Ingress Basics
This section introduces the Ingress object: how to route external HTTP traffic to in-cluster Services by host and path, with TLS.
Search across all documentation pages
This section introduces the Ingress object: how to route external HTTP traffic to in-cluster Services by host and path, with TLS.
Remember that an Ingress is just declarative configuration. A running ingress controller must be installed for any of these examples to take effect.
kubectl access.Quick install of a common controller with Helm 3:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespaceRoute all traffic for a hostname to one backend Service.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web
spec:
ingressClassName: nginx
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80ingressClassName binds the object to a specific installed controller.pathType: Prefix matches / and everything under it.backend names a Service and its port, not a pod.Send different URL paths to different Services behind one host.
- 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: 80/api goes to the api Service, everything else to web.Serve multiple hostnames from one Ingress and one controller.
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: web, port: { number: 80 } } }
- host: admin.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: admin, port: { number: 80 } } }host block is an independent virtual host.Host header.Match a single URL exactly, not its subtree.
- path: /healthz
pathType: Exact
backend:
service:
name: web
port:
number: 80Exact matches only /healthz, not /healthz/extra.Prefix is the more common choice for app routes.Catch requests that match no rule.
spec:
ingressClassName: nginx
defaultBackend:
service:
name: fallback
port:
number: 80defaultBackend.Terminate HTTPS at the controller using a Secret.
spec:
ingressClassName: nginx
tls:
- hosts:
- app.example.com
secretName: app-tls
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: web, port: { number: 80 } } }tls block references a kubernetes.io/tls Secret holding the cert and key.hosts list should match the SNI names in the certificate.Confirm which controller owns your objects.
kubectl get ingressclassIngressClass (for example nginx).spec.ingressClassName must match one of these.Enable features not covered by the core spec via annotations.
metadata:
name: web
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "10m"ssl-redirect forces HTTP to HTTPS.proxy-body-size raises the upload limit.Strip a prefix before forwarding to the backend.
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- host: app.example.com
http:
paths:
- path: /api(/|$)(.*)
pathType: ImplementationSpecific
backend: { service: { name: api, port: { number: 8080 } } }rewrite-target rewrites the forwarded path using capture groups.pathType: ImplementationSpecific allows regex in ingress-nginx./ instead of /api.Serve several hostnames over HTTPS using one certificate with Subject Alternative Names.
spec:
ingressClassName: nginx
tls:
- hosts:
- app.example.com
- admin.example.com
secretName: multi-tls
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: web, port: { number: 80 } } }
- host: admin.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: admin, port: { number: 80 } } }host still needs its own rule block for routing.Test without changing DNS by sending an explicit Host header.
kubectl get ingress web
curl -H "Host: app.example.com" http://<controller-external-ip>/kubectl get ingress shows the assigned address once the controller reconciles.Host header makes the controller match your rule.-k to skip cert verification when testing HTTPS against an IP.Stack versions: This page was written for Kubernetes 1.36.2, Docker Engine 29.6.1 (BuildKit default), containerd (CRI runtime on nodes), Helm 3, Compose v2, Argo CD (latest - verify at build), and Gateway API (GA - verify controller support at build).
Reviewed by Chris St. John·Last updated Jul 16, 2026