Ingress Controllers & Networking
A comprehensive developer cheatsheet covering Kubernetes Ingress and HTTP/HTTPS routing, featuring essential CLI commands, YAML configurations, and operational workflows for managing ingress resources, controller classes, TLS/SSL termination secrets, and popular ingress controllers like NGINX, AWS ALB, and Traefik.
Table of Contents
- Ingress — HTTP/HTTPS Routing
- kubectl get ingress — List Ingresses
- kubectl describe ingress — Show Ingress Details
- kubectl get ingressclass — List Ingress Classes
- kubectl create ingress — Create an Ingress
- Quick Reference — Most Used Commands
- Pro Tips
Ingress — HTTP/HTTPS Routing
Ingress exposes HTTP and HTTPS routes from outside the cluster to services.
Prerequisites
- Ingress Controller must be installed (e.g., NGINX, AWS ALB, Traefik, GCE)
- IngressClass defines which controller to use
Common Ingress Controllers
| Controller | Installation Command |
|---|---|
| NGINX | kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml |
| AWS ALB | kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.0/docs/install/v2_5_0.yaml |
| Traefik | helm install traefik traefik/traefik |
| GCE | Built-in with GKE |
kubectl get ingress — List Ingresses
Lists ingress resources in the cluster.
Basic Usage
$ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
my-ingress nginx example.com 10.0.0.1 80 5d
api-ingress nginx api.example.com 10.0.0.2 80,443 2dCommon Flags
| Flag | Purpose |
|---|---|
-n | Namespace |
-A | All namespaces |
-o wide | Show more details |
Examples
Get ingresses in namespace:
$ kubectl get ingress -n productionGet all ingresses:
$ kubectl get ingress -AGet with wide output:
$ kubectl get ingress -o wide
NAME CLASS HOSTS ADDRESS PORTS AGE
my-ingress nginx example.com 10.0.0.1 80 5dkubectl describe ingress — Show Ingress Details
Shows detailed information about an ingress resource.
Basic Usage
$ kubectl describe ingress my-ingress
Name: my-ingress
Namespace: default
Address: 10.0.0.1
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
example.com
/ nginx-service:80 (10.0.1.100:80,10.0.1.101:80)
/api api-service:80 (10.0.1.102:80)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 5d nginx-ingress-controller Scheduled for syncExamples
Describe with namespace:
$ kubectl describe ingress my-ingress -n productionkubectl get ingressclass — List Ingress Classes
Lists available ingress classes in the cluster.
Basic Usage
$ kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
nginx k8s.io/ingress-nginx <none> 30d
alb ingress.k8s.aws/alb <none> 20dExamples
Describe an ingress class:
$ kubectl describe ingressclass nginx
Name: nginx
Labels: <none>
Annotations: <none>
Controller: k8s.io/ingress-nginx
Events: <none>kubectl create ingress — Create an Ingress
Creates an ingress resource imperatively (or from YAML).
From YAML (Recommended)
ingress.yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80$ kubectl create -f ingress.yaml
ingress.networking.k8s.io/my-ingress createdFrom CLI (Imperative)
Create simple ingress:
$ kubectl create ingress my-ingress --rule=example.com/*=nginx-service:80
ingress.networking.k8s.io/my-ingress createdCreate with TLS:
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80,tls=my-tls"Create with multiple rules:
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80" --rule="api.example.com/*=api-service:80"Dry-run to generate YAML:
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80" --dry-run=client -o yamlTLS/SSL with Ingress
Create TLS Secret
$ kubectl create secret tls my-tls --cert=path/to/cert.pem --key=path/to/key.pemIngress with TLS
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
ingressClassName: nginx
tls:
- hosts:
- example.com
secretName: my-tls
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80Quick Reference — Most Used Commands
| Task | Command |
|---|---|
| List ingresses | kubectl get ingress |
| List ingresses in namespace | kubectl get ingress -n production |
| List all ingresses | kubectl get ingress -A |
| Describe ingress | kubectl describe ingress my-ingress |
| List ingress classes | kubectl get ingressclass |
| Describe ingress class | kubectl describe ingressclass nginx |
| Create ingress from YAML | kubectl create -f ingress.yaml |
| Create ingress from CLI | kubectl create ingress my-ingress --rule="example.com/*=nginx:80" |
Pro Tips
-
Ingress Controller must be installed — without it, Ingress resources do nothing.
-
Check controller status:
bashkubectl get pods -n ingress-nginx -
IngressClass is required — specify which controller to use.
-
Multiple path types:
Prefix— matches path prefixExact— matches exact pathImplementationSpecific— controller-specific behavior
-
Annotations are controller-specific — NGINX uses
nginx.ingress.kubernetes.io, AWS ALB usesalb.ingress.kubernetes.io. -
Test ingress locally with port-forward:
bashkubectl port-forward svc/ingress-nginx-controller -n ingress-nginx 8080:80 -
Check ingress endpoints:
bashkubectl get endpoints nginx-service -
Troubleshoot ingress:
- Check controller logs
- Verify service endpoints
- Check DNS resolution