straits-1dnf62s already has a ClusterIP Service market-web in front of three web Pods. From the shell on your workstation, the Service name means nothing:
console
$ curl -s http://market-web
curl: (6) Could not resolve host: market-webChange the type
Apply a manifest that sets type: NodePort. The name must match the existing Service so it is updated in place:
sh
kubectl apply -n straits-1dnf62s -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: market-web
spec:
type: NodePort
selector:
app: market-web
ports:
- port: 80
targetPort: 80
EOFsh
kubectl get svc market-web -n straits-1dnf62sPORT(S) now reads 80:3xxxx/TCP. The second number is the node port.
Read the node port
sh
kubectl get svc market-web -n straits-1dnf62s -o jsonpath='{.spec.ports[0].nodePort}'
kubectl get nodes -o wideReach it from the shell
The node's INTERNAL-IP is 10.0.0.10. Put the node port after it, using your own number, in the terminal:
console
$ curl -s http://10.0.0.10:31860
<!doctype html>
<html>
<head><title>Monster Market</title></head>
...The page is the same one client fetched by name in the last lab, now served through the node.
text
shell ──▶ 10.0.0.10:3xxxx ──▶ 10.96.x.x:80 ──▶ market-web Pods