Services & the Gateway API
ClusterIP, EndpointSlices, DNS, NodePorts, Gateways, and HTTPRoutes
Every pod gets its own IP, and any pod can reach any other by IP, across nodes, without NAT. That's the Kubernetes network model; the CNI plugin (kindnet here) implements it. But pod IPs change with every replacement, so nothing should use them directly.
Services
kubectl -n shop get svc,endpointslices
NAME TYPE CLUSTER-IP PORT(S)
service/redis ClusterIP None 6379/TCP # headless
service/shop-nginx NodePort 10.96.48.169 80:30080/TCP # the Gateway's NGINX
service/web ClusterIP 10.96.95.206 8000/TCP
NAME PORTS ENDPOINTS
endpointslice.discovery.k8s.io/web-c2lh9 8000 10.244.3.40,10.244.1.31,10.244.3.41
endpointslice.discovery.k8s.io/redis-bt5nr 6379 10.244.1.33| Type | What you get |
|---|---|
| ClusterIP | A virtual IP inside the cluster; kube-proxy's rules on every node spread connections over the ready endpoints |
Headless (clusterIP: None) | No virtual IP; DNS returns the pod IPs. StatefulSets use it for stable names like redis-0.redis |
| NodePort | ClusterIP, plus a port (30000-32767) open on every node |
| LoadBalancer | NodePort, plus a cloud load balancer in front (in kind: nothing, unless you add cloud-provider-kind or MetalLB) |
EndpointSlices are the live list of ready pod addresses for a Service. Only ready pods are listed: that's how readiness probes and node failures take pods out of rotation.
DNS
CoreDNS gives every Service a name: web.shop.svc.cluster.local, or just
web from inside the shop namespace and web.shop from elsewhere. The
app reaches Redis as redis, and the labs' toolbox reaches the app as
web.shop:8000.
Getting traffic in: the Gateway API
The Gateway API splits the old Ingress object into roles:
kubectl -n shop get gateway,httproute
NAME CLASS ADDRESS PROGRAMMED
gateway.gateway.networking.k8s.io/shop nginx 10.96.48.169 TrueFor each Gateway, NGINX Gateway Fabric's control plane (namespace
nginx-gateway) provisions an NGINX Deployment and Service in the
Gateway's namespace (shop-nginx) and writes its configuration from the
routes. The bootstrap made that Service a NodePort (30080), which kind maps
to localhost:8180.
HTTPRoutes can also split traffic by weight (canary releases), match headers, rewrite paths, and route across namespaces where the Gateway allows it. TLS is a listener on the Gateway with a Secret holding the certificate (usually from cert-manager).
NGINX doesn't proxy to the Service's ClusterIP: the Gateway reads the EndpointSlices and puts pod IPs straight into NGINX's upstreams, then reloads NGINX on every change (61 reloads during the rollout labs). The rollouts lesson shows what that costs. Most ingress implementations work this way, so readiness and termination timing decide whether clients see errors.
Lab
kubectl -n labs exec deploy/toolbox -- nslookup web.shop.svc.cluster.local, then the same forredis.shop.svc.cluster.local. Why do the answers differ in kind? (Busybox'snslookupdoesn't apply search domains, so short names likeweb.shopfail with it; curl resolves them fine.)- Add a second HTTPRoute rule sending
/v2to a second Deployment, with a 90/10 weight split on/. - Scale web to 0 and request through the Gateway. What status code, from whom?