Nginx ingress will act as a load balancer for the Kubernetes cluster.

In this section, you will install the nginx ingress controller.

Check the target install version

Visit the official nginx ingress GitHub repo and see the supported versions table to decide which helm chart version is supported by your running k8s cluster.

Install Nginx ingress controller

Download and install the nginx-ingress controller using the following commands. (Use 4.7.0 for example.)

# Download Nginx-ingress packages and decompress it
curl -L <https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-4.7.0/ingress-nginx-4.7.0.tgz> | tar xz
# Use helm chart to install Nginx-ingress
helm install nginx-ingress ./ingress-nginx \\
    --version 4.7.0 \\
    --create-namespace \\
    --namespace ingress-nginx \\
    --set controller.hostNetwork=true \\
    --set rbac.create=true \\
    --set defaultBackend.enabled=true \\
    --set tcp."2222"=hub/ssh-bastion-server:2222 \\
    --set controller.image.tag=v1.0.4 \\
    --set controller.image.digest=null \\
    --set controller.admissionWebhooks.enabled=false \\
    --set controller.resources.limits.cpu=250m \\
    --set controller.resources.limits.memory=200Mi \\
    --set controller.resources.requests.cpu=100m \\
    --set controller.resources.requests.memory=100Mi \\
    --set defaultBackend.resources.limits.cpu=250m \\
    --set defaultBackend.resources.limits.memory=100Mi \\
    --set defaultBackend.resources.requests.cpu=100m \\
    --set defaultBackend.resources.requests.memory=64Mi \\
    --set data.proxy-body-size=10m

Verify installation

Use curl to verify that nginx-ingress is running correctly - A 404 response is correct at this stage.

$ curl http://<PRIMEHUB-IP>

default backend - 404

Tuning the Nginx ingress controller settings

Proxy body size

This value allows you to upload bigger files to PrimeHub web portal.

Proxy connection timeout

This value allows you to keep a longer response time to PrimeHub website.

Check the current nginx ingress controller settings:

kubectl -n ingress-nginx get cm nginx-ingress-ingress-nginx-controller -o yaml

You should see the following:

apiVersion: v1
data:
  allow-snippet-annotations: "true"
  proxy-body-size: 15m
  proxy-connect-timeout: "300"
  proxy-read-timeout: "300"
  proxy-send-timeout: "300"
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: nginx-ingress
    meta.helm.sh/release-namespace: ingress-nginx
.....

Reference: