This article will help you install and start using the nginx ingress controller. To learn about Kubernetes services, ingress, and ingress controllers, refer to the article "Set up the Gcore ingress controller".
Once you install the nginx ingress controller, our system automatically creates a load balancer. The traffic will go to that load balancer, which will then forward it to the nginx controller. After that, the nginx controller will distribute traffic across services within your cluster according to the rules specified in the ingress manifests.
1. Run the kubectl command to create a namespace for the nginx controller.
kubectl create namespace ingress-nginx
2. Run the command to add the helm repository for the nginx controller.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
3. Run the command to update the helm repository data.
helm repo update
4. Run the command to install the controller.
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.ingressClassResource.name=nginx \
--set controller.ingressClassResource.controllerValue="example.com/ingress-nginx" \
--set controller.ingressClassResource.enabled=true \
--set controller.ingressClassByName=true \
--set controller.hostNetwork=true
You have installed the nginx controller. Now it will automatically create a load balancer on your behalf. The load balancer will be shown in your control panel in the Load Balancers section. The traffic will go to the nginx controller through this balancer. To start using the controller, you need to apply an Ingress manifest.
1. Create a YAML file in any text or code editor to create an Ingress object:
Enter your custom values instead:
Make sure to add ingressClassName: nginx
to the spec attributes.
2. Run the kubectl command from the file directory.
kubectl apply -f <name of the created YAML-file>
You’ll get the output:
Ingress/<name of the created ingress object> created
Congratulations! You’ve created and applied an ingress object for the nginx ingress controller.
If you want to see an IP address of the load balancer through which the traffic comes, view it in your control panel in the Load Balancers section or run the command:
kubectl get ingress <ingress name>
You’ll get the output:
The IP address is written in the ADDRESS column.
Was this article helpful?
Discover our offerings, including virtual instances starting from 3.7 euro/mo, bare metal servers, AI Infrastructure, load balancers, Managed Kubernetes, Function as a Service, and Centralized Logging solutions.