NGINX Ingress Controller installation¶
NGINX Ingress Controller is an implementation of the Kubernetes Ingress API that manages external access to services within a cluster, typically via HTTP.^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md] It provides functionalities such as load balancing, SSL termination, and name-based virtual hosting.^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
Installation¶
To deploy the NGINX Ingress Controller, apply the official installation manifest using kubectl.^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md] The following command deploys the controller using a LoadBalancer type service, suitable for environments that support it (e.g., cloud providers).
[kubectl](<./kubectl.md>) apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml
This command automatically provisions the ingress-nginx namespace and configures necessary components, including:
* ServiceAccount and RBAC roles (ClusterRole, ClusterRoleBinding, Role, RoleBinding).
* ConfigMaps for configuration.
* The ingress-nginx-controller deployment and associated services.
* IngressClass resource (named nginx).^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
Verification¶
After applying the configuration, you can verify the status of the controller pods and services within the ingress-nginx namespace:^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
[kubectl](<./kubectl.md>) get pods --namespace=ingress-nginx
Expected output includes the ingress-nginx-controller in a Running state and admission webhook jobs in a Completed state.^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
You can also check the services to confirm the LoadBalancer IP assignment:
[kubectl](<./kubectl.md>) get service ingress-nginx-controller --namespace=ingress-nginx
If the EXTERNAL-IP field displays <pending>, it indicates the cluster environment cannot provision a load balancer (common in local clusters lacking specific support).^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
Configuration and Testing¶
Once installed, the controller requires Ingress resources to route traffic. A typical workflow involves:
- Deploying a Backend: Exposing a deployment (e.g.,
httpd) via a service. - Creating an Ingress Resource: Defining rules to map hostnames or paths to the backend service, specifying the
ingressClassName: nginx.^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
For local testing or if a LoadBalancer IP is unavailable, you can access the service using port-forward:
[kubectl](<./kubectl.md>) port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80
This forwards local port 8080 to port 80 on the controller, allowing you to verify routing using the hostname defined in your Ingress rules (e.g., demo.localdev.me).^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]
Related Concepts¶
- Kubernetes
- [[Service]]
- Ingress
- SSL Termination
Sources¶
^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]