Why kubernetes ingress does not have an adress?

Viewed 41

Good day!

I have an ingress controller.

ingress.yml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: main-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - host: miyron-my-app.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: api-gateway-service
            port:
              number: 80
$ kubectl get ingress
NAMESPACE            NAME           CLASS   HOSTS                 ADDRESS   PORTS   AGE
default              main-ingress   nginx   miyron-my-app.com             80      58m

if i trying get ingress logs i get

$ kuebctl describe ingress main-ingress

result:

Name:             main-ingress
Labels:           <none>
Namespace:        default
Address:
Ingress Class:    nginx
Default backend:  <default>
Rules:
  Host                 Path  Backends
  ----                 ----  --------
  miyron-my-app.com
                       /   api-gateway-service:80 (172.17.0.10:80,172.17.0.11:80,172.17.0.8:80)
Annotations:           nginx.ingress.kubernetes.io/rewrite-target: /
Events:
  Type     Reason          Age   From                      Message
  ----     ------          ----  ----                      -------
  Normal   AddedOrUpdated  43m   nginx-ingress-controller  Configuration for default/main-ingress was added or updated

What could be wrong? Maybe you need to configure the ingress controller somehow. How do I give it an ip address or does it get one by itself? What am I doing wrong?

1 Answers

There might be multiple reasons for the ingress controller for not having an ip address. Check whether the service is exposed on port 80. If not, configure the service to be exposed on port 80.

Try adding the annotation in ingress.yaml

kubernetes.io/ingress.class: nginx

And check the cluster is configured with an nginx Ingress controller. Always check with the Kubernetes admin for the configuration.

If the issue was happening because the ingress controller was not running in the cluster then you have to manually install and run the below command to install ingress controller.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/baremetal/deploy.yaml

Once this is done check if ingress controller pod is up it will be present in ingress-nginx namespace.

kubectl get pods -n ingress-nginx

Once this was done the ingress address had appeared.

Refer to the doc for Installing Ingress Controller and the link for more information.

Related