Lesson 102 · Section 9: Networking
Lesson 102: Networking introduction: how a cluster's network fits together
The map for the Networking section: the four connection problems Kubernetes solves, the three address ranges every cluster has, which component builds each layer, and the order in which to check them when something cannot connect. · 12 min read · 3 min video
Official competencies this lesson covers
Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.
What this section is about
Up to now you have used the cluster's network without looking at it. You created a Service and a Pod reached it by
name. You ran kubectl logs and the API server reached a kubelet on another machine. All of that worked because
several separate pieces were already in place.
This section opens them one at a time. It is a long section, because networking is where three different worlds meet: plain Linux networking (interfaces, routes, DNS), the container world (network namespaces, CNI), and Kubernetes objects (Services, Ingress, Gateway, NetworkPolicy). When people say Kubernetes networking is hard, they usually mean that a problem can sit in any of the three.
This lesson is the map. It teaches no new command in depth. It tells you which problems exist, which component solves each, and in which order the following lessons take them.
Why it matters for the exam
"Servicing and Networking" is 20 % of the CKA curriculum, and "Troubleshooting" (30 %) includes "Troubleshoot
services and networking". On top of that, installing a cluster with kubeadm is not finished until a network plugin
runs: nodes stay NotReady and CoreDNS stays Pending without one. So a good part of your score depends on
knowing where to look when two things cannot talk.
The four connection problems
Every network question in Kubernetes is one of these four.
| Problem | How Kubernetes solves it | Where you learn it |
|---|---|---|
| Container to container, inside one Pod | The containers of a Pod share one network namespace, so they talk over localhost and share one IP address and one set of ports | Network Namespaces |
| Pod to Pod, anywhere in the cluster | Every Pod gets its own IP address from the Pod range, and a CNI plugin connects all of them | Pod Networking, CNI in Kubernetes |
| Pod to Service | A Service has a stable virtual IP address. kube-proxy programs every node to send traffic for it to a healthy Pod, and CoreDNS gives it a name | Service Networking, DNS in Kubernetes |
| Outside to Service | NodePort and LoadBalancer Services open a way in. An Ingress or a Gateway routes HTTP by host name and path | Ingress, Gateway API |
The Kubernetes network model
Kubernetes does not ship a network. It states a few rules that any network must satisfy, and leaves the building to a plugin. The rules are short:
- Every Pod has its own IP address, unique in the cluster.
- Every Pod can reach every other Pod on that address, on the same node or on another, without NAT (network address translation). The address a Pod sees on an incoming packet is the real address of the sender.
- Agents on a node (the kubelet, system daemons) can reach all Pods on that node.
Parts:
- Pod A (10.244.1.2), in Node A
- Pod B (10.244.1.3), in Node A
- Pod network (built by a CNI plugin)
- Pod C (10.244.2.2), in Node B
- kubelet (reaches local Pods), in Node B
Connections:
- Pod A to Pod network: no NAT
- Pod network to Pod C: no NAT
- Pod A and Pod B: same node
- kubelet to Pod C: probes, logs
The second rule is the important one. It means a Pod behaves like a small machine on one big flat network. An application does not need to know which node it runs on, and you never have to map container ports to host ports to make two Pods talk.
Under the hood · Why not do it the Docker way?
Docker on a single host gives each container a private address behind the host and reaches the outside through NAT.
To receive traffic, a container needs a port published on the host (-p 8080:80). That works for one machine. With
hundreds of containers on many machines it becomes a bookkeeping problem: every published port must be unique per
host, and every application must be told on which host and port its neighbours live.
Kubernetes chose the opposite rule: one IP address per Pod, reachable from everywhere in the cluster. Ports never clash between Pods, and a Pod can move to another node without anyone needing a new port number. The price is that somebody has to build a network where those addresses really are reachable across nodes. That somebody is the CNI plugin. The lessons Docker Networking and CNI compare the two approaches in detail.
Who builds each layer
Parts:
- Linux kernel (interfaces, routes)
- CNI plugin (Pod IPs, Pod routes)
- kube-proxy (Service IPs)
- NetworkPolicy (who may talk)
- Ingress, Gateway (HTTP from outside)
- CoreDNS (Service names)
Connections:
- Linux kernel to CNI plugin: used by
- CNI plugin to kube-proxy: below
- CNI plugin to NetworkPolicy: enforced by plugin
- Ingress, Gateway to kube-proxy: sends to Services
- CoreDNS to kube-proxy: names to Service IPs
| Layer | Owner | What it does | Where it runs |
|---|---|---|---|
| Interfaces, routes, namespaces | The Linux kernel | The raw tools everything else uses | Every node |
| Pod network | A CNI plugin (Flannel, Calico, Cilium, and others) | Creates each Pod's network interface, gives it an IP address, and makes Pod addresses reachable across nodes | A DaemonSet on every node, plus files in /etc/cni/net.d and /opt/cni/bin |
| Service addresses | kube-proxy | Watches Services and their endpoints and writes iptables, IPVS or nftables rules that redirect a Service IP to a Pod IP | A DaemonSet on every node |
| Names | CoreDNS | Answers DNS queries such as web.shop.svc.cluster.local with the Service's IP address | A Deployment in kube-system, behind the Service kube-dns |
| HTTP entry | An Ingress controller or Gateway controller | Accepts outside HTTP traffic and routes it to Services by host and path | Pods you install yourself |
| Access rules | NetworkPolicy, enforced by the CNI plugin | Limits which Pods may talk to which | Rules on every node |
Two things in this table surprise many people:
- A Service IP address does not exist on any interface. It is a virtual address that only appears in kube-proxy's rules. You cannot ping a ClusterIP on many clusters, and that is normal.
- Kubernetes itself runs none of this except kube-proxy and CoreDNS. The Pod network and the Ingress or Gateway controller are add-ons you choose and install.
Three address ranges
A cluster uses three separate ranges of IP addresses. They must not overlap with each other.
| Range | Who gets an address | Typical value | Where it is set |
|---|---|---|---|
| Node network | Each node's network interface | 192.168.56.0/24 | Your infrastructure, outside Kubernetes |
| Pod network (cluster CIDR) | Each Pod | 10.244.0.0/16 | kubeadm init --pod-network-cidr, and the CNI plugin's configuration |
| Service network | Each Service (ClusterIP) | 10.96.0.0/12 | --service-cluster-ip-range on the kube-apiserver |
With most plugins, each node receives its own slice of the Pod range (10.244.0.0/24 for the first node,
10.244.1.0/24 for the second). That is why you can often tell from a Pod's IP address which node it runs on.
One request through every layer
Parts:
- Outside client (shop.example.com)
- Ingress, Gateway (routes by host, path)
- Service web (10.96.14.20:80)
- CoreDNS (10.96.0.10)
- Pod cart (10.244.1.7)
- Pod web (10.244.2.5:8080)
Connections:
- Outside client to Ingress, Gateway: HTTP
- Ingress, Gateway to Service web: routes
- Pod cart to CoreDNS: web?
- Pod cart to Service web: web:80
- Service web to Pod web: kube-proxy rules
Take a Pod cart that calls http://web:
- The application asks for the name
web. The Pod's/etc/resolv.confpoints at CoreDNS, which answers with the ClusterIP of the Serviceweb, here10.96.14.20. - The Pod sends the request to
10.96.14.20:80. - On the Pod's own node, the rules written by kube-proxy replace the destination with one of the Service's
endpoints, here
10.244.2.5:8080. - The Pod network carries the packet to the node where that Pod runs, and into the Pod.
A client outside the cluster has one extra step at the start: it reaches an Ingress controller or a Gateway (or a NodePort), which forwards to the same Service.
Each step depends on the one below it. If the Pod network is broken, nothing above it works, including DNS, because CoreDNS is itself a Pod.
The road ahead
The section starts on plain Linux, moves to containers, and only then returns to Kubernetes.
| Lessons | Topic | Question they answer |
|---|---|---|
| Switching, Routing and Gateways | Linux basics | How does a machine decide where to send a packet? |
| DNS, CoreDNS | Linux basics | How does a name become an address, and what does a DNS server do? |
| Network Namespaces, Docker Networking, CNI | Containers | How does a container get its own network, and who sets it up? |
| Cluster Networking, Explore Environment | Nodes | Which ports and interfaces does a cluster need? |
| Pod Networking, CNI in Kubernetes, IPAM | Pod layer | How do Pods get addresses and reach each other across nodes? |
| Service Networking | Service layer | What does kube-proxy really write on a node? |
| DNS in Kubernetes, CoreDNS in Kubernetes, Explore DNS | Names | Which names exist, and how is CoreDNS configured in a cluster? |
| Ingress, Annotations and rewrite-target, Ingress Networking | HTTP entry | How does outside HTTP traffic reach a Service? |
| Gateway API, Practical Guide to Gateway API | HTTP entry | What replaces Ingress, and how do you use it? |
If you already know Linux networking well, the first lessons will be quick. Do not skip them completely: the
commands they use (ip addr, ip route, nslookup) are the same ones you will type on a broken node.
Looking at a real cluster
Example · Find the three address ranges
Start with the nodes. The INTERNAL-IP column is the node network:
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP OS-IMAGE CONTAINER-RUNTIME
controlplane Ready control-plane 12d v1.34.2 192.168.56.10 Ubuntu 24.04.1 LTS containerd://1.7.27
node01 Ready <none> 12d v1.34.2 192.168.56.11 Ubuntu 24.04.1 LTS containerd://1.7.27
The Pod range of the whole cluster is a flag of the controller manager, and each node's slice is in the Node object:
grep cluster-cidr /etc/kubernetes/manifests/kube-controller-manager.yaml
kubectl get nodes -o custom-columns=NAME:.metadata.name,PODS:.spec.podCIDR
- --cluster-cidr=10.244.0.0/16
NAME PODS
controlplane 10.244.0.0/24
node01 10.244.1.0/24
The Service range is a flag of the API server:
grep service-cluster-ip-range /etc/kubernetes/manifests/kube-apiserver.yaml
- --service-cluster-ip-range=10.96.0.0/12
Some plugins manage Pod addresses themselves and ignore spec.podCIDR. In that case, read the plugin's own
configuration, or simply look at the addresses in kubectl get pods -A -o wide.
Example · Find out which network plugin a cluster uses
A task may say "the cluster uses the installed CNI plugin" without naming it. Three places tell you:
ls /etc/cni/net.d/
10-flannel.conflist
kubectl get pods -A -o wide | grep -Ei 'flannel|calico|cilium|weave|canal'
kube-flannel kube-flannel-ds-7xk2p 1/1 Running 0 12d 192.168.56.10 controlplane
kube-flannel kube-flannel-ds-m4qcz 1/1 Running 0 12d 192.168.56.11 node01
ls /opt/cni/bin/
bridge flannel host-local loopback portmap ...
The file in /etc/cni/net.d is the configuration the container runtime reads, the DaemonSet is the plugin's agent,
and /opt/cni/bin holds the programs that do the work. The lesson CNI in Kubernetes explains each.
Example · See the network add-ons Kubernetes runs itself
kubectl -n kube-system get deploy,ds,svc
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/coredns 2/2 2 2 12d
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/kube-proxy 2 2 2 2 2 kubernetes.io/os=linux 12d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 12d
CoreDNS is a Deployment, kube-proxy is a DaemonSet (one Pod per node), and the DNS Service is still called
kube-dns, the name of the server CoreDNS replaced.
Example · Walk a failing connection from the bottom up
A Pod cart cannot reach http://web in the namespace shop. Check one layer at a time and stop at the first
that fails.
# 1. Do the target Pods run, and do they have addresses?
kubectl -n shop get pods -o wide
# 2. Does a Pod answer on its own address? (Pod network)
kubectl -n shop exec cart -- wget -qO- -T 2 http://10.244.2.5:8080
# 3. Does the Service have endpoints? (selector and ports)
kubectl -n shop get endpointslices -l kubernetes.io/service-name=web
# 4. Does the Service address answer? (kube-proxy)
kubectl -n shop exec cart -- wget -qO- -T 2 http://10.96.14.20
# 5. Does the name resolve? (CoreDNS)
kubectl -n shop exec cart -- nslookup web
If step 2 works and step 3 shows no endpoints, the problem is a label selector or a readiness probe, not the network. If steps 2 to 4 work and step 5 fails, look at CoreDNS. Later lessons go deep on each step. The order is what to remember today.
Tricks
Common mistakes
- Looking at DNS first. A name that does not resolve is often a symptom: if the Pod network is down, CoreDNS is unreachable too. Test with IP addresses before names.
- Trying to ping a Service. A ClusterIP is a set of rules for specific ports, not an interface. On many clusters
it does not answer ping at all. Test the real port with
wget,curlornc. - Expecting Kubernetes to bring its own Pod network. It does not. Without a CNI plugin, Pods on different nodes
cannot reach each other and nodes do not even become
Ready. - Overlapping ranges. A Pod range that overlaps the node network or the Service range produces traffic that goes to the wrong place and is very hard to diagnose. Check the three ranges when you install a cluster.
- Assuming NetworkPolicy always works. Policies are enforced by the CNI plugin. A plugin without policy support accepts the objects and silently ignores them.
- Mixing up the port numbers. A Service's
port, itstargetPortand a container's port are three different fields. A Service with a wrongtargetPorthas endpoints and still refuses connections.
Recap
- Kubernetes solves four problems: container to container, Pod to Pod, Pod to Service, and outside to Service.
- The network model: one IP address per Pod, and every Pod reaches every other Pod without NAT.
- Layers and owners: Linux, then the CNI plugin (Pod network), kube-proxy (Service IPs), CoreDNS (names), and an Ingress or Gateway (HTTP from outside).
- Three ranges that must not overlap: nodes, Pods (
--cluster-cidr), Services (--service-cluster-ip-range). - Troubleshoot from the bottom up: Pod and its IP, Pod address, Service endpoints, Service address, name.
Official docs
Quiz: check what you learned
5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.
Sign in to take the quiz and keep your score.
Discussion
Learners ask and answer questions here. Sign in to read and join the discussion.