- 20 Nov 2023
- 3 Minutes to read
- Print
- DarkLight
How To Install or Upgrade NGINX Ingress Controller
- Updated on 20 Nov 2023
- 3 Minutes to read
- Print
- DarkLight
Background
RealTheory can notify you if NGINX Ingress Controller is a required component in your environment that is not present on your cluster or if the version of NGINX Ingress Controller that is installed is not in compliance with organizational standards.
Solution - Installation
If NGINX Ingress Controller is a required component in your Kubernetes environment, it is most likely that a Helm chart or the manifest file needed for the installation already exist. Contact your Operations or DevOps team to determine if there are company resources for installing NGINX Ingress Controller BEFORE using either of the following procedures.
Procedure Using HELM Chart Package Manager
To install NGINX Ingress Controller:
Use the Helm Installation Guide to install Helm (if not already installed).
Use the following commands to add the NGINX Helm repository:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
Create a namespace for NGINX Ingress Controller.
Example:
kubectl create namespace ingress-nginx
Do one of the following:
To install the latest version, use the following command:
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx
To install a specific version, use the following command:
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx --version <version>
where
<version>
is the version number of the NGINX Ingress Controller you want to install.
Verify the NGINX Ingress Controller pods are running:
kubectl get pods -n ingress-nginx
Obtain the external IP or hostname assigned to the Ingress Controller service:
kubectl get services -n ingress-nginx
Verify that the NGINX Ingress Controller is accessible by opening a web browser or using a tool like curl or wget to access the external IP or hostname:
Example:
curl http://<external-ip>
where
<external-ip>
is the external IP or hostname obtained in Step 6.
Procedure Using the YAML Manifest
To install NGINX Ingress Controller:
Create a namespace for the NGINX Ingress Controller.
Example:
kubectl create namespace ingress-nginx
Apply the default backend deployment and service, which handle requests that are not matched by any Ingress rules.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml
Verify the NGINX Ingress Controller pods are running:
kubectl get pods -n ingress-nginx
If you are using Minikube or Kind, you might need to expose the service to an external IP:
kubectl expose deployment ingress-nginx-controller --type=NodePort --name=ingress-nginx-controller --namespace=ingress-nginx
Obtain the external IP or hostname assigned to the Ingress Controller service:
kubectl get services -n ingress-nginx
Note: If you are using Minikube or Kind, you can use the Minikube or Kind IP as the external IP.
Verify that the NGINX Ingress Controller is accessible by opening a web browser or using a tool like curl or wget to access the external IP or hostname:
Example:
curl http://<external-ip>
where
<external-ip>
is the external IP or hostname obtained in Step 5.
Solution - Upgrade
If a specific version of NGINX Ingress Controller is required in your Kubernetes environment, it is most likely that a Helm chart or the manifest files already exist. Contact your Operations or DevOps team to determine if there are company resources for installing NGINX Ingress Controller BEFORE using either of the following procedures.
Procedure Using HELM Chart Package Manager
To upgrade NGINX Ingress Controller:
Use the Helm Installation Guide to install Helm (if not already installed).
Do one of the following:
To upgrade to the latest version, use the following command:
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx
To upgrade to a specific version, use the following command:
helm upgrade <release-name> ingress-nginx/ingress-nginx --namespace ingress-nginx --version <version>
where
<release-name>
is the name of your NGINX Ingress Controller release and<version>
is the version number of the NGINX Ingress Controller you want to upgrade to.
Verify the NGINX Ingress Controller pods are running and have been updated:
kubectl get pods -n ingress-nginx
Procedure Using YAML Manifest
To upgrade NGINX Ingress Controller:
Obtain the manifests for the version you want to upgrade to from the NGINX Ingress Controller GitHub releases page
export NGINX_VERSION=<version>
curl -O https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml
where
<version>
is the version number of the NGINX Ingress Controller you want to upgrade to.Apply the updated manifests:
kubectl apply -f deploy.yaml
Verify the NGINX Ingress Controller pods are running and have been updated:
kubectl get pods -n ingress-nginx
Remove the previous NGINX Ingress Controller resources, such as the deployment and service, if they exist:
kubectl delete -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml