03 Install an Ingress Controller

An ingress controller is a piece of software that provides reverse proxy, configurable traffic routing. Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. Using an ingress controller and ingress rules, a single external address can be used to route traffic to multiple services in a Kubernetes cluster.

Install NGINX Ingress Controller with Helm

Update the Helm repository

helm repo update

Install the nginx ingress controller with RBAC disabled

helm install --name nginx-ing stable/nginx-ingress --set rbac.create=false --namespace kube-system

NGINX ingress controller should now be installed in your cluster. Azure AKS automatically adds a load balancer called Kubernetes and a public IP to the resource group.

placeholder

Run the following command to see the services running in the cluster in the kube-system namespace

kubectl get services --namespace kube-system

Output:

NAME                                      TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)                      AGE
heapster                                  ClusterIP      10.0.195.50    <none>         80/TCP                       2h
kube-dns                                  ClusterIP      10.0.0.10      <none>         53/UDP,53/TCP                2h
kubernetes-dashboard                      ClusterIP      10.0.58.84     <none>         80/TCP                       2h
nginx-ing-nginx-ingress-controller        LoadBalancer   10.0.141.187   23.100.26.95   80:30459/TCP,443:31810/TCP   11m
nginx-ing-nginx-ingress-default-backend   ClusterIP      10.0.42.127    <none>         80/TCP                       11m
tiller-deploy                             ClusterIP      10.0.115.145   <none>         44134/TCP                    56m

You will see the nginx controller that can be accessed from the external internet (type: LoadBalancer) with an external IP assigned. You will also see an nginx default backend that runs inside the cluster and cannot be accessed from the internet (type: ClusterIP). The Load Balancer will route traffic to the default backend whenever a request for an unregistered path is made.

If you navigate to the external IP address (in this instance, 23.100.26.95) you will see the nginx default backend in the browser.

placeholder

Increasing the NGINX Proxy Buffer Size

The NGINX ingress controller Proxy Buffer Size is not large enough to handle the headers returned from some services. You will need to increase the buffer size. Create a ConfigMap file called ‘nginx-configuration.yaml’ and add this code. Replace the [placeholder] text with your nginx pod name (without the id extension).

kind: ConfigMap  
apiVersion: v1  
metadata:  
  name: [your-nginx-pod-name]
  namespace: kube-system
data:  
  proxy-buffer-size: "16k"

You can get the pod name for nginx with the following command

kubectl get pods --namespace kube-system

Output:

NAME                                                       READY     STATUS    RESTARTS   AGE
heapster-6599f48877-zj927                                  2/2       Running   0          2h
kube-dns-v20-7c556f89c5-5w5d2                              3/3       Running   0          2h
kube-dns-v20-7c556f89c5-fk8st                              3/3       Running   0          2h
kube-proxy-zksb6                                           1/1       Running   0          2h
kube-svc-redirect-4zr5z                                    1/1       Running   0          2h
kubernetes-dashboard-546f987686-v2g9v                      1/1       Running   0          2h
nginx-ing-nginx-ingress-controller-56b8ff549-6lshm         1/1       Running   0          27m
nginx-ing-nginx-ingress-default-backend-7f6dc6f7c4-dw5h4   1/1       Running   0          27m
omsagent-zt84m                                             1/1       Running   1          2h
tiller-deploy-5dd4f7b964-qz4rk                             1/1       Running   0          28m
tunnelfront-df6544c87-c6vv9                                1/1       Running   0          2h

The pod name in this instance is

nginx-ing-nginx-ingress-controller

CD into the folder where you saved the ConfigMap and run the following command:

kubectl apply -f nginx-configuration.yaml 

The nginx ingress controller will be updated and restarted with the new configuration value for the proxy buffer size.

Next Steps

The next article in this website will walk you through installing HTTPS certificates with cert-manager.

Next Article : Install HTTPS Certificates

Comments