Sub topic 1
Where you start: Ingress and NGINX annotations
Prerequisites
This chapter assumes you can do the following:
- Run
kubectland read YAML manifests. - Explain what a Pod, a Service and a Namespace are.
- Describe basic HTTP routing: hostnames, paths and TLS termination.
You do not need any Gateway API knowledge yet. This chapter describes the current state that later chapters migrate away from.
What an Ingress does
An Ingress is a Kubernetes resource that describes how HTTP and HTTPS traffic from outside the cluster reaches Services inside it. The Ingress object holds only rules. An Ingress controller is a separate program that reads those rules and configures a real proxy. Ingress NGINX is one such controller, and it configures NGINX.
The ingressClassName field selects which controller handles the object. Without a running controller, an Ingress does nothing.
The starting manifest
This Ingress is the example the rest of the tutorial translates. It combines TLS, host and path routing, and one NGINX-specific annotation.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app
namespace: shop
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
ingressClassName: nginx
tls:
- hosts:
- app.example.com
secretName: app-example-com-tls
rules:
- host: app.example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api
port:
number: 8080
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80Each part has a job:
tlsterminates HTTPS forapp.example.comusing the certificate in the Secretapp-example-com-tls. The Secret must be in the same namespace as the Ingress.rulesmatch the host, then the path. The longest matching prefix wins, so/apigoes to theapiService and everything else goes toweb.- The
ssl-redirectannotation tells NGINX to answer plain HTTP with a redirect to HTTPS.
Why annotations matter for migration
The Ingress API covers only host, path and TLS. Everything else, such as redirects, rewrites, canary weights, timeouts and body size limits, has no field. Ingress NGINX fills the gap with annotations, which are free-form key-value pairs under the nginx.ingress.kubernetes.io/ prefix.
This has two consequences:
- Annotations are not validated by the Kubernetes API server. A typo is silently ignored.
- Annotations are specific to one controller. Another controller will not understand them.
Your first migration task is therefore an inventory. List every annotation in use, because each one is behavior that you must reproduce or consciously drop.
kubectl get ingress -A -o json \
| jq -r '.items[] | .metadata.namespace + "/" + .metadata.name + " " + ((.metadata.annotations // {}) | keys | join(","))'The command prints one line per Ingress with its namespace, name and annotation keys. Annotations such as kubectl.kubernetes.io/last-applied-configuration appear too, and you can ignore them.
Common errors
- Missing
ingressClassName. The Ingress is ignored when no default class exists. - Secret in the wrong namespace. TLS fails because the controller cannot find the certificate.
- Misspelled annotation. The setting has no effect and no error appears.
Exercise
Why must you inventory annotations before migrating, rather than only copying the rules section?
Show answer
Behavior such as redirects, rewrites and canary splits lives in controller-specific annotations, not in the Ingress fields. The Gateway API will not read them, so any annotation you skip is behavior you silently lose.