Summary - Ingress
- Docker & Kubernetes course
- Advanced
- Lesson 6/70
- 5 min
Combine host, path and TLS to write an Ingress.
Summary: Ingress
In this group:
- An Ingress is a set of rules routing HTTP(S) traffic to Services by host and path; it provides a single entry point.
- An Ingress controller (ingress-nginx, Traefik) applies the rules;
ingressClassNamechooses which one processes it. - YAML:
networking.k8s.io/v1,rules[].host,paths[].path/pathType/backend.service. PrefixandExactmatching; the longest prefix wins;defaultBackendis for unmatched requests.- TLS:
spec.tls+ akubernetes.io/tlsSecret; cert-manager gets certificates automatically.
kubectl get ing
curl -H "Host: magaza.example.com" http://$(minikube ip)/Practice A complete Ingress
Write an Ingress YAML: name magaza; ingressClassName: nginx; under tls, host magaza.example.com and secretName: magaza-tls; for host magaza.example.com, the / path (Prefix) goes to port 80 of the web service.
Starter code
# buraya yazSample solution
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: magaza
spec:
ingressClassName: nginx
tls:
- hosts:
- magaza.example.com
secretName: magaza-tls
rules:
- host: magaza.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80Expected output
ingress.networking.k8s.io/magaza created $ curl -sI https://magaza.example.com | head -1 HTTP/2 200
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 If the Ingress's ADDRESS column stays empty, what is checked first?
- The namespace quota
- The etcd backup
- Whether a controller is installed and ingressClassName matches Correct answer
- The pods' image
Explanation: Check kubectl get ingressclass and the controller pods.
2 Use prefix matching.
- path: /api
pathType: ____
- path: /api
pathType: Prefix
Explanation: Prefix is prefix matching by path segments.
3 Match.
| Term | Meaning |
|---|---|
Ingress |
Rule |
controller |
Enforcer |
tls |
HTTPS |
host |
Domain name |