> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lab Solution Explore CNI optional

> Lab walkthrough inspecting kubelet container runtime and CNI setup, locating CNI binaries, identifying missing plugin, and confirming flannel and portmap are configured and invoked by kubelet.

In this short lab we inspect the kubelet service and the CNI configuration on the control-plane host to answer these questions:

* Which container runtime endpoint is configured for kubelet?
* Where are the CNI plugin binaries stored?
* Which of the candidate plugins is not present on the host?
* Which CNI plugin is configured for the cluster?
* Which CNI plugin binary will kubelet invoke after creating a container and its namespaces?

***

## 1) Inspect the kubelet service to find the container runtime endpoint

Locate the kubelet process and inspect its command-line flags. Prefer `ps aux` (not `ps -aux`) to follow best practice.

```bash theme={null}
controlplane ~ ➜ ps aux | grep -i kubelet | grep -v grep
root       4312  0.0  0.0 3865156 98512 ?      Ssl  01:05   0:09 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --container-runtime-endpoint=unix:///var/run/containerd/containerd.sock --pod-infra-container-image=registry.k8s.io/pause:3.9
```

Answer: The kubelet's container runtime endpoint is `unix:///var/run/containerd/containerd.sock` (i.e., containerd).

<Callout icon="lightbulb" color="#1CB2FE">
  The kubelet flag `--container-runtime-endpoint` points to the CRI socket that kubelet uses to communicate with the container runtime. In this environment kubelet is configured to use containerd via `unix:///var/run/containerd/containerd.sock`.
</Callout>

***

## 2) Path containing all CNI plugin binaries

On many distributions the standard path for CNI plugin binaries is `/opt/cni/bin`. List the directory to see which plugins are installed:

```bash theme={null}
controlplane /opt/cni/bin ➜ ls
bandwidth  dhcp       firewall    host-device  ipvlan  macvlan  ptp     static  vlan
bridge     dummy      flannel     host-local   loopback portmap  sbr     tuning  vrf
```

Answer: `/opt/cni/bin`

***

## 3) Which plugin from the candidate list is not available on the host?

From the `ls` output above, common plugins such as `vlan`, `bridge`, `dhcp`, `flannel`, and `portmap` are present. The vendor-specific `cisco` plugin is not present in `/opt/cni/bin`.

Answer: `cisco` (not available)

***

## 4) Which CNI plugin is configured for this Kubernetes cluster?

Check the CNI configuration directory to find the active config or conflist:

```bash theme={null}
controlplane /opt/cni/bin ➜ ls /etc/cni/net.d/
10-flannel.conflist
```

Inspect the conflist to see the plugin chain and order of execution:

```json theme={null}
controlplane /etc/cni/net.d ➜ cat 10-flannel.conflist
{
  "name": "cbr0",
  "cniVersion": "0.3.1",
  "plugins": [
    {
      "type": "flannel",
      "delegate": {
        "hairpinMode": true,
        "isDefaultGateway": true
      }
    },
    {
      "type": "portmap",
      "capabilities": {
        "portMappings": true
      }
    }
  ]
}
```

Answer: The cluster is configured to use `flannel` as the primary plugin, with `portmap` as a delegate plugin.

***

## 5) Which binary will be run by kubelet after a container and its namespaces are created?

CNI conflists define the plugin execution order. Kubelet (through the CNI library) invokes the plugin binaries from the binaries directory (`/opt/cni/bin`) in the same order they appear in the conflist.

Answer: `/opt/cni/bin/flannel` will be executed first, followed by `/opt/cni/bin/portmap`.

***

## Quick summary

| Question | Answer |
| - | - |
| Kubelet container runtime endpoint | `unix:///var/run/containerd/containerd.sock` |
| Path containing CNI plugin binaries | `/opt/cni/bin` |
| Candidate plugin missing on the host | `cisco` |
| Configured CNI plugin for the cluster | `flannel` (with `portmap` as delegate) |
| Plugin binaries invoked by kubelet (execution order) | `/opt/cni/bin/flannel`, then `/opt/cni/bin/portmap` |

***

## Links and references

* [Kubernetes: Kubelet](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/)
* [CNI Project: Specifications](https://github.com/containernetworking/cni/blob/main/SPEC.md)
* [Flannel GitHub](https://github.com/flannel-io/flannel)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/cka-certification-course-certified-kubernetes-administrator/module/44bc9a9f-319c-40ee-babd-0f7b53a70de7/lesson/e407aade-4765-44a3-a873-e44b25b5864d" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.