World map

 

BM: Baca dalam Bahasa Melayu

World K3: Counters & Doors

Services: one order number

You will learn: to give a group of pods one fixed address with a Service.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

Shop trays come and go, and so do their IPs. The client needs one address that always works. What would you give it?

Pick one answer.

Watch

You are here: cluster kind-dev namespace default
service.yaml makes a Service called shop. It gets one CLUSTER-IP for all three shop trays. Terminal output: $ kubectl apply -f service.yaml service/shop created $ kubectl get service shop NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE shop ClusterIP 10.96.142.241 <none> 80/TCP 0s

A Service: One order number, whichever stall cooks it: a fixed address for a group of pods. is one order number for a group of pods. Its CLUSTER-IP stays put while trays come and go.

Try it

A Service finds its trays by label. One shop tray lost its sticker. Give it back.

Drag a label onto a tray, or tap a label, then a tray.

Service shop (order number)

selector:app=shop

Picks 2 trays.

Labels

  • shop-1

    • app=shop

    shop picks this tray.

  • shop-2

    • app=shop

    shop picks this tray.

  • shop-3

    • No labels yet.

    Not picked: needs app=shop.

  • menu-1

    • app=menu

    Not picked: needs app=shop.

kubectl get endpointslices -l kubernetes.io/service-name=shopNAME         ADDRESSTYPE   PORTS   ENDPOINTS                  AGEshop-2jl8t   IPv4          80      10.244.1.84,10.244.2.103   12s

Try it

Your turn. kubectl expose deployment shop --port=80 gives the shop an order number. Then call it by name from the client.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 4 (4 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • shop·nvxvs
  • shop·vdzl6
dev-worker2Open
  • client
  • shop·vd259
Time: +0s (sped up)

Predict

You delete one shop tray. Does http://shop still answer?

Pick one answer.

Check

This Service file won’t apply. Read kubectl’s words, then fix it.

Fix the manifest, then press Apply.

service.yaml11 lines

Plain words: kubectl does not know a field called targetport.

You did it!

You can now give pods one fixed address with a Service.

Go deeper (optional)

port and targetPort can differ: port 80 can lead to a tray’s port 8080. On every stall, kube-proxy sends each order to a random ready tray. The practice sim takes turns instead. This plain kind is called ClusterIP: it works inside the cluster only.

Real rep (optional), on a throwaway kind cluster:

Real mission

  1. kubectl expose deployment shop --port=80
  2. kubectl run client --image=busybox:1.37 -- sleep 3600
  3. kubectl exec client -- wget -qO- -T 5 http://shop

0 of 3 steps done · Your ticks are saved.