Implementation Ingress Controller

Ayi angio
FAUN — Developer Community 🐾
3 min readJan 11, 2022

--

Photo by Denys Nevozhai on Unsplash

Hi Everyone, in this article I want to share how to implement an ingress controller.

The ingress controller functions as a load balancer to direct requests from outside to internal service Kubernetes.

Prerequisite

  • Kubernetes Version 1.19 or newer
  • Nginx-Ingress Version 1 or Newer
  • Helm Version 3
  • At least 1 Application Running on Kubernetes

Steps

Deploy Ingress-controller

In this article using Nginx as an ingress controller, there are many options for ingress controller, such as kong, haproxy, ambassador, etc.

  • First, we take is to add the helm repository to deploy the Nginx ingress controller, using the following command:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update
  • After that, download the values.yaml file from the ingress-nginx repository using the command below:
helm show values ingress-nginx/ingress-nginx > values.yaml
  • Open the values.yaml and change nginx in the line 99 as a needed. In this section, it will be a reference for every ingress in each service that wants to use the ingress controller that we have been created.
values.yaml
  • Create a namespace for the ingress controller. The namespace is nginx-ingress
kubectl create ns nginx-ingress
  • Deploy ingress-nginx using helm on the nginx-ingress namespace with the name nginx, using the command below:
helm install nginx ingress-nginx/ingress-nginx -f values.yaml -n nginx-ingress
  • Make sure the ingress controller is deployed
kubectl get all -n nginx-ingress
  • Make sure the ingress class is appropriate
kubectl get ingressclass

Deploy Ingress

We will deploy this Ingress in each service that should be accessed from outside, even though there is an option to use the type load balancer from the service on every application on Kubernetes, this is not a best practice because it will use a lot of public IP addresses. Therefore, we use ingress as a way for services to be accessed from outside.

if you want to access services from outside using a public IP address, you should use the load balancer type in the service application

Here are the steps for deploying ingress

  • Copy and paste the simple configuration and save with the name ingress.yaml
ingress.yaml

In the section IngressClassName, adjust the IngressClassName that has been defined in the Nginx-ingress-controller and validate with the command below

kubectl get ingressclass
  • Apply the configuration
kubectl apply -f ingress.yaml -n (namespace application)
  • Make sure ingress and ingress controller are connected

a. Check Ip public ingress controller

kubectl get svc -n nginx-ingress

b. Check IP ingress in the application and make sure it’s like IP on the ingress controller

kubectl get ing -n (namespace application)
  • The last step is the registration hostname that has been determined in ingress.yaml to DNS management. So, that should be accessed from outside if isn’t registered the application shouldn’t be accessed.

Join FAUN: Website 💻|Podcast 🎙️|Twitter 🐦|Facebook 👥|Instagram 📷|Facebook Group 🗣️|Linkedin Group 💬| Slack 📱|Cloud Native News 📰|More.

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

--

--