Bird
Raised Fist0
Kubernetesdevops~30 mins

Container Network Interface (CNI) in Kubernetes - Mini Project: Build & Apply

Choose your learning style10 modes available
Container Network Interface (CNI) Setup in Kubernetes
📖 Scenario: You are setting up a Kubernetes cluster and need to configure the network so that pods can communicate with each other. This is done using a Container Network Interface (CNI) plugin.In this project, you will create a simple YAML configuration to apply a CNI plugin to your cluster, configure a network range, and verify the network setup.
🎯 Goal: Learn how to apply a CNI plugin configuration in Kubernetes and verify that pods can communicate over the network.
📋 What You'll Learn
Create a YAML manifest for a CNI plugin deployment
Add a network configuration with a specific pod CIDR range
Apply the CNI configuration to the Kubernetes cluster
Verify the network plugin pods are running
💡 Why This Matters
🌍 Real World
Kubernetes clusters need a network plugin to allow pods to communicate. Setting up a CNI plugin like Calico is a common real-world task to enable pod networking.
💼 Career
DevOps engineers and Kubernetes administrators often configure and manage CNI plugins to ensure cluster networking works correctly and securely.
Progress0 / 4 steps
1
Create the CNI Plugin YAML Manifest
Create a YAML file named calico.yaml with the following content to deploy the Calico CNI plugin. Include the apiVersion as projectcalico.org/v3 and kind as Installation. Set the spec.calicoNetwork.ipPools[0].cidr to 192.168.0.0/16.
Kubernetes
Hint

Use the exact keys apiVersion, kind, and spec.calicoNetwork.ipPools[0].cidr with the given values.

2
Add Network Configuration for Pod CIDR
In the same calico.yaml file, add a spec.kubernetesProvider section with nodePortSupport set to true to enable Kubernetes node port support.
Kubernetes
Hint

Indent kubernetesProvider under spec and set nodePortSupport to true.

3
Apply the CNI Plugin Configuration
Use the command kubectl apply -f calico.yaml to apply the CNI plugin configuration to your Kubernetes cluster.
Kubernetes
Hint

Type the exact command kubectl apply -f calico.yaml to apply the configuration.

4
Verify the CNI Plugin Pods are Running
Run kubectl get pods -n calico-system and check that the Calico pods have the status Running. Print the output of this command.
Kubernetes
Hint

Use the exact command kubectl get pods -n calico-system to see the status of Calico pods.

Practice

(1/5)
1. What is the main purpose of the Container Network Interface (CNI) in Kubernetes?
easy
A. To manage storage volumes for containers
B. To provide IP addresses and networking for pods
C. To schedule pods on nodes
D. To monitor container resource usage

Solution

  1. Step 1: Understand CNI role in Kubernetes

    CNI is responsible for setting up networking so pods can communicate.
  2. Step 2: Identify correct function

    Providing IP addresses and network connectivity to pods is the core function of CNI.
  3. Final Answer:

    To provide IP addresses and networking for pods -> Option B
  4. Quick Check:

    CNI = Pod networking [OK]
Hint: CNI is about pod networking, not storage or scheduling [OK]
Common Mistakes:
  • Confusing CNI with storage management
  • Thinking CNI schedules pods
  • Assuming CNI monitors resources
2. Which of the following is a valid CNI configuration file format?
easy
A. XML
B. CSV
C. INI
D. JSON

Solution

  1. Step 1: Recall CNI config formats

    CNI plugins use JSON or YAML files to configure networking.
  2. Step 2: Identify valid format

    JSON is the standard format for CNI configuration files.
  3. Final Answer:

    JSON -> Option D
  4. Quick Check:

    CNI config = JSON [OK]
Hint: CNI configs are JSON or YAML, not XML or INI [OK]
Common Mistakes:
  • Choosing XML as config format
  • Confusing INI or CSV with CNI config
  • Not knowing CNI uses JSON
3. Given this CNI config snippet:
{
  "cniVersion": "0.4.0",
  "name": "mynet",
  "type": "bridge",
  "bridge": "cni0",
  "ipMasq": true,
  "ipam": {
    "type": "host-local",
    "subnet": "10.22.0.0/16"
  }
}

What IP subnet will pods get addresses from?
medium
A. 172.16.0.0/12
B. 192.168.1.0/24
C. 10.22.0.0/16
D. None, IPs are assigned dynamically

Solution

  1. Step 1: Locate subnet in config

    The subnet is specified inside the "ipam" section as "10.22.0.0/16".
  2. Step 2: Understand IP assignment

    Pods will get IPs from the defined subnet range in the config.
  3. Final Answer:

    10.22.0.0/16 -> Option C
  4. Quick Check:

    Subnet in ipam = 10.22.0.0/16 [OK]
Hint: Look inside "ipam" for subnet to find pod IP range [OK]
Common Mistakes:
  • Ignoring the subnet field
  • Choosing default Kubernetes pod subnet
  • Thinking IPs are random without subnet
4. You installed a CNI plugin but pods cannot communicate across nodes. What is a likely cause?
medium
A. CNI config file missing or incorrect
B. Pods have no CPU limits set
C. Kubernetes API server is down
D. Node disk space is full

Solution

  1. Step 1: Analyze pod network failure

    Pods not communicating across nodes usually means network setup is broken.
  2. Step 2: Check CNI config

    If the CNI config file is missing or wrong, networking won't work properly.
  3. Final Answer:

    CNI config file missing or incorrect -> Option A
  4. Quick Check:

    Network issues = CNI config problem [OK]
Hint: Check CNI config file first for network issues [OK]
Common Mistakes:
  • Blaming CPU limits for network problems
  • Assuming API server affects pod networking directly
  • Ignoring CNI config correctness
5. You want to deploy a new CNI plugin that supports network policies and IP address management. Which step is NOT required?
hard
A. Restart the Kubernetes API server
B. Create a CNI configuration file in /etc/cni/net.d/
C. Install the CNI plugin binaries on all nodes
D. Ensure kubelet is configured to use the new CNI

Solution

  1. Step 1: Understand CNI plugin deployment steps

    You must install plugin binaries, add config files, and configure kubelet to use it.
  2. Step 2: Identify unnecessary step

    Restarting the Kubernetes API server is not needed for CNI plugin changes.
  3. Final Answer:

    Restart the Kubernetes API server -> Option A
  4. Quick Check:

    API server restart NOT needed for CNI install [OK]
Hint: API server restart not needed when changing CNI [OK]
Common Mistakes:
  • Thinking API server restart is required
  • Forgetting to install plugin binaries
  • Not placing config in correct directory
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard