<p>After creating a deployment for a web-application, consisting of pod, internal service and ingress, the ingress can't be created. When executing <code>kubectl apply -f web-app.yaml</code>, I get the error:
<code>error when creating &quot;web-app.yaml&quot;: Internal error occurred: failed calling webhook &quot;validate.nginx.ingress.kubernetes.io&quot;: Post &quot;https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1/ingresses?timeout=10s&quot;: dial tcp 10.100.7.97:443: connect: no route to host</code></p>
<p>After some retries, it worked surprisingly, but after some changes to the deployment, the same error occurs again.</p>
<p><strong>web-app.yaml</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  namespace: development
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: registry/web-app:latest
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: web-app-internal
  namespace: development
spec:
  selector:
      app: web-app
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations: 
    kubernetes.io/ingress.class: &quot;nginx&quot;
  name: web-app-ingress
  namespace: development
  labels:
    name: web-app-ingress
spec:
  rules:
  - host: web.app
    http:
      paths:
      - pathType: Prefix
        path: &quot;/&quot;
        backend:
          service:
            name: web-app-internal
            port: 
              number: 8080

</code></pre>
<p>Any clues what the issue could be?</p>

andreas.teich
<p>The error you are getting is from the webhook trying to validate your ingress, and not the ingress object itself you are trying to apply.</p>
<p>The validation webhook is set by default to <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml#L27" rel="nofollow noreferrer">fail</a> the request if the webhook cannot process it. Is there are a chance your ingress controller was unavailable for any reason while you were trying to apply the ingress object?</p>
<p>Also, looking at a related <a href="https://stackoverflow.com/questions/52619828/kubernetes-no-route-to-host">SO question,</a> it might be an error related to DNS resolution.</p>
