Ingress not showing up in namespace

6/30/2021

I have used the official Kubernetes-dashboard and was trying to setup an ingress for the dashboard. I have tried to put the ingress into the Kubernetes-dashboard namespace, but the ingress won't show up when I tried kubectl get all -n kubernetes-dashboard. I could still describe the ingress in the same namespace using kubectl get ingress -n kubernetes-dashboard, but the annotations shown up <none>. Can anyone please help me?

Here is my yaml file for the ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: 
  name: dashborad-ingress
  namespace: kubernetes-dashboard
spec:
  rules:
  - host: dashboard.com
    http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service: 
            name: kubernetes-dashboard
            port: 
              number: 443

And the output of kubectl desribe ingress -n kubernetes-dashboard

Name:             dashborad-ingress
Namespace:        kubernetes-dashboard
Address:          192.168.49.2
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host           Path  Backends
  ----           ----  --------
  dashboard.com  
                    kubernetes-dashboard:443 (172.17.0.6:8443)
Annotations:     <none>
Events:
  Type    Reason  Age                 From                      Message
  ----    ------  ----                ----                      -------
  Normal  Sync    4m7s (x5 over 24m)  nginx-ingress-controller  Scheduled for sync

Any helps would be appreciated.

-- kemoosabee
kubernetes
kubernetes-ingress

1 Answer

7/1/2021

Annotations displayed as <none> appear to correct behaviour. You haven't defined any in the attached yaml file, so <none> should be displayed. I have create simple ingress with one annotation to show you how it works. Look at my metadata section:

metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1

When I describe my ingress by using command: kubectl describe ingress I have this line in the output:

Annotations:  nginx.ingress.kubernetes.io/rewrite-target: /$1

However, I see the problem in a completely different place. When you describe ingress you have this line:

Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)

The default-backend is responsible to deliver the 404-page-not-found error page when you are trying to access a Service that does not have a rule defined or a Service that has not been configured correctly.

Depending on how you set up the cluster, the solutions may be different. However, if you are using bare metal and Minikube you can try to enable ingress addon:

minikube addons enable ingress

or

minikube addons enable ingress --alsologtostderr

Another solution to this addons:

kubectl apply -f https://raw.githubusercontent.com/roelal/minikube/5093d8b21c0931a6c63fa448538761b4bf100ee0/deploy/addons/ingress/ingress-rc.yaml
kubectl apply -f https://raw.githubusercontent.com/roelal/minikube/5093d8b21c0931a6c63fa448538761b4bf100ee0/deploy/addons/ingress/ingress-svc.yaml

You can also add defaultBackend as a part of your Ingress definition like so

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: default-backend-ingress-example
spec:
  defaultBackend:
    service:
      name: hotel-svc
      port:
        number: 80

See also:

-- Mikołaj Głodziak
Source: StackOverflow