Nginx ingress will act as a load balancer for the Kubernetes cluster.
In this section, you will install the nginx ingress controller.
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.
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
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
Enter <PRIMEHUB-IP> in your local browser and you will see the output below.
This value allows you to upload bigger files to PrimeHub web portal.
Modify the nginx ingress configMap to change proxy-body-size
to 15m
if needed:
The unit of the size is mb
.
kubectl patch configmap nginx-ingress-ingress-nginx-controller -n ingress-nginx --type merge -p '{"data":{"proxy-body-size":"15m"}}'
This value allows you to keep a longer response time to PrimeHub website.
Add the proxy connection timeout settings to provide longer connection timeout:
The unit of the number is second
.
kubectl patch configmap nginx-ingress-ingress-nginx-controller -n ingress-nginx --type merge -p '{"data":{"proxy-connect-timeout":"300"}}'
kubectl patch configmap nginx-ingress-ingress-nginx-controller -n ingress-nginx --type merge -p '{"data":{"proxy-read-timeout":"300"}}'
kubectl patch configmap nginx-ingress-ingress-nginx-controller -n ingress-nginx --type merge -p '{"data":{"proxy-send-timeout":"300"}}'
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
.....