blog
  • Blogs
    • Medium Articles
      • Linux
        • 40 Powerful Linux Networking Commands You Must Know.
        • These (Linux) VI Editor Shortcuts You Must Know
        • Bash/Linux Interview Questions for DevOps Engineers
        • Page 1
      • Git
        • 40 Powerful Git Commands Every Developer Should Know
        • 10 Git Best Practices That Every Developer Must Know
      • DevOps/SRE Interview Questions and Answers
        • Top DevOps/SRE Interview Questions and Answers on AWS VPC
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Terraform Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Kubernetes Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Dockerfiles
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Grafana
      • Installation
        • Docker Installation on Ubuntu 20/22
        • Install WireGuard VPN on Docker Compose
        • Install Redis on Docker Compose
        • Gravitee Docker Compose
      • Kubernetes Series 2025
        • Understanding Kubernetes: Part 1 -Control Plane
        • Understanding Kubernetes: Part 2 -Worker Node
        • Understanding Kubernetes: Part 3 -Pod
        • Understanding Kubernetes: Part 4-ReplicaSets
        • Understanding Kubernetes: Part 5 -Deployment
        • Understanding Kubernetes: Part 6 -DaemonSets
        • Understanding Kubernetes: Part 7 -StatefulSet
        • Understanding Kubernetes: Part 8 -ConfigMap
        • Understanding Kubernetes: Part 9 -Kubernetes Secret
        • Understanding Kubernetes: Part 10 -StorageClass
        • Understanding Kubernetes: Part 11 -Persistent Volume (PV)
        • Understanding Kubernetes: Part 12 -Persistent Volume Claim (PVC)
        • Understanding Kubernetes: Part 13 -Services
        • Understanding Kubernetes: Part 14 -ClusterIP Service
        • Understanding Kubernetes: Part 15 -NodePort Service
        • Understanding Kubernetes: Part 16 -Load Balancer Service
        • Understanding Kubernetes: Part 17 -Ingress
        • Understanding Kubernetes: Part 18 -Ingress Controller
        • Understanding Kubernetes: Part 19 -Headless Service
        • Understanding Kubernetes: Part 20-Network Policy
        • Understanding Kubernetes: Part 21 -CNI
        • Understanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits
        • Understanding Kubernetes: Part 23 Node Selector
        • Understanding Kubernetes: Part 24 Taints and Tolerations
        • Understanding Kubernetes: Part 25 Affinity and Anti-Affinity
        • Understanding Kubernetes: Part 26 Preemption and Priority
        • Understanding Kubernetes: Part 27 Role and RoleBinding
        • Understanding Kubernetes: Part 28 ClusterRole and ClusterRoleBinding
        • Understanding Kubernetes: Part 29 Service Account
        • Understanding Kubernetes: Part 30 Horizontal Pod Autoscaler (HPA)
        • Understanding Kubernetes: Part 31 Vertical Pod Autoscaler (VPA)
        • Understanding Kubernetes: Part 33 Startup Probe
        • Understanding Kubernetes: Part 34 Liveness Probe
        • Understanding Kubernetes: Part 35 Readiness Probe
        • Understanding Kubernetes: Part 36 Container Network Interface (CNI)
        • Understanding Kubernetes: Part 37 Container Runtime Interface (CRI)
        • Understanding Kubernetes: Part 38 Container Storage Interface (CSI)
      • Cloudflare
        • Cloudflare Tunnel for Secure HTTP Routing
      • Nginx
        • Nginx use cases that every engineer must know
Powered by GitBook
On this page
  1. Blogs
  2. Medium Articles
  3. Kubernetes Series 2025

Understanding Kubernetes: Part 21 -CNI

PreviousUnderstanding Kubernetes: Part 20-Network PolicyNextUnderstanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits

Last updated 3 months ago


If you’ve been following our Kubernetes series 2025, welcome back! For new readers, check out Part 20: etwork Policy

Container Network Interface (CNI) in Kubernetes

A Container Network Interface (CNI) is a standard used in Kubernetes to configure networking for containers. It provides a pluggable architecture that allows different networking solutions to be integrated seamlessly with Kubernetes. CNI is responsible for assigning IP addresses to Pods, establishing routes, and enforcing network policies across the cluster.

Kubernetes itself does not include a default networking solution; instead, it relies on CNI plugins such as Calico, Flannel, Weave, and Cilium to implement networking functionalities.

Example Use Case:

Suppose you have a Kubernetes cluster that requires advanced network policies, IP address management, and high-performance data path routing. By deploying a CNI solution like Calico, you can achieve efficient network segmentation, security enforcement, and observability within the cluster.


Capabilities of CNI:

  1. Pod Networking:

  • Assigns unique IP addresses to each Pod and ensures connectivity across nodes.

2. Network Policies Enforcement:

  • Supports policies to allow or restrict traffic between Pods.

3. IP Address Management (IPAM):

  • Handles IP allocation and deallocation dynamically within the cluster.

4. Encapsulation & Routing:

  • Implements networking overlays (VXLAN, IP-in-IP) or direct routing for better performance.

5. Scalability:

  • Handles large-scale deployments efficiently by optimizing network traffic.

6. Custom Network Configurations:

  • Allows customization to meet specific infrastructure needs like multi-network support and bandwidth management.


Popular CNI Plugins:

  1. Calico:

  • Provides network security, policy enforcement, and BGP-based routing.

  • Supports both overlay and non-overlay modes for optimal performance.

2. Flannel:

  • Simple and lightweight CNI that creates an overlay network using VXLAN or host-gw.

  • Suitable for small to medium-scale deployments.

3. Weave:

  • Implements a full mesh overlay network with built-in encryption and multi-cloud support.

4. Cilium:

  • Built on eBPF technology, providing high-performance networking and deep observability.

5. Kube-Router:

  • Provides network routing, firewalling, and service proxy functionalities in a single component.


YAML Example — Installing Flannel CNI:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: flannel-daemonset
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: flannel
  template:
    metadata:
      labels:
        app: flannel
    spec:
      hostNetwork: true
      containers:
      - name: kube-flannel
        image: quay.io/coreos/flannel:v0.18.0
        args:
        - "--ip-masq"
        - "--kube-subnet-mgr"
        securityContext:
          privileged: true

Explanation:

  • This DaemonSet deploys Flannel CNI across all nodes in the cluster.

  • It runs in the kube-system namespace with the necessary privileges to manage node networking.

  • The --kube-subnet-mgr flag allows Flannel to dynamically allocate IPs.


In My Previous Role:

As a Senior DevOps Engineer, I managed Kubernetes networking by leveraging CNI plugins to optimize network performance and security. Some of my key contributions included:

  • Implemented Calico CNI to enable fine-grained network policies, ensuring strict access controls between sensitive workloads.

  • Tuned Flannel CNI for low-latency communication across multi-node clusters, achieving 30% performance improvement.

  • Automated CNI deployments using Helm and Terraform to ensure consistency across multiple environments.

  • Troubleshoot networking issues related to Pod connectivity, latency, and DNS resolution using tools like kubectl, Calicoctl, and tcpdump.

  • Collaborated with cloud providers to integrate CNI plugins with VPC networking for hybrid cloud deployments.

🚀 Ready to Master Kubernetes?

Take your Kubernetes journey to the next level with the Master Kubernetes: Zero to Hero course! 🌟 Whether you’re a beginner or aiming to sharpen your skills, this hands-on course covers:

✅ Kubernetes Basics — Grasp essential concepts like nodes, pods, and services. ✅ Advanced Scaling — Learn HPA, VPA, and resource optimization. ✅ Monitoring Tools — Master Prometheus, Grafana, and AlertManager. ✅ Real-World Scenarios — Build production-ready Kubernetes setups.

🎓 What You’ll Achieve

💡 Confidently deploy and manage Kubernetes clusters. 🛡️ Secure applications with ConfigMaps and Secrets. 📈 Optimize and monitor resources for peak performance.

Don’t miss your chance to become a Kubernetes expert! 💻✨

🔥 Start Learning Now: [Join the Master Kubernetes Course]()

🚀 Stay ahead in DevOps and SRE! 🔔 and never miss a beat on Kubernetes and more. 🌟

https://cloudops0.gumroad.com/l/k8s
Subscribe now
Understanding Kubernetes: N