How to expose an ingress on kuberntes to get the public IP address?

5/3/2021

I am new in AWS and EKS. Everything is going well except I am not able to figure out How to expose the ingress IP/Domain for public usage?

I tested on minikube and using minikube ip, I was able to run the application. How should I do it in AWS EKS?

Here is my ingress service file

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
 name: platform-app-ingress
 annotations:
   nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
   - http:
      paths:
        - path: /?(.*)
          pathType: Prefix
          backend:
            serviceName: platform-app-api
            servicePort: 80

Any hint? what am I doing wrong here?

-- Amit Pal
amazon-eks
amazon-web-services
kubernetes
kubernetes-ingress
kubernetes-pod

2 Answers

5/3/2021

You are missing the ingress endpoint at least in between, please refer https://kubernetes.io/docs/concepts/services-networking/ingress/. The correct communication is: internet -> ingress endpoint/LB -> ingress controller -> ingress object -> routing rule -> service -> available pod In this case you don't have to worry about public IP. However, if you use service directly with type=loadbalancer you will get External IP field while describing service.

-- Abhi
Source: StackOverflow

5/3/2021

You have to install the ingress controller basically which handles and manages the ingress object.

there are multiple ingress controllers available in the market for the Kubernetes you can use one of as per need.

https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/

so your whole traffic whole will be something like

internet > ingress > ingress controller > Kubernetes service > pod >  container

you are using the annotation of nginx

for that controller is must need to be installed in cluster.

everything will be same just you need to install the controller using YAML or Helm chart no other configuration required.

you can read more at : https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-on-digitalocean-kubernetes-using-helm

Official deployment documentation : https://kubernetes.github.io/ingress-nginx/deploy/

how to install on AWS : https://kubernetes.github.io/ingress-nginx/deploy/#aws

Note :

Once you will deploy the Ingress controller it will create one Kubernetes service with the type LoadBalancer.

you can check this using the Kubectl get svc -n <Respective namespace>

Use that IP as the public IP. you can add this IP into the DNS and create the multiple subdomain and domain as per need.

-- Harsh Manvar
Source: StackOverflow