Introduction

Kubernetes networking can seem complex at first, but understanding the core concepts is essential for any DevOps engineer. In this guide, we’ll explore the fundamental networking concepts in Kubernetes.

Pod Networking

Every Pod in Kubernetes gets its own IP address. This means you don’t need to explicitly create links between Pods, and you almost never need to deal with mapping container ports to host ports.

# Check Pod IPs
kubectl get pods -o wide

# Test connectivity between Pods
kubectl exec -it pod-1 -- ping <pod-2-ip>

Services

Services provide stable network identities to Pods. They act as load balancers and service discovery mechanisms.

ClusterIP Service

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

Services are an abstract way to expose an application running on a set of Pods as a network service.

Kubernetes Documentation

Network Policies

Network policies allow you to control traffic flow at the IP address or port level for TCP, UDP, and SCTP protocols.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress

Key Takeaways

  • Each Pod has a unique IP address
  • Services provide stable endpoints for Pod groups
  • Network policies control traffic between Pods
  • Understanding these basics is crucial for production deployments

Next Steps

In future posts, we’ll dive deeper into CNI plugins, Ingress controllers, and service mesh architectures like Istio.