liveBook · Manning

IP address

As explained in Kubernetes in Action, Second Edition

An IP address is a numeric network-layer identifier assigned to a device, network interface, or pod.

An IP address identifies where a pod can be reached on the cluster network. Each pod has its own network interface and IP address. Containers in the same pod share that address and its port space; containers in different pods communicate across the pod network. section 11.0 section 3.3.1

A pod can send traffic directly to another pod when it knows the destination IP address and application port. This works across worker nodes: direct pod-to-pod packets retain their source and destination IP addresses and ports, so the receiving pod sees the sender’s IP address. section 11.0

$ kubectl get pod kiada -o wide
NAME    READY   STATUS    RESTARTS   AGE   IP           NODE     ...
kiada   1/1     Running   0          35m   10.244.2.4   worker2  ...

Run `kubectl get pod kiada -o wide` to find the pod’s address in the IP column. You can also find it in the pod’s status under `podIP`. section 5.3.1

Choose how to reach the application based on where the client runs:

  • From another pod, send the request to the destination pod’s IP address and listening port; for example, `curl 10.244.2.4:8080`. section 5.3.1
  • From your local computer, do not assume the pod IP is reachable: it is typically internal to the cluster. For development or debugging, run `kubectl port-forward kiada 8080`, then request `localhost:8080`. section 5.3.1
  • Use a Service when you want traffic forwarded to pods rather than a direct connection to one specific pod. section 5.3.1

The IP address alone does not tell you which port the application listens on. Listing container ports in a pod definition helps readers discover the intended port, but omitting that list does not prevent connections to a port the container accepts. section 5.3.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains shared pod addressing, IP lookup, reachability, and direct packet behavior without detailing IP assignment or network-plugin implementation.
Examples
Demonstrates `kubectl get pod -o wide`, a request to `10.244.2.4:8080`, and `kubectl port-forward` followed by a localhost request.
What it assumes
Introduces pod addressing through containers and simple requests, while assuming familiarity with basic `kubectl` and `curl` commands.
What you can do after
Operate/configure it by finding a pod’s IP address and choosing direct pod access or port forwarding for a request.
How it connects
Connects pod IP addresses to network namespaces, container ports, Services, port forwarding, and network address translation.

Also explained in

Compare how 4 books explain IP address →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.