abhilashthale.tech
  • Home
  • BlogCategories
    • coding
    • other
    • n
  • Images to Pdf
  • My Files
  • Shares Average
  • About Me
  • Server Stats
  • Day
  • Night
  • Birds
  • Waves
  • Net
  • Dots
  • Halo
  • Rings
  • Fog
  • Clouds

    Kubernetes Networking Notes

    by abhilashthale - June 3, 2026

    Kubernetes Networking Revision Notes

    1. Basic Networking Building Blocks

    Network Namespace

    A Pod gets its own network namespace.

    Inside a namespace:

    • Interfaces
    • Routing table
    • ARP table
    • iptables view

    are isolated from the host.

    Think:

    Host Network Namespace ↓ Pod Network Namespace


    veth Pair

    A veth pair is like a virtual cable.

    Example:

    Pod eth0 ↔ veth123

    One end is inside Pod.

    One end is on host.

    Traffic enters/leaves Pod through veth.


    Bridge

    A bridge works like a virtual switch.

    Example:

    PodA ↓ veth ↓ Bridge ↓ veth ↓ PodB

    Bridge works at Layer 2.


    2. Routing

    Routing decides:

    "Where should packet go next?"

    Example:

    DST=172.16.212.50

    Kernel checks routing table.

    Chooses interface.

    Sends packet.

    Routing happens after DNAT.


    3. Netfilter Hooks

    Hooks are checkpoints inside kernel.

    PREROUTING

    Packet just arrived.

    Used mainly for:

    • DNAT
    • Service translation

    INPUT

    Packet destined for local host.

    Examples:

    • sshd
    • kubelet

    FORWARD

    Packet passing through host.

    Examples:

    • PodA → PodB
    • NodePort → Pod

    OUTPUT

    Packet generated locally.

    Examples:

    • kubelet
    • curl from host

    POSTROUTING

    Packet leaving system.

    Used mainly for:

    • SNAT
    • MASQUERADE

    4. NAT

    DNAT

    Change destination.

    Example:

    10.96.0.25 ↓ 172.16.212.50

    Used by:

    • Services
    • NodePort
    • Ingress traffic

    SNAT

    Change source.

    Example:

    172.16.212.50 ↓ 192.168.241.141

    Used when returning traffic.


    MASQUERADE

    Dynamic SNAT.

    Commonly used when Pods access outside world.


    5. Conntrack

    Conntrack tracks connections.

    Stores:

    SRC IP SRC PORT DST IP DST PORT Protocol

    Example:

    192.168.1.10:50000 ↓ 10.96.0.25:80

    States:

    NEW ESTABLISHED RELATED INVALID

    Purpose:

    • Return traffic mapping
    • NAT tracking
    • Firewall efficiency

    6. Kubernetes Services

    A Service is NOT:

    • Process
    • Pod
    • Interface

    Service is:

    A virtual IP + kube-proxy rules.

    Example:

    rabbitmq-service

    10.96.0.25


    Flow:

    Pod ↓ 10.96.0.25 ↓ kube-proxy ↓ DNAT ↓ RabbitMQ Pod


    7. kube-proxy

    Watches:

    • Services
    • Endpoints

    from API Server.

    Creates:

    • iptables rules

    Main Job:

    Service IP ↓ Pod IP

    Example:

    10.96.0.25 ↓ 172.16.212.50


    8. CoreDNS

    Purpose:

    Name ↓ Service IP

    Example:

    rabbitmq ↓ 10.96.0.25


    Pod resolv.conf:

    nameserver 10.96.0.10


    Flow:

    Application ↓ DNS Query ↓ 10.96.0.10 ↓ kube-proxy ↓ CoreDNS Pod ↓ Returns Service IP


    CoreDNS watches API Server.

    Keeps service records in memory.

    Example:

    rabbitmq → 10.96.0.25

    mysql → 10.96.0.50


    9. Calico

    Purpose:

    • Pod networking
    • Routing
    • Network Policy

    Calico uses Linux networking.

    Creates:

    • Routes
    • iptables policy rules

    Traffic:

    PodA ↓ Host Network ↓ FORWARD ↓ Calico Rules ↓ PodB


    10. Network Policy

    Network Policy controls:

    • Allow
    • Deny

    pod communication.

    Implemented by Calico.

    Calico creates iptables rules.

    Example:

    Allow:

    frontend ↓ backend

    Deny:

    all others


    11. iptables Chains

    Chain = Collection of Rules.

    Example:

    FORWARD chain

    contains many rules.

    Can call another chain.

    Example:

    FORWARD ↓ CALICO-FORWARD ↓ Policy Rules

    Think:

    Main Chain ↓ Sub Chain ↓ Rules


    12. Pod to Pod Communication

    PodA ↓ veth ↓ Host Routing ↓ Calico ↓ Worker2 ↓ PodB


    13. Pod to Service Communication

    PodA ↓ Service IP 10.96.0.25 ↓ kube-proxy DNAT ↓ PodB


    14. DNS Resolution

    Application

    curl rabbitmq

    ↓

    CoreDNS

    ↓

    10.96.0.25

    ↓

    Application connects

    ↓

    kube-proxy

    ↓

    RabbitMQ Pod


    15. Ingress

    Ingress Object:

    Routing Rules.

    Example:

    myrabbitmqui.com ↓ rabbitmq-service

    Ingress Object does NOT receive traffic.


    16. Ingress Controller

    Actual software.

    Examples:

    • NGINX
    • Traefik

    Receives HTTP/HTTPS traffic.

    Reads:

    Host Header

    Example:

    Host: myrabbitmqui.com

    ↓

    rabbitmq-service


    17. HTTPS

    Browser ↓ 443 ↓ Ingress Controller ↓ Certificate Validation ↓ Encrypted Traffic

    Certificate usually stored in:

    Kubernetes Secret


    18. Complete Flow

    Browser ↓ myrabbitmqui.com ↓ DNS ↓ Worker IP / LoadBalancer ↓ Ingress Controller ↓ rabbitmq-service ↓ kube-proxy ↓ RabbitMQ Pod


    Mental Model

    CoreDNS

    Name → Service IP

    kube-proxy

    Service IP → Pod IP

    Calico

    Can packet travel there?

    Routing

    How packet reaches destination

    Ingress

    Host Name → Service

    Conntrack

    Connection Tracking

    DNAT

    Change Destination

    SNAT

    Change Source

    Service

    Virtual IP

    Pod

    Actual Application

abhilashthale.tech