Unless you say otherwise, a Service is a ClusterIP Service: reachable from inside the cluster, and only from there.
A virtual IP
learner@shallows:~$ kubectl get svc market-web
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
market-web ClusterIP 10.96.248.109 <none> 80/TCP 5s10.96.248.109 is not a machine. No container listens on it. It is an address that every node knows how to rewrite.
kube-proxy, the third program on every node from Chapter 2, watches Services and programs the node's packet rules. A packet to the cluster IP leaves the node already addressed to a Pod. Three Pods behind the Service share the traffic.
Reach it
From a Pod, the Service answers by name or by IP:
learner@shallows:~$ kubectl exec client -- wget -qO- market-web
<!doctype html>
<html>
<head><title>Monster Market</title></head>From your own terminal the name means nothing; curl http://market-web fails. The cluster IP is inside the cluster.
Service port
expose --port=8080 sets the port clients use. For now it is also the port on the Pod; the lesson after next separates the two.
learner@shallows:~$ kubectl expose deployment market-api --port=8080
service/market-api exposed
learner@shallows:~$ kubectl exec client -- wget -qO- market-api:8080/healthz
{"status":"ok"}