Nginx Ingress is an open-source Kubernetes Ingress controller that uses Nginx as a reverse proxy to manage and route external traffic to services within a Kubernetes cluster. In Kubernetes, an Ingress is an API object that provides HTTP and HTTPS routing to services based on rules. In other words, it acts as an entry point for external traffic to reach services deployed in the Kubernetes cluster.
Key features of Nginx Ingress include:
- Load Balancing: Nginx Ingress can distribute incoming traffic across multiple pods of a service, ensuring efficient utilization of resources.
- SSL/TLS Termination: It supports terminating SSL/TLS connections, allowing you to secure your applications with HTTPS.
- Path-Based Routing: You can define rules based on URL paths to route traffic to different services within the cluster.
- Rewrites and Redirections: Nginx Ingress allows you to define URL rewrites and redirections, making it flexible for handling different use cases.
- Custom Configurations: You can customize the Nginx Ingress configuration using annotations in the Ingress resource, providing fine-grained control over its behavior.
Configuring Nginx Ingress in Kubernetes involves several steps. Below is a basic guide to help you set up Nginx Ingress Controller on your Kubernetes cluster.
Step 1: Adding Help Repository
Add the official Nginx Helm repository by using given command with helm.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
Step 2: Update the Helm repositories
After added the repository we need to update the repo by using given command.
helm repo update
Step 3: Installing Nginx Ingress Controller
We need to use given command to install the Nginx Ingress Controller, This command installs the Nginx Ingress Controller in the
default namespace. You can specify a different namespace by using the
helm install nginx-ingress ingress-nginx/ingress-nginx
Step 4: Verify Installation
After installation of nginx ingress controller we need to use the given command to validate the installation.
kubectl get pods -n default -l app.kubernetes.io/name=ingress-nginx --watch
Step 5: Create an Ingress Resource
Create a sample Ingress resource to define how Nginx should route traffic:
Paste the following configuration and update your backend service, port, Path and domain name.
- host: example.com
- path: /app
Step 6: Accessing Your Application
Depending on your setup, you might need to update DNS records or modify your /etc/hosts file to point your domain to the IP address of the Ingress Controller.
We have successfully deploy nginx ingress controller using helm on K8s cluster, If you still have questions, please post them in the comments section below.