Ingress Quiz
Quiz
Ingress Resource:
- Kubernetes API object (YAML manifest)
- Defines routing rules (host-based, path-based)
- Declarative specification of desired routing
- Example: ‘api.example.com โ api-service’
Ingress Controller:
- Implementation/software that reads Ingress Resources
- Runs as pods in the cluster (nginx, AWS ALB, Traefik, etc.)
- Configures actual reverse proxy/load balancer
- Watches for Ingress Resources and implements their rules
How they work together:
- You create an Ingress Resource (routing rules)
- Ingress Controller watches for new/updated Ingress Resources
- Controller configures its reverse proxy based on the rules
- Controller routes external traffic to appropriate Services
Key Point: Ingress Resource is the ‘what’ (rules), Controller is the ‘how’ (implementation).
Did you get it right?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api
port:
number: 80pathType: Prefix and path: /api, the Ingress matches any path starting with ‘/api’, including /api/v1, /api/users, etc. This is a prefix match, not an exact match.pathType: Prefix and path: /api, the Ingress matches any path starting with ‘/api’, including /api/v1, /api/users, etc. This is a prefix match, not an exact match.Exact (exact path match), Prefix (matches path prefix), and ImplementationSpecific (controller-dependent behavior, e.g., nginx regex support).Exact (exact path match), Prefix (matches path prefix), and ImplementationSpecific (controller-dependent behavior, e.g., nginx regex support).Host-Based Routing:
- Routes based on the hostname (domain) in the request
- Different domains โ different services
- Example:
- api.example.com โ api-service
- web.example.com โ web-service
- admin.example.com โ admin-service
- Use case: Multiple applications on different subdomains
Path-Based Routing:
- Routes based on the URL path
- Same domain, different paths โ different services
- Example:
- example.com/api โ api-service
- example.com/web โ web-service
- example.com/admin โ admin-service
- Use case: Microservices architecture on single domain
Both can be combined in a single Ingress โ e.g., route by host first, then by path within that host.
Did you get it right?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tls-ingress
spec:
ingressClassName: nginx
_____:
- hosts:
- api.example.com
secretName: api-tls
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api
port:
number: 80tls: section in the Ingress spec defines TLS configuration, including which hosts to secure and which Secret contains the certificate and key.tls: section in the Ingress spec defines TLS configuration, including which hosts to secure and which Secret contains the certificate and key.kubernetes.io/tls and contain two data fields: tls.crt (the certificate) and tls.key (the private key), both base64-encoded.kubernetes.io/tls and contain two data fields: tls.crt (the certificate) and tls.key (the private key), both base64-encoded.IngressClass:
- Kubernetes resource that identifies which Ingress Controller should handle an Ingress
- Metadata layer between Ingress Resources and Controllers
- Allows multiple Ingress Controllers to coexist in the same cluster
Relationship:
Ingress Resource
โ (references via ingressClassName)
IngressClass
โ (identifies via controller field)
Ingress Controller (nginx pod)
โ (watches and implements)
Routing configurationWhy Important:
- Multi-controller support: Run nginx AND AWS ALB in same cluster
- Selective processing: Each Ingress specifies which controller handles it
- Default behavior: Mark one IngressClass as default for Ingress without ingressClassName
Example:
- IngressClass ’nginx’ โ controller: k8s.io/ingress-nginx
- IngressClass ‘aws-alb’ โ controller: ingress.k8s.aws/alb
- Ingress with ingressClassName: nginx โ nginx controller handles it
Did you get it right?
defaultBackend handles requests that don’t match any defined rules, typically serving custom 404 pages or error responses. It’s optional and provides a catch-all for unmatched traffic.defaultBackend handles requests that don’t match any defined rules, typically serving custom 404 pages or error responses. It’s optional and provides a catch-all for unmatched traffic.apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: canary-ingress
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "10"
spec:
ingressClassName: nginx
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-v2
port:
number: 80canary: true and canary-weight: 10, this Ingress receives 10% of traffic to api.example.com. The main (non-canary) Ingress for the same host receives the remaining 90%.canary: true and canary-weight: 10, this Ingress receives 10% of traffic to api.example.com. The main (non-canary) Ingress for the same host receives the remaining 90%.ingressclass.kubernetes.io/is-default-class: "true" marks an IngressClass as default. Ingress Resources without an ingressClassName will automatically use this default class.ingressclass.kubernetes.io/is-default-class: "true" marks an IngressClass as default. Ingress Resources without an ingressClassName will automatically use this default class.nginx Ingress Controller:
- Pros: Lightweight, flexible, works anywhere, large community, regex routing
- Cons: Not cloud-native, manual management, requires an external LB
- Use when: Cloud-agnostic deployment, on-premises, need flexibility
AWS ALB Ingress Controller:
- Pros: Native AWS integration, auto-scaling, security groups
- Cons: AWS-specific, requires IAM setup
- Use when: AWS-only deployment, want native AWS features, cost optimization
Istio Ingress Gateway:
- Pros: Advanced traffic management, mTLS, circuit breaking, unified with service mesh
- Cons: Complex setup, higher resource overhead, steep learning curve
- Use when: Need advanced features, already using Istio, require mTLS
Decision Matrix:
- Cloud-agnostic or hybrid โ nginx
- EKS + want AWS-native integrations (WAF, ACM, Shield) โ AWS ALB
- Need mTLS, traffic shifting, mesh policies โ Istio
Did you get it right?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: multi-path
spec:
rules:
- host: example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /admin
pathType: Exact
backend:
service:
name: admin-service
port:
number: 80pathType: Exact on the ‘/admin’ path, only exactly ‘http://example.com/admin' matches. Requests like ‘/admin/users’ would not match because Exact requires an exact path match, not a prefix.pathType: Exact on the ‘/admin’ path, only exactly ‘http://example.com/admin' matches. Requests like ‘/admin/users’ would not match because Exact requires an exact path match, not a prefix.What command creates a TLS Secret named ‘my-tls’ from certificate files tls.crt and tls.key for use with Ingress?
kubectl create secret tls <name> --cert=<cert-file> --key=<key-file>. This creates a Secret with type ‘kubernetes.io/tls’ containing the properly named keys ’tls.crt’ and ’tls.key’.kubectl create secret tls <name> --cert=<cert-file> --key=<key-file>. This creates a Secret with type ‘kubernetes.io/tls’ containing the properly named keys ’tls.crt’ and ’tls.key’.apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: microservices
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /users
pathType: Prefix
backend:
service:
name: users-service
port:
number: 80
- path: _____
pathType: Prefix
backend:
service:
name: _____
port:
number: 80Ingress Resource:
- Defines routing rules (declarative config)
- Specifies hosts, paths, and backend services
- Role: What to route
IngressClass:
- Links Ingress Resources to specific Controllers
- Allows multiple controllers in one cluster
- Role: Which controller handles this Ingress
Ingress Controller:
- Implements the actual routing (runs nginx/ALB/Istio/etc.)
- Watches Ingress resources and configures load balancer
- Role: How to route (the implementation)
TLS Secret:
- Stores certificates and private keys
- Referenced by Ingress for HTTPS termination
- Role: Enables secure connections
Backend Service:
- Receives routed traffic from Ingress
- ClusterIP service that forwards to Pods
- Role: Final destination for requests
[CONTROL PLANE]
Ingress Resource
โ (ingressClassName)
IngressClass
โ (controller field)
Ingress Controller (control loop)
โ
Generates proxy config (NGINX / Envoy)[DATA PLANE]
External Client
โ
LoadBalancer / NodePort Service
โ
Ingress Controller Pod (NGINX data plane)
โ (TLS termination + routing)
ClusterIP Service
โ
PodDid you get it right?
kubectl get ingress (or kubectl get ing) shows Ingress resources including their assigned ADDRESS/external IP. Use -w flag to watch for IP assignment: kubectl get ingress -w.kubectl get ingress (or kubectl get ing) shows Ingress resources including their assigned ADDRESS/external IP. Use -w flag to watch for IP assignment: kubectl get ingress -w.nginx.ingress.kubernetes.io/force-ssl-redirect: "true" forces all HTTP requests to redirect to HTTPS, a common security practice.nginx.ingress.kubernetes.io/force-ssl-redirect: "true" forces all HTTP requests to redirect to HTTPS, a common security practice.Mental Model:
1. Check DNS โ Can the client even reach the Ingress?
2. Check Ingress Controller โ Is the implementation running?
3. Verify IngressClass โ Is the right controller selected?
4. Verify Ingress Status โ Are the rules configured correctly?
5. Test Routing (curl) โ Do the Ingress rules route correctly?
6. Check TLS โ Are certificates valid and referenced?
7. Verify Backend Service โ Does the destination exist?
8. Check Pods โ Are there healthy backends?Ingress Troubleshooting Checklist:
1. Check DNS:
nslookup api.example.com
# Does domain resolve to Ingress IP?2. Check Ingress Controller:
kubectl get pods -n ingress-nginx
# Is controller running? Check logs for errors
kubectl logs -n ingress-nginx <controller-pod>3. Verify IngressClass:
kubectl get ingressclass
# Does the IngressClass exist?
kubectl get ingress <name> -o yaml | grep ingressClassName
# Does Ingress reference the correct IngressClass?4. Verify Ingress Status:
kubectl describe ingress <name>
# Check: Address assigned? Rules correct? Backends listed?5. Test Routing:
curl http://api.example.com
# Test host-based routing
curl http://api.example.com/api
# Test path-based routing6. Check TLS (if using HTTPS):
kubectl get secret <tls-secret-name>
# Does the Secret exist?
kubectl get ingress <name> -o yaml | grep -A2 tls
# Is it referenced correctly in the Ingress spec?7. Verify Backend Service:
kubectl get svc <backend-service>
kubectl get endpoints <backend-service>
# Service exists? Has endpoints (pods)?8. Check Pods:
kubectl get pods -l app=<backend>
# Pods running? Ready?Common Issues:
- No Ingress Controller installed
- IngressClass doesn’t exist or wrong ingressClassName
- Backend Service doesn’t exist
- No pods matching Service selector
- DNS not pointing to Ingress IP
- TLS Secret missing or incorrectly referenced
Did you get it right?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
spec:
ingressClassName: nginx
defaultBackend:
service:
name: default-404
port:
number: 80
rules:
- host: example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80