Wire a Service's ports
- 13 min
- 6 steps
- Networking
Steps
0 of 6 done
Fix a Service that sends traffic to the wrong port, add a second port, then expose the same pods as a NodePort and as a headless Service.
Step 1 of 6
kubectl exec client -- curl -sS -m 2 http://shopfails, although theshoppods are Running and Ready. Compare the port the Service forwards to with the port the container listens on.Checked against what your commands print.
Step 2, not started: Point the Service at the container's port by its name, so that the Service keeps working if the image moves to another port number.
Step 3, not started: Add a second port to
shop: port 9090, namedmetrics, forwarding to 9090 on the pods. The API server rejects the first attempt most people make; read what it asks for.Step 4, not started: Create a second Service,
shop-nodeport, that exposes the same pods on port 30080 of every node. Prove it fromclientthrough the address ofkx-worker2.Step 5, not started: Create
shop-headless, a Service for the same pods that gets no cluster IP, so a DNS lookup of its name returns the pod addresses.Step 6, not started: Ask the proxies to prefer
shopendpoints in the client's own zone when there are any.
Enter runs the command. Tab completes, and the arrow keys recall earlier commands. Control C stops a watch. On an empty line, or after Escape, Tab moves focus out of the terminal.