Home > Mobile >  Kubernetes Ingress - cannot access
Kubernetes Ingress - cannot access

Time:11-24

I'm new to Ingress in Kubernetes. I installed Ingress NGINX controller in my AKS cluster. My application runs in a pod (Port 80) in testns (Namespace). I created a service for it in the same namespace. Now I want to access my application from outside. So I created an Ingress yaml for it.

service.yaml

 kubectl get svc -A | grep my-svc
    testns    my-svc                         ClusterIP      10.0.116.192   <none>          80/TCP                             93m

ingress

Name:             example-ingress
Namespace:        testns
Address:
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *
              /apple   my-svc:80 (10.244.1.33:80)
Annotations:  ingress.kubernetes.io/rewrite-target: /
Events:       <none>

ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /apple
          backend:
            serviceName: my-svc
            servicePort: 80

When I access using the <IP_ADDRESS_OF_THE_INGRESS>/apple, it gives an 404 error. I want to know why the application can't be accessed.

CodePudding user response:

Try adding the ingress class into YAML config kubernetes.io/ingress.class: "nginx"

as annotation

kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /

Example

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /apple
          backend:
            serviceName: my-svc
            servicePort: 80
  • Related