# k8snetworkplumbingwg/multus-cni architecture

> Architecture diagram of the GitHub repository k8snetworkplumbingwg/multus-cni, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k8snetworkplumbingwg/multus-cni
- Repository: https://github.com/k8snetworkplumbingwg/multus-cni

## Overview

##### Project Type and Purpose
- The project is an open-source Kubernetes networking tool. Its primary purpose is to allow multiple network interfaces to be attached to pods, with support for both the “thin” (traditional) and “thick” (client/server) plugin deployments.
- The README highlights that the thick plugin includes two binaries—multus-daemon and multus-shim—adding extra features (e.g., metrics) compared to the thin plugin.

##### Analyzing the File Structure
- Top-level directories like cmd, deployments, docs, e2e, examples, and pkg show clear separations of concerns.
- The cmd directory includes various executable binaries (e.g., multus, multus-daemon, multus-shim, kubeconfig_generator), indicating different entry points or modes of operation.
- The pkg directory houses the core libraries and functionalities such as networking utilities, logging, Kubernetes client integrations, and server logic.
- The deployments folder contains Kubernetes deployment manifests (daemonsets for multus in its different modes) which show how the binaries are deployed onto cluster nodes.
- e2e tests and examples drive integration and usage demos.
- Presence of GitHub workflows and release configurations indicate robust CI/CD and build practices.

##### Specific Elements
- “Kubernetes API Server”
- “Default CNI Plugin” (pod network)
- “Multus Thin Plugin” (if using the traditional deployment)
- “Multus Thick Plugin” with two subcomponents: “multus-daemon” and “multus-shim”
- “External CNI Plugins” which are invoked by Multus.
- Utility components (deployment scripts, testing frameworks, build pipelines)
- Data flow and configuration request paths from the API Server to Multus components.
- The delegation flow from the Multus meta-plugin to the selected external CNI plugins.

##### Final Advice
- Detail how the “thick plugin” implementation splits responsibilities between the daemon (acting as a local agent with advanced features like metrics) and the shim (acting as the intermediary that interacts with the container runtime and network plugins).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        API["Kubernetes API Server"]:::external
        DefCNI["Default CNI Plugin (Pod Network)"]:::service
    end

    %% Multus Plugin Core
    subgraph "Multus Plugin Core"
        Thin["Multus Thin Plugin"]:::plugin
        subgraph "Thick Plugin"
            Daemon["multus-daemon"]:::pluginThick
            Shim["multus-shim"]:::pluginThick
        end
    end

    %% Support Components
    subgraph "Support Components (pkg)"
        K8sClient["K8s Client (pkg/k8sclient)"]:::lib
        KubeletClient["Kubelet Client (pkg/kubeletclient)"]:::lib
        Netutils["Netutils (pkg/netutils)"]:::lib
        Logging["Logging (pkg/logging)"]:::lib
        Server["Server (pkg/server)"]:::lib
    end

    %% Auxiliary Tools
    subgraph "Auxiliary Tools (cmd)"
        KubeConfigGen["Kubeconfig Generator"]:::cli
        Installer["Multus Installer"]:::cli
    end

    %% Deployment and Testing
    subgraph "Deployment & Testing"
        Deployments["Deployment Manifests"]:::deploy
        E2ETests["End-to-End Tests"]:::test
        CICD["CI/CD Workflows"]:::deploy
    end

    %% External CNI Plugins
    ExternalCNI["External CNI Plugins"]:::external

    %% Connections between components
    API -->|"configures"| Thin
    API -->|"configures"| Daemon
    DefCNI -->|"primary-network"| Thin
    Thin -->|"delegates-to"| ExternalCNI
    Daemon -->|"delegates-to"| ExternalCNI
    Shim -->|"communicates-with"| Daemon

    Thin -- "uses" --> K8sClient
    Thin -- "uses" --> KubeletClient
    Thin -- "uses" --> Netutils
    Thin -- "uses" --> Logging
    Thin -- "uses" --> Server

    Daemon -- "uses" --> K8sClient
    Daemon -- "uses" --> Logging
    Daemon -- "uses" --> Server

    Shim -- "uses" --> KubeletClient
    Shim -- "uses" --> Logging

    KubeConfigGen -->|"generates-config"| API
    Installer -->|"deploys"| Deployments
    CICD -->|"triggers-builds"| Deployments
    E2ETests -->|"validates"| Deployments

    %% Styling Classes
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef service fill:#bbf,stroke:#333,stroke-width:2px;
    classDef plugin fill:#bfb,stroke:#333,stroke-width:2px;
    classDef pluginThick fill:#dfd,stroke:#333,stroke-width:2px;
    classDef lib fill:#ff9,stroke:#333,stroke-width:2px;
    classDef cli fill:#9ff,stroke:#333,stroke-width:2px;
    classDef deploy fill:#fdd,stroke:#333,stroke-width:2px;
    classDef test fill:#fdf,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click Deployments "https://github.com/k8snetworkplumbingwg/multus-cni/tree/master/deployments/"
    click Thin "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/cmd/multus/main.go"
    click Daemon "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/cmd/multus-daemon/main.go"
    click Shim "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/cmd/multus-shim/main.go"
    click K8sClient "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/pkg/k8sclient/k8sclient.go"
    click KubeletClient "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/pkg/kubeletclient/kubeletclient.go"
    click Netutils "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/pkg/netutils/netutils.go"
    click Logging "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/pkg/logging/logging.go"
    click Server "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/pkg/server/server.go"
    click KubeConfigGen "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/cmd/kubeconfig_generator/main.go"
    click Installer "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/cmd/install_multus/main.go"
    click E2ETests "https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/e2e/README.md"
    click CICD "https://github.com/k8snetworkplumbingwg/multus-cni/tree/master/.github/workflows/"
```
