Working with Ingress

1. Creating Ingress Resource

Example: Host + path-based routing with TLS

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
spec:
  ingressClassName: nginx
  tls:
  - hosts: [www.example.com]
    secretName: www-tls
  rules:
  - host: www.example.com
    http:
      paths:
      - { path: /api,  pathType: Prefix, backend: { service: { name: api,  port: { number: 80 } } } }
      - { path: /,     pathType: Prefix, backend: { service: { name: web,  port: { number: 80 } } } }

2. Listing Ingress Resources

kubectl get ing -A
kubectl get ing -o wide          # shows hosts, address, ports
ColumnMeaning
CLASSingressClassName
HOSTSFQDNs in rules
ADDRESSController external IP/host

3. Describing Ingress Details

SectionInfo
RulesHosts & path mappings
TLSHostnames & secrets
Default backendFallback service
EventsController sync/errors

4. Configuring Ingress Rules

MatchSource
HostHTTP Host header (with SNI for TLS)
PathpathType determines match semantics
Wildcard host*.example.com (single-label only)

5. Setting Default Backend

spec:
  defaultBackend:
    service: { name: notfound, port: { number: 80 } }
BehaviorDetail
No rule matchRouted to defaultBackend
Controller-wideNGINX has its own default-backend service

6. Using Path Types

pathTypeSemantics
ExactMatch URL path exactly
PrefixMatch element-wise prefix (/foo matches /foo/bar)
ImplementationSpecificController-defined (e.g., NGINX regex)

7. Configuring TLS Termination

spec:
  tls:
  - hosts: [www.example.com, api.example.com]
    secretName: example-tls
Secret TypeKeys
kubernetes.io/tlstls.crt, tls.key
Auto-issuedcert-manager + Issuer / ClusterIssuer

8. Using Ingress Annotations

NGINX AnnotationEffect
rewrite-targetRewrite path for backend
ssl-redirect: "true"Force HTTPS
proxy-read-timeoutBackend read timeout (s)
limit-rpsRate limit per client
auth-url / auth-signinExternal auth
configuration-snippetInline NGINX directives

9. Setting Ingress Class

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata: { name: nginx }
spec:
  controller: k8s.io/ingress-nginx
FieldDetail
spec.ingressClassNamePer-Ingress reference
Defaultingressclass.kubernetes.io/is-default-class: "true"

10. Installing Ingress Controllers

ControllerInstall
ingress-nginxhelm upgrade --install ingress-nginx ingress-nginx/ingress-nginx
Traefikhelm install traefik traefik/traefik
HAProxyhelm install haproxy haproxytech/kubernetes-ingress
AWS ALB ControllerProvision ALBs from Ingress objects
Cloud-native (GKE/EKS)Managed Ingress controllers

11. Troubleshooting Ingress

SymptomCheck
404 default backendHost header / path mismatch
No ADDRESSController not running / no IngressClass
502/504Backend pod down or readiness failing
TLS errorsWrong secretName / mismatched SNI
Connection refusedtargetPort mismatch