ingress-nginx controller installation via kubectl¶
ingress-nginx is an Ingress Controller for Kubernetes that manages external access to cluster services, 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]. This document outlines the installation and verification process using kubectl^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Installation¶
The installation is performed by applying a specific manifest YAML file directly from the official ingress-nginx repository^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]. This process creates the necessary namespace, service accounts, roles, and controller resources^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Command¶
Execute the following command to deploy the controller^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]:
[kubectl](<./kubectl.md>) apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml
Upon success, kubectl will confirm the creation of numerous resources, including a namespace, service account, ConfigMap, RBAC roles, and the controller deployment^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Verification¶
After installation, you can verify that the controller pods are running correctly^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Checking Pods¶
List the pods in the ingress-nginx namespace to ensure the controller is running^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
[kubectl get pods](<./kubectl-get-pods.md>) --namespace=ingress-nginx
Expected Output:
You should see a pod named ingress-nginx-controller-***** in the Running state^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]. Temporary admission jobs will also be listed as Completed^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Checking Services¶
Examine the services to see how the Ingress Controller is exposed^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
[kubectl](<./kubectl.md>) get svc -A
The ingress-nginx-controller service is typically created as a LoadBalancer^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Service Configuration Details¶
LoadBalancer vs. NodePort¶
By default, the installation manifest often configures the service with type: LoadBalancer^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
- In Cloud Environments: If your cluster supports it, an external IP address or FQDN will be automatically assigned to the
EXTERNAL-IPfield^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]. - In Local/Bare-Metal Clusters: The
EXTERNAL-IPfield will often remain in a<pending>state because the cluster cannot provision a cloud load balancer^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]. In this state, access relies on theNodePortorPORT(S)mappings displayed in the service details^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Port Mappings¶
The service exposes HTTP and HTTPS ports^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]. Even when EXTERNAL-IP is pending, Kubernetes creates mappings (e.g., 80:32411/TCP) that allow access via the node's IP address and the assigned high port number^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Validation Workflow¶
To validate the Ingress Controller is functioning, you can deploy a test application and route traffic to it^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
- Create a deployment:
[kubectl](<./kubectl.md>) create deployment demo --image=httpd --port=80 - Expose the deployment:
[kubectl](<./kubectl.md>) expose deployment demo - Create an Ingress resource:
[kubectl](<./kubectl.md>) create [Ingress](<./ingress.md>) demo-localhost --class=nginx --rule=demo.localdev.me/*=demo:80 - Port Forward (for local testing):
Accessing
[kubectl port-forward](<./kubectl-port-forward.md>) --namespace=ingress-nginx service/ingress-nginx-controller 8080:80http://demo.localdev.me:8080/should return the default web server page^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md].
Related Concepts¶
- Kubernetes
- [[Service]]
- [[Load Balancer]]
Sources¶
^[400-devops__06-Kubernetes__k8s-learning__06.ingress__README.md]