Tag Archives: ingress

[Solved] Kubernetes ingress-srv. error: failed calling webhook “validate.nginx.ingress.kubernetes.io”

Problem scenario

When writing the configuration file of the ingress controller entry controller of kubernetes

kubectl apply -f ingress-srv.yaml

Three Errors:

    1. Error 1:

no matches for kind “Ingress” in version “networking.k8s.io/v1beta1”

    Error 2: pathType is wrong after I modified APIVersion to v1.

Error 3: Error from server (InternalError): error when creating “ingress-srv.yaml”: Internal error occurred: failed calling webhook “validate.nginx.ingress.kubernetes.io”: Post “https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1/ingresses?timeout=10s”: dial tcp 10.102.20.133:443: connect: connection refused

 

Solution 1:
no matches for kind “Ingress” in version “networking.k8s.io/v1beta1”
Modify

apiVersion: networking.k8s.io/v1beta1

to

apiVersion: networking.k8s.io/v1

 

Solution 2:

pathType is wrong after I modified APIVersion to v1.

It is the version issue. here is the mofied codes below:

Original codes (report error):

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: posts.com
      http:
        paths:
          - path: /posts/create
            backend:
              serviceName: posts-clusterip-srv
              servicePort: 4000
          - path: /posts
            backend:
              serviceName: query-srv
              servicePort: 4002
          - path: /posts/?(.*)/comments
            backend:
              serviceName: comments-srv
              servicePort: 4001
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000

Here is the modified code:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: posts.com
      http:
        paths:
          - pathType: Prefix
            path: "/posts/create"
            backend:
              service:
                name: posts-clusterip-srv
                port:
                  number: 4000
          - pathType: Prefix
            path: "/posts"
            backend:
              service:
                name: query-srv
                port:
                  number: 4002
          - pathType: Prefix
            path: "/posts/?(.*)/comments"
            backend:
              service:
                name: comments-srv
                port:
                  number: 4001
          - pathType: Prefix
            path: "/?(.*)"
            backend:
              service:
                name: client-srv
                port:
                  number: 3000

 

Solution 3:
1. First kubectl get ValidatingWebhookConfiguration
2. Then kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
3. Delete that admission, and then it’s normal