From point A to point B
Point A: you know how to create pods and Services, and how to protect them, but the network that connects them is still a black box. Point B: by the end of this chapter you'll understand the three network layers in Kubernetes: the node network, the pod network and the one that brings outside traffic to your applications.
Networking is part of the Container Orchestration domain (28% of the KCNA exam). If you come from a networking background, you'll recognize a lot here: interfaces, routes, bridges, DNS and load balancers, only automated.
- The node network and each component's ports
- The pod network model
- CNI plugins: Calico, Cilium, Flannel
- Cluster DNS with CoreDNS
- Ingress and Gateway API
The cluster network
The foundation is a regular network, physical or virtual, local or wide area, that all the nodes connect to. This is the underlay network. Each node needs at least one interface on it, with a unique IP address, hostname and MAC address.
On top of that network, each component listens on a well-known port. If there's a firewall or a cloud security group between the nodes, these ports have to be open:
| Node | TCP port | Component | Used by |
|---|---|---|---|
| Control plane | 6443 | kube-apiserver | Everyone |
| Control plane | 2379-2380 | etcd | kube-apiserver, etcd |
| Control plane | 10259 | kube-scheduler | The node itself |
| Control plane | 10257 | kube-controller-manager | The node itself |
| All | 10250 | kubelet | The node itself and the control plane |
| Workers | 30000-32767 | NodePort Services | Everyone |
All the nodes share one network, and each component listens on its own port. Diagram: The House of Routing.
The commands to inspect a node's network are the same as on any Linux machine:
ip link # network interfaces of the node
ip addr show eth0 # the node's IP address
ip route # routing table and default gateway
ss -tlnp | grep kube # ports the Kubernetes components listen on
kubectl get nodes -o wide # INTERNAL-IP of every node
The pod network
The node network isn't enough: pods need their own network, and Kubernetes doesn't implement it. What it does is set a model with three rules that any solution has to follow:
- Every pod has its own IP address.
- All the pods on a node can talk to each other.
- All pods can talk to pods on any other node without NAT: the destination pod sees the source pod's real IP.
You can build it by hand, and doing it once helps you understand it. On each node, for each pod, you create a network namespace, connect it to a bridge with a virtual cable, give it an IP from the node's range and add routes:
# What a CNI plugin automates on every node, for every pod:
ip netns add pod-a # 1. a network namespace for the pod
ip link add v-pod-a type veth peer name v-pod-a-br # 2. a virtual cable (veth pair)
ip link set v-pod-a netns pod-a # one end inside the pod
ip link set v-pod-a-br master cni0 # the other end on the node bridge
ip -n pod-a addr add 10.244.1.2/24 dev v-pod-a # 3. an IP from the node's pod range
ip -n pod-a link set v-pod-a up
ip -n pod-a route add default via 10.244.1.1 # 4. a route out of the pod
Each node has its own IP range for pods, and a route sends traffic to the right node without NAT. Diagram: The House of Routing.
Doing this by hand with hundreds of pods that come and go every minute is impossible. That's why the right solution is a CNI plugin.
CNI: the network plugins
CNI (Container Network Interface) is a CNCF standard that defines how a container runtime asks a plugin for networking. When a pod is created, the runtime calls the plugin with the ADD command, and the plugin creates the interface, assigns the IP and sets up the routes. When the pod is deleted, the runtime calls it with DEL and the plugin cleans everything up.
- The plugin configuration is in
/etc/cni/net.d/. - The plugin binaries are in
/opt/cni/bin/. - The plugin is usually deployed as a DaemonSet, with one pod on each node.
ls /etc/cni/net.d/ # which CNI plugin is configured
ls /opt/cni/bin/ # the plugin binaries
kubectl get pods -n kube-system # e.g. calico-node or cilium on every node
kubectl get pods -o wide # the IP and node of every pod
| Plugin | How it works | Network Policies |
|---|---|---|
| Flannel | A simple overlay network with VXLAN | Doesn't enforce them on its own |
| Calico | BGP routing or overlay, widely used in companies | Yes |
| Cilium | Based on eBPF, with observability through Hubble | Yes, including layer 7 |
DNS in Kubernetes
Pod IPs change every time pods are recreated, so applications find each other by name. Kubernetes comes with its own DNS server: CoreDNS, which runs as a Deployment in the kube-system namespace behind a Service called kube-dns.
Every time you create a Service, CoreDNS gives it a name. The full name has four parts:
A Service's full name: service, namespace, type and cluster domain. Diagram: The House of Routing.
You don't always need to type it in full. The kubelet sets up each pod's /etc/resolv.conf file with search domains:
# /etc/resolv.conf inside a pod of the namespace "apps"
nameserver 10.96.0.10
search apps.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
- From the same namespace,
web-serviceis enough. - From another namespace, use
web-service.apps. - The full name,
web-service.apps.svc.cluster.local, works from anywhere.
Pods can have DNS records too, but they're based on the IP with dashes (10-244-1-5.apps.pod.cluster.local) and turned off in many installations. In practice, you always talk to a Service.
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl get svc -n kube-system kube-dns
kubectl run dns-test --image=busybox:1.36 --rm -it --restart=Never -- \
nslookup web-service.apps.svc.cluster.local
Ingress
To publish an application outside the cluster, you can use a NodePort or LoadBalancer Service. It works, but with ten applications you'd have ten load balancers, ten public IPs and ten certificates to manage.
Ingress solves that with a single entry point that routes HTTP and HTTPS traffic by hostname or path. It has two parts:
- The Ingress controller: a reverse proxy that runs in the cluster, such as NGINX, Traefik, HAProxy or Envoy. It isn't installed by default: without a controller, Ingress resources do nothing.
- Ingress resources: the rules, written in YAML, that the controller reads and applies.
A single controller routes traffic to several Services based on the path. Diagram: The House of Routing.
Path-based rules: everything arrives at shop.example.com and the path decides where it goes.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shop
spec:
ingressClassName: nginx
rules:
- host: shop.example.com
http:
paths:
- path: /wear
pathType: Prefix
backend:
service:
name: wear-service
port:
number: 80
- path: /watch
pathType: Prefix
backend:
service:
name: watch-service
port:
number: 80
Host-based rules: each subdomain goes to its own Service.
spec:
ingressClassName: nginx
rules:
- host: wear.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service: { name: wear-service, port: { number: 80 } }
- host: watch.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service: { name: watch-service, port: { number: 80 } }
ingressClassName says which controller handles the resource, and pathType can be Prefix (the path and everything under it) or Exact (only that path). With a tls section and a Secret holding the certificate, the controller terminates HTTPS.
kubectl get ingressclass
kubectl get ingress
kubectl describe ingress shop
kubectl create ingress shop --class=nginx \
--rule="shop.example.com/wear*=wear-service:80"
Gateway API: what's next
The Ingress API is still available and stable, but it's frozen: it no longer gets new features. Its successor is Gateway API, which splits responsibilities across three objects:
- GatewayClass: the type of load balancer, defined by the infrastructure provider.
- Gateway: the actual entry point, with its ports and certificates. The platform team manages it.
- HTTPRoute (and other routes): each application's rules. Each development team writes its own.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: shop
spec:
parentRefs:
- name: public-gateway # a Gateway managed by the platform team
hostnames: ["shop.example.com"]
rules:
- matches:
- path: { type: PathPrefix, value: /wear }
backendRefs:
- name: wear-service
port: 80
KCNA-style challenge
Answer before you open the solution. Getting it wrong here is the cheapest way to learn.
1. Which port does the kube-apiserver listen on?
6443. etcd uses 2379-2380 and the kubelet uses 10250.
2. A pod on node 1 talks to a pod on node 2. According to the Kubernetes network model, which source IP does the destination see?
The source pod's real IP. The model requires pod-to-pod communication without NAT.
3. Which component creates the interface and assigns the IP for a new pod?
The CNI plugin, which the container runtime calls with the ADD command.
4. A pod in the front namespace wants to reach the api Service in the back namespace. Which short name works?
api.back, or the full name api.back.svc.cluster.local. Just "api" isn't enough, because it would be looked up in the front namespace.
5. You create a correct Ingress resource, but nothing happens. What's missing?
An Ingress controller. Kubernetes doesn't install one by default, and without it the rules aren't applied.
Key takeaways
- The nodes share a regular network; the API server listens on 6443, etcd on 2379-2380 and the kubelet on 10250.
- NodePorts use the 30000-32767 range.
- The network model: every pod has its own IP, and all pods talk to each other without NAT, whatever node they're on.
- Kubernetes doesn't implement the pod network: a CNI plugin such as Calico, Cilium or Flannel does.
- CoreDNS gives Services their names: service.namespace.svc.cluster.local.
- Ingress is a controller plus rules; without a controller, the rules do nothing.
- Gateway API is the successor to Ingress, and the Ingress NGINX controller is no longer maintained.
In the next chapter you'll go back to Services in more detail and take the leap to the service mesh: sidecars, Envoy and Istio.
Official resources
- Cluster Networkingkubernetes.io
- Ports and Protocolskubernetes.io
- The Kubernetes network modelkubernetes.io
- Network Pluginskubernetes.io
- DNS for Services and Podskubernetes.io
- Ingresskubernetes.io
- Ingress Controllerskubernetes.io
- Gateway APIkubernetes.io
- Ingress NGINX Retirement: What You Need to Knowkubernetes.io
- CNI: the Container Network Interfacecni.dev
- Kubernetes and Cloud Native Associate (KCNA)cncf.io
Source and credits. Chapter written from Jesús Espinoza's study notes on KodeKloud's KCNA course (January to April 2026). Text drafted with AI assistance; original diagrams by The House of Routing. Technical details and YAML examples were checked against the official Kubernetes and CNCF documentation.