<p>My yaml file.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    -http:
      paths:
        - path: /?(.*)
          backend:
            serviceName: nginx-service
            servicePort: 80
</code></pre>
<pre><code>kubectl apply -f file.yaml

error: error validating &quot;ingress.yaml&quot;: error validating data: ValidationError(Ingress.spec.rules): invalid type for io.k8s.api.networking.v1beta1.IngressSpec.rules: got &quot;map&quot;, expected &quot;array&quot;; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>this is yaml template error only, use</p>
<pre><code>kubectl explain ingress.spec.rules
</code></pre>
<p>to get idea.</p>
<p>The hostname is also missing in the ingress rule, should have been something like</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    -host: {replace-me-with-hostname}
     http:
       paths:
        - path: /?(.*)
          backend:
            serviceName: nginx-service
            servicePort: 80 
</code></pre>
<hr />
