Skip to content

NGINX Ingress Controller for Kubernetes (Microservices)

Notifications You must be signed in to change notification settings

kayvansol/Ingress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

Setting up Ingress controller NGINX (as a router) along with HAproxy for Microservice deployed inside Kubernetes cluster (Bare-metal servers)

alt text

General Design (big picture) :

alt text

All files needed for deployments are available at Manifests folder.

The control-plane & worker nodes addresses are :

192.168.56.115
192.168.56.116
192.168.56.117

alt text

and HAProxy as a Load Balancer :

192.168.56.118

Kubernetes cluster nodes :

alt text

The Steps :

  1. Install NGINX Ingress Controller from :
https://docs.k0sproject.io/main/examples/nginx-ingress
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.3/deploy/static/provider/baremetal/deploy.yaml

kubectl get all --namespace=ingress-nginx

Ingress-Nginx workloads (ingress port in our case is 30798) :

alt text


  1. On the node, where the POD will be located (node1 and node2 in our case) :
DIRNAME="vol1"
mkdir -p /mnt/disk/$DIRNAME 
chcon -Rt svirt_sandbox_file_t /mnt/disk/$DIRNAME
chmod 777 /mnt/disk/$DIRNAME

  1. Deploy the Storage Class & PV & PVC :
kubectl apply -f storageClass.yaml

kubectl apply -f persistentVolume.yaml
kubectl apply -f persistentVolume1.yaml

kubectl apply -f persistentVolumeClaim.yaml
kubectl apply -f persistentVolumeClaim1.yaml

alt text


  1. Deploy the web apps :
kubectl apply -f http-pod.yaml
kubectl apply -f http-pod1.yaml

alt text alt text alt text

Get pod ip & curl the related web app :

POD_IP=$(kubectl get pod www2-c5644ff98-trk4d  -o yaml | grep podIP | awk '{print $2}'); echo $POD_IP

curl $POD_IP

  1. Deploy the Services :
kubectl apply -f IngressService.yaml
kubectl apply -f IngressService1.yaml

alt text alt text


  1. Deploy the Ingress resource :
kubectl apply -f Ingress.yaml

alt text alt text

Note: you can also Secure NGINX-ingress via this Securing NGINX-ingress


  1. HAProxy config as a Load Balancer (On 192.168.56.118) :
sudo nano /etc/haproxy/haproxy.cfg

alt text


  1. DNS Record (On DNS Server) :

alt text


The final results are 🍹 :

alt text alt text