Advanced Networking in Kubernetes

Docker Networking

3 default networking types — None, Host, Bridge (docker0 network)

Containers are launched on Docker bridge
Docker Inner Host Networking (Doesn’t have interconnectivity between node for pod-pod communication)

CNI (Container Network Interface)

Interface between container to network
It is in JSON format
Identify network to attach container
Assign IPs to pods
3rd party plugins: VLAN, MacVLAN, Weave, Calico, Contiv

Kubernetes Networking

IP address of containers change on reboot# Service
Static entry
Monitors pod

Types of Services

1. ClusterIP — Service is accessible inside the cluster
2. NodePort
3. Loadbalancer —Routing performed on Layer 4 (Network layer)
4. Ingress Controller — Layer 7 (Application Layer)

kubectl get pods -o wide      # to see internal IP addresses of pods

Services expose internal IP to the outside world ( Each pod will have a separate service if pods are of different types )

Until service is mentioned, pods can’t talk to each other

kubectl get svckubectl expose pod nginx-pod --type ClusterIP --port 80 --target-port 80            # --port = service port, --target-port = pod portkubectl describe svc nginx-pod

Service has static IP address

Service monitors the pod and does Health Checks
If the pod restarts with the same label, label selector matching happens and all IP of pods with same label are stored in the service monitor


For name registering kube-dns is used

Converting ClusterIP to NodePort

kubectl edit svc nginx-pod
# change service and save it

LB ip -> node ip:node port -> service ip:service port -> pod ip:target port-> container port


Ingress Resource - contains rules 
Ingress Controller - reading rules and processing data
kubectl get ingress



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store