NetworkingLesson 2 of 8
  1. The pod network model, not reconciled
  2. Services, not reconciled
    1. A stable name and a virtual IP
    2. Types
    3. Headless Services
    4. Ports
    5. Traffic policies
    6. trafficDistribution
    7. Services without selectors
    8. No endpoints
  3. EndpointSlices and kube-proxy, not reconciled
  4. Following a packet through the node, not reconciled
  5. Cluster DNS with CoreDNS, not reconciled
  6. Gateway API and the frozen Ingress API, not reconciled
  7. NetworkPolicies, not reconciled
  8. gRPC, service mesh and mTLS, not reconciled

Services

A Service gives a changing set of pods one stable name and virtual IP. Choose a Service type, wire ports correctly, decide where traffic may go and what source address it keeps, and recognise a Service with no endpoints.

  • 28 min
  • 5 objectives
  • 8 scenes
  • Includes an On AWS layer

Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.

Reconcile, in 8 scenes

A stable name and a virtual IP

Pods are disposable: a replacement pod gets a different name and IP, and a rollout replaces all of them. Clients need an address that outlives any pod. A ServiceAn API object that selects a set of pods by label and gives them one stable virtual IP, DNS name and set of ports. provides one.

Three things happen when you create a Service with a selector:

  1. The API server allocates a cluster IPA virtual address from the Service range. No interface owns it; service proxies on every node recognise it and redirect connections to it. and cluster DNS starts answering for <service>.<namespace>.svc.cluster.local.
  2. The EndpointSlice controller finds the pods that match the selector in the Service’s namespace and writes their addresses, ports and readiness into EndpointSlice objects. It keeps them current as pods come, go, and pass or fail readiness. EndpointSlice is the primary API; the v1 Endpoints API has been deprecated since Kubernetes 1.33.
  3. A service proxy on every node, kube-proxy by default, watches Services and EndpointSlices and programs kernel rules that rewrite the destination of any connection to clusterIP:port to a ready endpoint.

Why a virtual IP rather than DNS that lists the pods? Many clients resolve a name once and keep the answer far past its TTL, so a DNS answer that changes with every rollout sends them to pods that no longer exist. A cluster IP never changes for the life of the Service; the churn moves into kernel rules, which the proxies update within seconds of a pod change.

kube-proxy programs those rules and stays out of the data path. On Linux it uses iptables by default; nftables mode, GA since 1.33, outperforms both iptables and IPVS, and IPVS mode has been deprecated since 1.35. The next lesson follows a packet through the rules. One consequence matters here: the redirect changes only the destination, so a pod reached through a cluster IP sees the calling pod’s own address.

One name in front of three pods
kubectl get service web
NAME   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
web    ClusterIP   10.98.108.133   <none>        80/TCP    15s
kubectl get endpointslices -l kubernetes.io/service-name=web
NAME        ADDRESSTYPE   PORTS   ENDPOINTS                          AGE
web-q79zt   IPv4          80      10.244.3.3,10.244.2.2,10.244.1.3   15s
kubectl exec client -- curl -s web | grep Hostname
Hostname: web-6664b96dd5-dq87d
kubectl exec client -- curl -s web | grep Hostname
Hostname: web-6664b96dd5-nshlv
kubectl exec client -- curl -s web | grep Hostname
Hostname: web-6664b96dd5-pggpj

ExplainerService routing

Podclient10.244.1.2

Serviceweb

clusterIP
10.102.158.59
port
80, targetPort 8080

The value pods need on their app label to be selected.

EndpointSliceweb-jlc26

  • 10.244.3.2:8080web-aready trueserving trueterminating false
  • 10.244.3.3:8080web-bready trueserving trueterminating false
  • 10.244.2.3:8080web-cready trueserving trueterminating false

kube-proxy3 ready endpoints, each taking 1/3 of new connections.

  • web-a10.244.3.2

    Readykx-worker3

  • web-b10.244.3.3

    Readykx-worker3

  • web-c10.244.2.3

    Readykx-worker2

$ kubectl exec client -- curl -s web
Send a request to see the reply.

The selector app=web matches 3 pods; 3 are ready. Send a request to see where kube-proxy routes it.

Change a pod's readiness or labels, or the Service's selector, and send a request. Only ready pods the selector matches are in the EndpointSlice, and kube-proxy picks among them.

The proxy picks a backend per connection, not per request. A client that holds one HTTP keep-alive or gRPC connection open sends every request to the same pod, and replicas added later get nothing until clients reconnect. Spread long-lived connections in the client, or put an L7 proxy in front. If you want the same client to keep reaching the same pod across connections, set sessionAffinity: ClientIP; the default stickiness timeout is 10800 seconds.

Press Play to send requests from client to web one connection at a time. Each lands on the pod kube-proxy’s rules picked for that connection, and the stage counts the answers per pod.

kind cluster kx

Starting

Starting the cluster…

$

    Six requests from the client pod to service/web, and the rules that spread them. Press Play: the scene runs its commands on this page's cluster, and the dock's terminal shows each one.

    Types

    spec.type decides who can reach the Service. The first three types build on each other; ExternalName stands apart.

    • ClusterIP, the default, is reachable only from inside the cluster.
    • NodePort adds a port on every node. Traffic to any node’s address on that port reaches the Service, even if no backend runs on that node. The API server picks the port from --service-node-port-range, 30000-32767 by default. Automatic allocation prefers the upper band (30086-32767 with the default range), so if you choose a port yourself, choose it from the static band, 30000-30085, to avoid collisions.
    • LoadBalancer adds an external load balancer that sends traffic to the node ports. Kubernetes does not build it: a controller for your platform watches the Service, provisions a load balancer, and writes its address into status.loadBalancer, which kubectl shows as EXTERNAL-IP. With no controller, as on kx, the address stays <pending> forever. loadBalancerClass picks which controller handles a Service and cannot change afterwards. Implementations that send traffic straight to pod IPs can set allocateLoadBalancerNodePorts: false to skip node ports. loadBalancerIP has been deprecated since 1.24.
    • ExternalName maps the Service name to another DNS name with a CNAME record. There is no cluster IP, no proxying and no port mapping. Clients connect with the Service’s name, so HTTP servers see a Host header they may not recognise, and TLS servers cannot present a certificate for it. A value that looks like an IPv4 address is treated as a DNS name and never resolves.
    Four more Services for the same pods
    kubectl expose deployment web --name=web-np --type=NodePort --port=80 --target-port=http
    service/web-np exposed
    kubectl expose deployment web --name=web-lb --type=LoadBalancer --port=80 --target-port=http
    service/web-lb exposed
    kubectl expose deployment web --name=web-headless --cluster-ip=None --port=80 --target-port=http
    service/web-headless exposed
    kubectl create service externalname payments-api --external-name=api.example.com
    service/payments-api created
    kubectl get services
    NAME           TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)        AGE
    kubernetes     ClusterIP      10.96.0.1        <none>            443/TCP        45s
    payments-api   ExternalName   <none>           api.example.com   <none>         0s
    web            ClusterIP      10.98.108.133    <none>            80/TCP         15s
    web-headless   ClusterIP      None             <none>            80/TCP         0s
    web-lb         LoadBalancer   10.102.72.24     <pending>         80:32524/TCP   0s
    web-np         NodePort       10.108.234.254   <none>            80:32651/TCP   0s
    web-v2         ClusterIP      10.105.30.240    <none>            80/TCP         15s
    kubectl exec client -- curl -s http://172.18.0.3:32651 | grep Hostname
    Hostname: web-6664b96dd5-dq87d

    web-lb got a cluster IP and a node port, but no external address: nothing on kx provisions load balancers.

    Headless Services

    Set clusterIP: None and the Service gets no virtual IP. kube-proxy ignores it, and cluster DNS answers its name with one A record per ready pod instead of one cluster IP. Clients pick a pod themselves.

    That suits two kinds of client. StatefulSets need a headless Service for stable per-pod names such as db-0.db. Clients that balance load themselves, such as gRPC with client-side balancing or databases that discover their peers, need the full list of addresses rather than one virtual one. Created again on the lesson’s cluster and looked up from client, the web-headless and payments-api Services from above answer like this:

    Headless and ExternalName answer in DNS
    kubectl expose deployment web --name=web-headless --cluster-ip=None --port=80 --target-port=http
    service/web-headless exposed
    kubectl create service externalname payments-api --external-name=api.example.com
    service/payments-api created
    kubectl exec client -- nslookup web-headless
    Server:		10.96.0.10
    Address:	10.96.0.10#53
    
    Name:	web-headless.default.svc.cluster.local
    Address: 10.244.3.3
    Name:	web-headless.default.svc.cluster.local
    Address: 10.244.2.2
    Name:	web-headless.default.svc.cluster.local
    Address: 10.244.1.3
    kubectl exec client -- nslookup payments-api
    Server:		10.96.0.10
    Address:	10.96.0.10#53
    
    payments-api.default.svc.cluster.local	canonical name = api.example.com.
    Name:	api.example.com
    Address: 203.0.113.10

    Ports

    Each entry under spec.ports maps a Service port to a pod port:

    • port is what clients connect to on the cluster IP.
    • targetPort is where the pods listen. It defaults to the value of port, and it can be a number or the name of a container port.
    • nodePort is the node port, for NodePort and LoadBalancer Services.
    • protocol is TCP by default; UDP and SCTP also work.

    A named targetPort is resolved per pod, so a rollout can move the container to another port number without touching the Service, and pods with different numbers under the same name can sit behind one Service. A single-port Service may leave its port unnamed. Once a Service has two or more ports, every port needs a unique name of lowercase letters, digits and -, starting and ending with a letter or digit.

    apiVersion: v1
    kind: Service
    metadata:
      name: web
    spec:
      selector:
        app: web
      ports:
        - name: http
          port: 80
          targetPort: http
        - name: metrics
          port: 9090
          targetPort: 9090

    Traffic policies

    Two fields restrict which endpoints a node may use, and with that, how many hops a packet takes and what source address the pod sees.

    externalTrafficPolicy applies to traffic arriving from outside through a node port or load balancer.

    • Cluster, the default, lets every node forward to any ready endpoint in the cluster. A packet that lands on a node without a local pod takes a second hop to another node, and that node rewrites the source to its own address so the reply comes back through it. The pod sees a node address, not the client’s. Every node whose kube-proxy is healthy is a target; Kubernetes recommends that load balancers health-check kube-proxy at <node IP>:10256/healthz, which fails while the node is being deleted so that connections drain.
    • Local lets a node forward only to endpoints on itself. There is no second hop and no source NAT, so the pod sees the real client address. A node with no local endpoint does not forward traffic for the Service at all; its health check fails, so the load balancer stops sending it any. The cost is balance: the load balancer spreads by node, so a node with one pod gets the same share as a node with five.

    internalTrafficPolicy, stable since 1.26, applies to traffic from pods to the cluster IP. Local restricts it to endpoints on the client’s own node and drops it when there are none. It suits node agents run by a DaemonSet, such as a node-local cache, where the nearest copy is the only one you want.

    A rolling update can leave a Local node with only terminating endpoints. Since 1.28, kube-proxy then sends traffic to those terminating endpoints instead of dropping it, so connections drain while the load balancer notices the failing health check.

    Pod-to-cluster-IP traffic keeps the client’s address. Source NAT happens for node port and load balancer traffic with externalTrafficPolicy: Cluster, for hairpin traffic, when a pod reaches itself through its own Service, and for traffic leaving the cluster network.

    Send one request from the dock, kubectl exec client -- curl -s web, then walk it through client’s node: the cluster IP it was sent to, the rule that drew an endpoint, the DNAT, the route to the pod, and the conntrack entry that keeps the source address the client’s own.

    ExplainerA packet through the node

    client to Service web3 ready endpoints; send a request to draw one

    kubectl exec client -- curl -s -m 2 -o /dev/null -w '%{http_code}\n' http://web

    Resolve webLeave the podMatch the cluster IPDraw an endpointRewrite the destinationRoute on this nodeInto the endpoint's podThe reply finds its way back

    kubectl exec client -- cat /etc/resolv.confdocker exec kx-worker3 ip routedocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 ip routedocker exec kx-worker3 ip routedocker exec kx-worker3 conntrack -L -p tcp -d 10.98.108.133

    search default.svc.cluster.local svc.cluster.local cluster.local
    nameserver 10.96.0.10
    options ndots:5
    

    curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.The packet leaves eth0 inside the pod and comes out of veth249012b5 in kx-worker3's network namespace, addressed to 10.98.108.133:80. No interface anywhere holds that address.PREROUTING jumps to KUBE-SERVICES, where kube-proxy wrote one rule per Service port: 10.98.108.133 port 80 goes to KUBE-SVC-LOLE4ISW44XBNF3G.KUBE-SVC-LOLE4ISW44XBNF3G holds one rule per ready endpoint, 3 of them. Each rule but the last matches with probability 1/(remaining), so every endpoint is equally likely. Send a request: kube-proxy's draw happens once per connection.The winning rule jumps to the endpoint's KUBE-SEP chain, whose DNAT rewrites the destination to the pod's IP and port. Send a request: kube-proxy's draw happens once per connection.The rewritten packet is routed by its new destination. Send a request: kube-proxy's draw happens once per connection.The endpoint's node sends it down the pod's veth. Send a request: kube-proxy's draw happens once per connection.conntrack keeps one entry per connection, with the original destination and the reply's source. Send a request: kube-proxy's draw happens once per connection.

    Step 1 of 8: Resolve web. curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.

    1. Resolve web

      kubectl exec client -- cat /etc/resolv.conf

      search default.svc.cluster.local svc.cluster.local cluster.local
      nameserver 10.96.0.10
      options ndots:5
      

      curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.

    2. Leave the pod

      docker exec kx-worker3 ip route

      default via 172.18.0.1 dev eth0 
      10.244.0.0/24 via 172.18.0.2 dev eth0 
      10.244.1.0/24 via 172.18.0.3 dev eth0 
      10.244.2.0/24 via 172.18.0.4 dev eth0 
      10.244.3.2 dev veth249012b5 scope host 
      10.244.3.3 dev vethf2213491 scope host 
      172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.5 
      

      The packet leaves eth0 inside the pod and comes out of veth249012b5 in kx-worker3's network namespace, addressed to 10.98.108.133:80. No interface anywhere holds that address.

    3. Match the cluster IP

      docker exec kx-worker3 iptables-save -t nat

      -A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
      -A KUBE-SERVICES -d 10.98.108.133/32 -p tcp -m comment --comment "default/web cluster IP" -m tcp --dport 80 -j KUBE-SVC-LOLE4ISW44XBNF3G
      

      PREROUTING jumps to KUBE-SERVICES, where kube-proxy wrote one rule per Service port: 10.98.108.133 port 80 goes to KUBE-SVC-LOLE4ISW44XBNF3G.

    4. Draw an endpoint

      docker exec kx-worker3 iptables-save -t nat

      -A KUBE-SVC-LOLE4ISW44XBNF3G ! -s 10.244.0.0/16 -d 10.98.108.133/32 -p tcp -m comment --comment "default/web cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
      -A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web -> 10.244.1.3:80" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-MHDQ23KUGG7EGFMW
      -A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web -> 10.244.2.2:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-QHWUG6SOC7OJ2BZK
      -A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web -> 10.244.3.3:80" -j KUBE-SEP-74RNEJOQ4CH6BCPU
      

      KUBE-SVC-LOLE4ISW44XBNF3G holds one rule per ready endpoint, 3 of them. Each rule but the last matches with probability 1/(remaining), so every endpoint is equally likely. Send a request: kube-proxy's draw happens once per connection.

    5. Rewrite the destination

      docker exec kx-worker3 iptables-save -t nat

      No lines match.

      The winning rule jumps to the endpoint's KUBE-SEP chain, whose DNAT rewrites the destination to the pod's IP and port. Send a request: kube-proxy's draw happens once per connection.

    6. Route on this node

      docker exec kx-worker3 ip route

      default via 172.18.0.1 dev eth0 
      10.244.0.0/24 via 172.18.0.2 dev eth0 
      10.244.1.0/24 via 172.18.0.3 dev eth0 
      10.244.2.0/24 via 172.18.0.4 dev eth0 
      10.244.3.2 dev veth249012b5 scope host 
      10.244.3.3 dev vethf2213491 scope host 
      172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.5 
      

      The rewritten packet is routed by its new destination. Send a request: kube-proxy's draw happens once per connection.

    7. Into the endpoint's pod

      docker exec kx-worker3 ip route

      No lines match.

      The endpoint's node sends it down the pod's veth. Send a request: kube-proxy's draw happens once per connection.

    8. The reply finds its way back

      docker exec kx-worker3 conntrack -L -p tcp -d 10.98.108.133

      No lines match.

      conntrack keeps one entry per connection, with the original destination and the reply's source. Send a request: kube-proxy's draw happens once per connection.

    Send a request from a pod to the Service, then step through what the node does with it: the cluster IP rule, kube-proxy's random draw between endpoints, the DNAT, the route to the endpoint's node and conntrack's rewrite of the reply. Each step shows the real lines from iptables-save, ip route and conntrack.

    trafficDistribution

    spec.trafficDistribution, GA since 1.33, expresses a preference rather than a rule. With PreferSameZone, the EndpointSlice controller adds zone hints to each endpoint, and kube-proxy on each node uses only endpoints in its own zone when there are any. When a zone has none, its clients fall back to the whole cluster. PreferSameNode, GA since 1.35, prefers the client’s node, then its zone, then the cluster. PreferClose is a deprecated alias for PreferSameZone. Zones come from the topology.kubernetes.io/zone label on nodes.

    apiVersion: v1
    kind: Service
    metadata:
      name: checkout
    spec:
      selector:
        app: checkout
      ports:
        - port: 80
          targetPort: 8080
      trafficDistribution: PreferSameZone

    The reason to use it is money and latency: many clouds bill cross-zone traffic, and it adds a network hop. The cost is balance. Every endpoint in a zone takes all of that zone’s traffic, however many clients the zone has, so spread replicas across zones evenly, for example with topology spread constraints. A traffic policy set to Local takes precedence over trafficDistribution, and so does the service.kubernetes.io/topology-mode: Auto annotation, which balances proportionally to allocatable CPU instead.

    Services without selectors

    A Service with no selector gets no EndpointSlices from the controller. You write them yourself, which lets a cluster name and address a backend that is not a pod: a database outside the cluster during a migration, or servers in another network.

    apiVersion: v1
    kind: Service
    metadata:
      name: ledger
    spec:
      ports:
        - name: https
          port: 443
          targetPort: 8443
    ---
    apiVersion: discovery.k8s.io/v1
    kind: EndpointSlice
    metadata:
      name: ledger-1
      labels:
        kubernetes.io/service-name: ledger
        endpointslice.kubernetes.io/managed-by: cluster-admins
    addressType: IPv4
    ports:
      - name: https
        protocol: TCP
        port: 8443
    endpoints:
      - addresses:
          - 192.0.2.40
        conditions:
          ready: true

    The kubernetes.io/service-name label links the slice to the Service, and the slice name is free. endpointslice.kubernetes.io/managed-by names whoever maintains it: pick a value of your own, such as cluster-admins, never endpointslice-controller.k8s.io, which marks the control plane’s slices. Endpoint addresses cannot be loopback or link-local addresses, or other Services’ cluster IPs. kubectl port-forward to such a Service fails, because the API server only proxies to pods.

    Write EndpointSlices, not Endpoints. The Endpoints API is deprecated, and so is the controller that mirrors hand-made Endpoints into slices.

    spec.externalIPs, which made a Service answer on arbitrary addresses that route to nodes, has been deprecated since 1.36, with removal planned for v1.43. Kubernetes never managed those addresses, so anyone allowed to create Services could claim one. Use a load balancer controller or Gateway API.

    No endpoints

    A Service with no ready endpoints still has a cluster IP and a DNS name, so clients resolve it and then fail to connect. With kube-proxy, connections are rejected at once rather than timing out.

    A Service whose selector matches nothing
    kubectl exec client -- curl -sS -m 3 web-v2
    curl: (7) Failed to connect to web-v2 port 80 after 1 ms: Couldn't connect to server
    command terminated with exit code 7
    kubectl get endpointslices -l kubernetes.io/service-name=web-v2
    NAME           ADDRESSTYPE   PORTS     ENDPOINTS   AGE
    web-v2-p8nz6   IPv4          <unset>   <unset>     15s
    kubectl get service web-v2 -o wide
    NAME     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE   SELECTOR
    web-v2   ClusterIP   10.105.30.240   <none>        80/TCP    15s   app=wbe
    kubectl get pods -l app=wbe
    No resources found in default namespace.
    kubectl get pods --show-labels
    NAME                   READY   STATUS    RESTARTS   AGE   LABELS
    client                 1/1     Running   0          15s   <none>
    web-6664b96dd5-dq87d   1/1     Running   0          15s   app=web,pod-template-hash=6664b96dd5
    web-6664b96dd5-nshlv   1/1     Running   0          15s   app=web,pod-template-hash=6664b96dd5
    web-6664b96dd5-pggpj   1/1     Running   0          15s   app=web,pod-template-hash=6664b96dd5

    Manifestweb-v2.yaml, the Service whose selector matches nothing

    Edit web-v2.yaml, then apply it to this page's cluster
    In the cluster
    • service/web-v2
    Tab indents two spaces and Shift+Tab outdents. To leave the editor, press Escape, then Tab. Control+Enter or Command+Enter to apply.
    The preview runs once this page's cluster starts.

    Make the selector match the web pods and apply it. The Service gets three ready endpoints, and curl from client reaches a pod.

    Work through the causes in order:

    1. The selector matches no pods. Run the Service’s selector as a label query with kubectl get pods -l. A typo, a label renamed in the Deployment template but not in the Service, or pods in another namespace all look like this; a Service only selects pods in its own namespace.
    2. The pods are not ready. The slice lists them with ready: false, and kubectl describe service shows no endpoints. Fix the readiness probe or what it checks.
    3. The endpoints are fine, but the port is wrong. Connections are refused at the pod. Compare targetPort with the container port.

    Build Services on your cluster

    1. kubectl --context kind-kx create deployment hello --image=traefik/whoami:v1.12 --replicas=3 --port=80
    2. kubectl --context kind-kx expose deployment hello --port=80
    3. kubectl --context kind-kx expose deployment hello --name=hello-np --type=NodePort --port=80
    4. kubectl --context kind-kx get endpointslices -l kubernetes.io/service-name=hello -o yaml
    5. kubectl --context kind-kx run curler --image=nicolaka/netshoot:v0.16 -- sleep infinity
    6. kubectl --context kind-kx wait --for=condition=Ready pod/curler --timeout=60s
    7. kubectl --context kind-kx exec curler -- curl -s http://hello
    8. kubectl --context kind-kx label pods -l app=hello app=hello-old --overwrite
    9. kubectl --context kind-kx get endpointslices -l kubernetes.io/service-name=hello
    10. kubectl --context kind-kx delete deployment hello
    11. kubectl --context kind-kx delete pods -l app=hello-old
    12. kubectl --context kind-kx delete service hello hello-np
    13. kubectl --context kind-kx delete pod curler --now

    For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. Relabelling the pods empties the Service's slice at once, and the Deployment's ReplicaSet creates three fresh app=hello pods, which then fill it again. The relabelled pods no longer belong to the ReplicaSet, so deleting the Deployment leaves them behind until you delete them by label.

    Actual state

    Check your understanding

    6 checks

    Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.

    1. Check 1 of 6

      kubectl describe service shop shows TargetPort: 80/TCP and three endpoints ending in :80, but the pods listen on 8080. What does a client inside the cluster see?

    2. Check 2 of 6

      Check runs your command on a private cluster; what it prints shows here.

    3. Check 3 of 6

      A LoadBalancer Service sets externalTrafficPolicy: Local. Its two pods run on two of five nodes. What changes compared with Cluster?

    4. Check 4 of 6

      You add a second port to a Service that has one unnamed port. The API server rejects the change. Why?

    5. Check 5 of 6

      A Service sets trafficDistribution: PreferSameZone. Zone b has clients but no ready endpoints. Where does traffic from zone b go?

    6. Check 6 of 6

      On EKS with the AWS Load Balancer Controller v2.5 or later installed with defaults, you create a Service of type LoadBalancer with no annotations. What do you get?

    Lesson not yet reconciled

    Desired: 5 objectives, 0 metReconciled: 5 of 5 objectives met

    • Choose between ClusterIP, NodePort, LoadBalancer, ExternalName and headless Services for a workload. (not yet met)
    • Wire port, targetPort and named ports so that a Service reaches its pods, including Services with several ports. (not yet met)
    • Explain how externalTrafficPolicy and internalTrafficPolicy change source addresses and the number of hops. (not yet met)
    • Keep traffic inside a zone with trafficDistribution set to PreferSameZone, and say what it costs. (not yet met)
    • Diagnose a Service with no endpoints from its EndpointSlices, selector and pod labels. (not yet met)

    Pass every check above to reconcile this lesson.

    Every check has passed, so the desired state is met. First-try accuracy: 0 of 6. This lesson's review cards are in your queue.

    Practice

    Put this lesson to work on the simulated cluster. Everything runs in your browser, with nothing to install.

    Changed since the notes

    This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.

    Show 13 corrections
    1. Stale, true once, no longerKubernetes Services

      The notes saidThe Endpoints object (or EndpointSlice in newer clusters) … the Endpoints controller

      CorrectedThe EndpointSlice API and controller are primary. v1 Endpoints has been deprecated since v1.33.

      Sourcekubernetes.io/blog/2025/04/24/endpoints-deprecation

    2. Stale, true once, no longerKubernetes Services

      The notes saidIPVS performs better at scale than iptables

      CorrectedIPVS is deprecated since v1.35. nftables mode outperforms both iptables and IPVS and is the recommended replacement.

      Sourcekubernetes.io/docs/reference/networking/virtual-ips

    3. Nuance, true with conditionsKubernetes Services

      The notes saidIn EKS with the AWS Load Balancer Controller, a LoadBalancer Service creates an NLB by default

      CorrectedOnly new Services get an NLB by default, through the LBC v2.5+ mutating webhook (on by default), which sets loadBalancerClass service.k8s.aws/nlb. The scheme defaults to internal. The legacy cloud provider creates Classic Load Balancers.

      Sourcedocs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html

    4. Wrong, not trueKubernetes Services

      The notes saidIn EKS, annotations control whether you get an NLB or ALB

      CorrectedA LoadBalancer Service never produces an ALB. ALBs come from Ingress or Gateway API through the LBC or EKS Auto Mode.

      Sourcedocs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html

    5. Stale, true once, no longerKubernetes Services

      The notes saidSelector-less Services are wired by manually managing the Endpoints object

      CorrectedCreate EndpointSlices labelled kubernetes.io/service-name=<service>. The Endpoints API is deprecated and its mirroring is deprecated too.

      Sourcekubernetes.io/docs/concepts/services-networking/service

    6. Wrong, not trueKubernetes Services

      The notes saidEach port gets a name

      CorrectedPort names are required only when a Service has more than one port.

      Sourcekubernetes.io/docs/concepts/services-networking/service

    7. Nuance, true with conditionsKubernetes Services

      The notes saidLoadBalancer traffic always flows LB -> NodePort -> pod

      CorrectedWith IP targets (LBC or EKS Auto Mode) the load balancer sends traffic straight to Pod IPs. Setting allocateLoadBalancerNodePorts: false skips NodePort allocation for such implementations.

      Sourcekubernetes.io/docs/concepts/services-networking/service

    8. Wrong, not trueAWS Load Balancers Compared

      The notes saidFor LoadBalancer Services the controller creates NLBs by default; annotation 'aws-load-balancer-type: external' (missing 'service.beta.kubernetes.io/' prefix; grouped)

      CorrectedThe annotation key needs its prefix: service.beta.kubernetes.io/aws-load-balancer-type: external. Since AWS Load Balancer Controller v2.5, its Service mutating webhook (enableServiceMutatorWebhook, default true) sets loadBalancerClass: service.k8s.aws/nlb on new LoadBalancer Services, so the controller provisions them without the annotation. The NLB is internal by default (since v2.2.0) unless aws-load-balancer-scheme: internet-facing is set, and the default target type is instance.

      Sourcekubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/service/nlb

    9. Nuance, true with conditionsAWS Load Balancers Compared

      The notes saidGateway Load Balancer is the newest load balancer type

      CorrectedGateway Load Balancer launched in Nov 2020. Give the launch date instead of 'newest', which goes stale.

      Sourceaws.amazon.com/about-aws/whats-new/2020/11/introducing-aws-gateway-load-balancer

    10. Stale, true once, no longerAWS Load Balancers Compared

      The notes saidAWS Load Balancer Controller scope (Ingress and Service only)

      CorrectedThe AWS Load Balancer Controller also implements Gateway API, with L7 routes on ALB and L4 routes on NLB; that support is GA in v3.0.0 (Jan 23, 2026). The most recent release as of 2026-11-19 is v3.6.3.

      Sourcegithub.com/kubernetes-sigs/aws-load-balancer-controller/releases/tag/v3.0.0

    11. Nuance, true with conditionsAWS Load Balancers Compared

      The notes saidSecurity groups control traffic to load balancers

      CorrectedNLBs have supported security groups since Aug 10, 2023, but only if a security group is associated when the NLB is created (AWS Load Balancer Controller v2.6.0+ does this for new Services). Cross-zone load balancing is always on for ALBs at the load-balancer level (it can be turned off per target group) and off by default for NLBs and GWLBs.

      Sourcedocs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-security-groups.html%20;%20https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html

    12. Nuance, true with conditionsAWS Load Balancers Compared

      The notes said'NLB preserves the source IP address by default' is wrong for IP-type target groups with TCP/TLS

      CorrectedConfirmed. Client IP preservation is enabled by default for instance targets and for IP targets using UDP, TCP_UDP or QUIC, but disabled for IP targets using TCP or TLS. For IP-mode TCP/TLS, set preserve_client_ip.enabled=true (with the controller, the aws-load-balancer-target-group-attributes annotation) or enable proxy protocol v2.

      Sourcedocs.aws.amazon.com/elasticloadbalancing/latest/network/edit-target-group-attributes.html

    13. Wrong, not trueAWS Load Balancers Compared

      The notes said'Connection logs for NLB capture TLS connection details'

      CorrectedConfirmed. NLBs have access logs, created only for TLS listeners. Connection logs, which record client TLS connection details including mTLS, are an ALB feature.

      Sourcedocs.aws.amazon.com/elasticloadbalancing/latest/network/enable-access-logs.html%20;%20https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-connection-logs.html

    Every correction across the guide, by note and topic.

    Sources

    Checked against kubernetes.io and AWS documentation for Kubernetes 1.37 on .

    1. kubernetes.io/docs/concepts/services-networking/service
    2. kubernetes.io/docs/reference/networking/virtual-ips
    3. kubernetes.io/docs/concepts/services-networking/service-traffic-policy
    4. kubernetes.io/docs/concepts/services-networking/topology-aware-routing
    5. kubernetes.io/docs/concepts/services-networking/endpoint-slices
    6. kubernetes.io/docs/concepts/services-networking/dns-pod-service
    7. kubernetes.io/blog/2025/04/24/endpoints-deprecation
    8. docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html
    9. docs.aws.amazon.com/eks/latest/userguide/auto-configure-nlb.html
    10. kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/service/nlb

    Services

    ↓ ↑ step, 1 to 8 scene, Esc leave

    kind cluster kxLast command: Nothing run yet