NGINX Ingress Controller with HAProxy for k8s cluster

$ kubectl patch svc <application-name> -n <name-of-namespace> -p ‘{“spec”: {“type”: “LoadBalancer”, “externalIPs”:[“<haproxy-ip-address>”]}}’

What is ingress controller ?

Updates to cluster

$ vim inventory/mycluster/group_vars/k8s-cluster/addons.yml
# Nginx ingress controller deployment
ingress_nginx_enabled: false -> true
$ ansible-playbook -i inventory/mycluster/hosts.yaml — become — become-user=root cluster.yml
$ vim /etc/haproxy/haproxy.cfgfrontend kubernetes-ingress-http
bind *:80
default_backend kubernetes-worker-nodes-http
backend kubernetes-worker-nodes-http
balance leastconn
option tcp-check
server worker1 10.0.128.81:80 check fall 3 rise 2
server worker2 10.0.128.137:80 check fall 3 rise 2
server worker3 10.0.128.156:80 check fall 3 rise 2
NGINX Ingress Controller
Overview of HA Kubernetes Cluster
Overview of HA k8s cluster

Steps to create NGINX Ingress controller

$ git clone https://github.com/nginxinc/kubernetes-ingress/
$ cd kubernetes-ingress
$ kubectl apply -f common/ns-and-sa.yaml
$ kubectl apply -f rbac/rbac.yaml
$ kubectl apply -f common/default-server-secret.yaml
$ kubectl apply -f common/nginx-config.yaml
$ kubectl apply -f daemon-set/nginx-ingress.yaml
$ kubectl get allNAME READY STATUS RESTARTS AGE
pod/nginx-ingress-47z8r 1/1 Running 0 24h
pod/nginx-ingress-cmkfq 1/1 Running 0 24h
pod/nginx-ingress-ft5pv 1/1 Running 0 24h
pod/nginx-ingress-q554l 1/1 Running 0 24h
pod/nginx-ingress-ssdrj 1/1 Running 0 24h
pod/nginx-ingress-t9jml 1/1 Running 0 24h
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/nginx-ingress 6 6 6 6 6 <none> 24h

Deploy Example Application

Example NGINX Deployment
$ kubectl apply -f https://k8s.io/examples/application/deployment.yaml## or you can do same thing with local file as given below$ kubectl apply -f nginx-deploy-main.yml
$ kubectl expose deploy nginx-deployment --port 80
Ingress Ruleset
Ingress rules for different services
$ kubectl create -f nginx-ingress-resource.yml
Example NGINX Web Server Deployment Result

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store