Shoomer

  • Docker
    DockerShow More
    Monolith to Microservices: A Docker + K8s Migration Story
    8 Min Read
    Docker Security Best Practices | Scout Trivy Scans
    8 Min Read
    CI/CD with Docker and Kubernetes with Examples YML
    10 Min Read
    Docker Networking Deep Dive | Bridge, Host, Overlay
    9 Min Read
    Docker Volumes and Bind Mounts Explained with Examples
    7 Min Read
  • Kubernetes
    KubernetesShow More
    Zero to Hero Kubernetes Crash Course – Minikube, kubectl, Helm Quickstart
    7 Min Read
    Spring Boot Web Crash Course 2025 – REST APIs, Controllers, Get/Post
    7 Min Read
    K8s Crash Course – Learn Containers to Clusters (Hands-On in 2025)
    7 Min Read
    Spring Data JPA Crash Course 2025 – Repository, Query Methods & Paging
    7 Min Read
    Spring Boot for Web Development – Crash Course with Thymeleaf & MVC
    7 Min Read
  • CICD Pipelines
    CICD PipelinesShow More
    What is GitOps with ArgoCD: Deep Dive into Architecture
    10 Min Read
    CI/CD with Docker and Kubernetes with Examples YML
    10 Min Read
  • Pages
    • About Us
    • Contact Us
    • Cookies Policy
    • Disclaimer
    • Privacy Policy
    • Terms of Use
Notification Show More
Font ResizerAa
Font ResizerAa

Shoomer

  • Learning & Education
  • Docker
  • Technology
  • Donate US
Search
  • Home
  • Categories
    • Learning & Education
    • Technology
    • Docker
  • More Foxiz
    • Donate US
    • Complaint
    • Sitemap
Follow US
Home » Advanced Networking in Kubernetes | Pod to Pod Networking
Kubernetes

Advanced Networking in Kubernetes | Pod to Pod Networking

shoomer
By shoomer
Last updated: June 11, 2025
Share

Kubernetes networking forms the backbone of communication between Pods, Services, and external entities in a cluster. Modern networking solutions like Calico and Cilium offer advanced capabilities for scalability, security, and performance. This guide dives into Kubernetes networking, exploring eBPF-based networking, NetworkPolicies, debugging techniques, and multi-cluster connectivity.

Contents
Table of ContentsCalico and Cilium (eBPF-Based Networking)Introduction to CalicoIntroduction to CiliumDeep Dive into NetworkPoliciesUnderstanding NetworkPoliciesAdvanced ExamplesDeny All Traffic Except Database Access:Isolation by Namespace:Debugging DNS and Pod-to-Pod NetworkingDNS Resolution in KubernetesTroubleshooting DNSTroubleshooting Pod NetworkingMulti-Cluster NetworkingChallenges in Multi-Cluster NetworkingSolutions Using KubeFed, Submariner, and Cilium Cluster MeshKubeFed (Kubernetes Federation):Submariner for Cross-Cluster ConnectivityCilium Cluster MeshMulti-Cluster Service ExampleFinal Thoughts

Table of Contents

  1. Calico and Cilium (eBPF-Based Networking)
    • Introduction to Calico
    • Introduction to Cilium
  2. Deep Dive into NetworkPolicies
    • Understanding NetworkPolicies
    • Advanced Examples
  3. Debugging DNS and Pod-to-Pod Networking
    • DNS Resolution in Kubernetes
    • Troubleshooting Pod Networking
  4. Multi-Cluster Networking
    • Challenges in Multi-Cluster Networking
    • Solutions using KubeFed, Submariner, and Cilium Cluster Mesh
  5. Final Thoughts

Calico and Cilium (eBPF-Based Networking)

Introduction to Calico

Calico is a high-performance networking and network security solution for Kubernetes. It uses a combination of BGP (Border Gateway Protocol) and IPAM (IP Address Management) for scalable networking and supports NetworkPolicies to enforce security boundaries.

Calico Key Features:

  1. IP-Based Networking: Offers L3 routing for optimized performance.
  2. NetworkPolicies: Enforces fine-grained traffic controls.
  3. Compatibility: Supports hybrid and multi-cloud environments.

Installing Calico:
Calico can be installed with a single command using its manifest:

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

Calico Example Use Case:
Deploy an application with Pod-to-Pod communication restricted to the namespace:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-cross-namespace
spec:
  podSelector: {}
  policyTypes:
    - Egress
    - Ingress
  ingress:
    - from:
        - namespaceSelector:
            matchLabels:
              name: my-namespace

Introduction to Cilium

Cilium, powered by eBPF (extended Berkeley Packet Filter), is a next-generation networking plugin designed for high scalability and visibility. eBPF allows Cilium to insert logic directly into the kernel for faster, safer execution.

Cilium Key Features:

  1. eBPF Networking: Delivers higher performance by bypassing traditional kernel networking stacks.
  2. Layer 7 Policies: Supports API-level controls for HTTP, Kafka, gRPC, and more.
  3. Cluster Mesh: Provides multi-cluster connectivity and service discovery.

Installing Cilium:
Install Cilium via its CLI:

helm install cilium cilium/cilium --namespace kube-system

Cilium Example Policy:
Restrict Pods to allow HTTP traffic only to specific endpoints:

apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: allow-http
spec:
  endpointSelector:
    matchLabels:
      app: my-app
  egress:
  - toEndpoints:
    - matchLabels:
        app.kubernetes.io/name: back-end
    toPorts:
    - ports:
      - port: "80"
        protocol: TCP
      rules:
        http:
        - method: "GET"
          pathRegex: "^/status/.*"

Deep Dive into NetworkPolicies

Understanding NetworkPolicies

NetworkPolicies are Kubernetes objects that control ingress and egress traffic at the Pod level. By default, Pods in Kubernetes can freely communicate, but enabling NetworkPolicies restricts this behavior.

Key Components:

  1. PodSelector: Specifies the affected Pods.
  2. Ingress/Egress Rules: Configures allowed traffic directions.
  3. NamespaceSelector & IPBlock: Defines external or namespace-level traffic sources.

Example Basic NetworkPolicy (Allow-Web-Ingress):
Allow incoming traffic to Pods with label app=web from any namespace:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-web-ingress
spec:
  podSelector:
    matchLabels:
      app: web
  ingress:
    - from:
        - namespaceSelector: {}

Advanced Examples

Deny All Traffic Except Database Access:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: db-only
spec:
  podSelector:
    matchLabels:
      app: backend
  policyTypes:
    - Egress
  egress:
  - to:
    - podSelector:
        matchLabels:
          app: database

Isolation by Namespace:

Block Pods from communicating across namespaces:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: namespace-isolate
spec:
  podSelector:
    matchLabels:
      role: worker
  ingress:
    - from:
        - podSelector:
            matchLabels:
              appOwnerNamespace: same

Debugging DNS and Pod-to-Pod Networking

DNS Resolution in Kubernetes

Kubernetes provides in-cluster DNS (e.g., CoreDNS) to resolve Pod and Service names.

Sample DNS Name Resolution:

TypeFQDN Example
Pod IP-based<pod-ip>.default.pod.cluster.local
Service Name-basedmy-service.my-namespace.svc.cluster.local

Troubleshooting DNS

  1. Check CoreDNS Pods:
    Ensure Pods are running and healthy:
kubectl get pods -n kube-system -l k8s-app=kube-dns
  1. Test DNS Lookup:
    Use BusyBox to test DNS:
kubectl run -it --rm dns-debug --image=busybox -- nslookup my-service
  1. Inspect CoreDNS ConfigMap:
    Ensure correct domain settings in kube-system:
kubectl edit configmap coredns -n kube-system

Troubleshooting Pod Networking

  1. ping Command:
    Check connectivity between Pods:
kubectl exec -it pod-a -- ping pod-b
  1. Logs from CNI Plugins:
    Inspect Calico or Cilium logs for network plugin issues:
kubectl logs -n kube-system <cni-plugin-pod>
  1. tcpdump for Packet Insights:
    Use tcpdump to monitor network traffic inside a node:
kubectl exec -it pod-a -- tcpdump -i eth0

Multi-Cluster Networking

Challenges in Multi-Cluster Networking

  1. Cross-cluster service discovery.
  2. Managing consistent network policies between clusters.
  3. Low-latency connectivity while ensuring high security.

Solutions Using KubeFed, Submariner, and Cilium Cluster Mesh

KubeFed (Kubernetes Federation):

Synchronizes resources like Deployments across clusters.
Install KubeFed:

kubefedctl join cluster-2 --host-cluster-context cluster-1

Submariner for Cross-Cluster Connectivity

Submariner creates secure IP tunnels between clusters for seamless connectivity.

Install Submariner:

helm install submariner-latest submariner-charts/submariner

Cilium Cluster Mesh

Cilium Cluster Mesh supports service discovery and connectivity between clusters in a secure manner using eBPF.

Enabling Cilium Cluster Mesh:

helm install cilium-cm cilium/cilium-cluster-mesh --namespace kube-system

Multi-Cluster Service Example

Expose a multi-cluster Service:

apiVersion: networking.k8s.io/v1
kind: Service
metadata:
  name: my-app
  annotations:
    "submariner.io/global": "true"
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080

Final Thoughts

Advanced Kubernetes networking solutions like Calico and Cilium offer tremendous flexibility for securing, scaling, and visualizing cluster communication. A robust understanding of NetworkPolicies, DNS debugging methods, and multi-cluster frameworks allows operators to build highly secure and performant Kubernetes environments.

By combining these tools and techniques, you can address both everyday networking needs and complex scaling challenges with confidence!

Share This Article
Facebook Email Copy Link Print
Previous Article Running Stateful Applications in Kubernetes (at Scale)
Next Article Best Full Stack Learning Path: Spring Boot, Docker, K8s & Microservices
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Empowering Tomorrow's Leaders through Understanding Child Development and Learning

Learning to thrive

Daily Feed

Zero to Hero Kubernetes Crash Course – Minikube, kubectl, Helm Quickstart
June 23, 2025
Spring Boot Web Crash Course 2025 – REST APIs, Controllers, Get/Post
June 23, 2025
K8s Crash Course – Learn Containers to Clusters (Hands-On in 2025)
June 23, 2025
Spring Data JPA Crash Course 2025 – Repository, Query Methods & Paging
June 23, 2025

You Might Also Like

Kubernetes

Kubernetes Helm Charts: A Complete Tutorial

June 11, 2025
Kubernetes

Complete guide on Auto-Scaling in Kubernetes (HPA/VPA)

June 11, 2025
Kubernetes

Kubernetes Monitoring with Prometheus & Grafana

June 11, 2025
Kubernetes

Top 10 IT Companies in India – 2025 Ranking by Revenue & Workforce

June 23, 2025
@Copyright 2025
  • Docker
  • Technology
  • Learning & Education
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?