New batchZero to DevOps starts 29 Nov · limited seatsReserve your seat
Cheat sheetsKubernetesKubernetes
FreeSheet 04 of 16

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

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

ControllerInstallation Command
NGINXkubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml
AWS ALBkubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.0/docs/install/v2_5_0.yaml
Traefikhelm install traefik traefik/traefik
GCEBuilt-in with GKE

kubectl get ingress — List Ingresses

Lists ingress resources in the cluster.

Basic Usage

bash
$ 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  2d

Common Flags

FlagPurpose
-nNamespace
-AAll namespaces
-o wideShow more details

Examples

Get ingresses in namespace:

bash
$ kubectl get ingress -n production

Get all ingresses:

bash
$ kubectl get ingress -A

Get with wide output:

bash
$ kubectl get ingress -o wide
NAME         CLASS   HOSTS         ADDRESS         PORTS   AGE
my-ingress   nginx   example.com   10.0.0.1        80      5d

kubectl describe ingress — Show Ingress Details

Shows detailed information about an ingress resource.

Basic Usage

bash
$ 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 sync

Examples

Describe with namespace:

bash
$ kubectl describe ingress my-ingress -n production

kubectl get ingressclass — List Ingress Classes

Lists available ingress classes in the cluster.

Basic Usage

bash
$ kubectl get ingressclass
NAME    CONTROLLER                    PARAMETERS   AGE
nginx   k8s.io/ingress-nginx          <none>       30d
alb     ingress.k8s.aws/alb           <none>       20d

Examples

Describe an ingress class:

bash
$ 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).

ingress.yaml:

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
bash
$ kubectl create -f ingress.yaml
ingress.networking.k8s.io/my-ingress created

From CLI (Imperative)

Create simple ingress:

bash
$ kubectl create ingress my-ingress --rule=example.com/*=nginx-service:80
ingress.networking.k8s.io/my-ingress created

Create with TLS:

bash
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80,tls=my-tls"

Create with multiple rules:

bash
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80" --rule="api.example.com/*=api-service:80"

Dry-run to generate YAML:

bash
$ kubectl create ingress my-ingress --rule="example.com/*=nginx-service:80" --dry-run=client -o yaml

TLS/SSL with Ingress

Create TLS Secret

bash
$ kubectl create secret tls my-tls --cert=path/to/cert.pem --key=path/to/key.pem

Ingress with TLS

yaml
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: 80

Quick Reference — Most Used Commands

TaskCommand
List ingresseskubectl get ingress
List ingresses in namespacekubectl get ingress -n production
List all ingresseskubectl get ingress -A
Describe ingresskubectl describe ingress my-ingress
List ingress classeskubectl get ingressclass
Describe ingress classkubectl describe ingressclass nginx
Create ingress from YAMLkubectl create -f ingress.yaml
Create ingress from CLIkubectl create ingress my-ingress --rule="example.com/*=nginx:80"

Pro Tips

  1. Ingress Controller must be installed — without it, Ingress resources do nothing.

  2. Check controller status:

    bash
    kubectl get pods -n ingress-nginx
  3. IngressClass is required — specify which controller to use.

  4. Multiple path types:

  • Prefix — matches path prefix
  • Exact — matches exact path
  • ImplementationSpecific — controller-specific behavior
  1. Annotations are controller-specific — NGINX uses nginx.ingress.kubernetes.io, AWS ALB uses alb.ingress.kubernetes.io.

  2. Test ingress locally with port-forward:

    bash
    kubectl port-forward svc/ingress-nginx-controller -n ingress-nginx 8080:80
  3. Check ingress endpoints:

    bash
    kubectl get endpoints nginx-service
  4. Troubleshoot ingress:

  • Check controller logs
  • Verify service endpoints
  • Check DNS resolution

Next in KubernetesInteracting with Pods Pro