Kubernetes Networking

Kubernetes Network model

  • All Pods can communicate with all other Pods without using network address translation (NAT).
  • All Nodes can communicate with all Pods without NAT.
  • The IP that a Pod sees itself as is the same IP that others see it as.

It’s turtles all the down

  • Node
  • Container
  • Container to Container
  • Pod to Pod
  • Services
  • External to Cluster

Node

Container

Container to Container

kubectl apply -f pod.yml
kubectl exec -it bb1 -c curl localhost:80

Pod to Pod

kubectl get pods -o wide
kubectl exec -it bb1 -c ping bb3

Services

  • NodePort
  • ClusterIP - Default
  • LoadBalancer

Service to Pod

kubectl apply -f service-clusterip.yml

External to Cluster

  • Service Type Loadbalancer

  • Ingress

Service Type LoadBalancer

kubectlcreate apply -f service-loadbalancer.yml

Ingress

  • Ingress Controller
  • Ingress rule

Ingress Controller

  • Nginx
  • Istio
  • Google Cloud Loadbalancer

Ingress rule

kubectl apply -f ingress.yml

Ingress

References: