# k8snetworkplumbingwg/sriov-network-device-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/k8snetworkplumbingwg/sriov-network-device-plugin
- Repository: https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin

## Overview

##### Main Components

a. Core Components:
- Device Plugin Manager (central controller)
- Resource Pools Manager
- Device Discovery System
- Device Selector Framework
- Resource Server
- Health Monitor (for link status)

b. External Interfaces:
- Kubernetes Device Plugin API
- Container Runtime Interface
- SR-IOV Network Resources
- CNI Plugin Integration Points
- Container Device Interface (CDI)

##### Key Architectural Elements

a. Resource Management Layer:
**┌─────────────────────────────────────────┐**
- Device Plugin Manager         │
- ┬───────────────────┤
- Resource Pools     │   Device Selector │
- Manager         │     Framework     │
- ┴───────────────────┘

b. Device Discovery and Management:
**┌─────────────────────────────────────────┐**
- Device Discovery System         │
- ┬─────────────┬────────────┤
- SR-IOV VFs │    PCI PFs  │    SFs     │
- ┴─────────────┴────────────┘

##### Integration Points

- Communication with Kubernetes API server
- Integration with CNI plugins (Multus/DANM)
- Interaction with hardware devices
- Resource allocation flow

##### Resource Types
**┌─────────────────────────────────────────┐**
- Supported Device Types          │
- ┬─────────────┬────────────┤
- NetDevice  │ AccelDevice │ AuxNetDev  │
- ┴─────────────┴────────────┘

##### Configuration Flow
**┌─────────────┐    ┌──────────────┐    ┌────────────┐**
- ConfigMap  │ -> │Device Plugin │ -> │  Resource  │
- (JSON)    │    │   Manager    │    │   Pools    │
- ┘    └──────────────┘    └────────────┘

##### Implementation Details

Relationship between:
- Device discovery (/pkg/devices)
- Resource management (/pkg/resources)
- Provider implementations (/pkg/netdevice, /pkg/accelerator, /pkg/auxnetdevice)
- Utility functions (/pkg/utils)

##### Monitoring and Health Checks

Components for:
- Link status monitoring
- Device health checks
- Kubelet restart detection
- Resource updates

- The plugin's modular architecture
- Clear separation of concerns
- Extensibility points
- Resource management workflow
- Integration with Kubernetes ecosystem

This design captures the essence of a Kubernetes device plugin while showing the specific implementations for SR-IOV network resources management.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Resource Management Layer"
        DPM["Device Plugin Manager"]
        RPM["Resource Pools Manager"]
        DSF["Device Selector Framework"]
        RS["Resource Server"]
    end

    subgraph "Device Discovery System"
        DDS["Device Discovery"]
        SRIOV["SR-IOV VFs"]
        PCI["PCI PFs"]
        SF["SFs"]
    end

    subgraph "Device Types"
        ND["NetDevice"]
        AD["AccelDevice"]
        AND["AuxNetDevice"]
    end

    subgraph "Configuration"
        CM["ConfigMap"]
        CDI["CDI Integration"]
    end

    subgraph "Device Providers"
        NDP["NetDevice Provider"]
        ADP["AccelDevice Provider"]
        ANDP["AuxNetDevice Provider"]
    end

    subgraph "External Interfaces"
        K8S["Kubernetes API"]
        CNI["CNI Plugins"]
        CRI["Container Runtime"]
    end

    subgraph "Monitoring"
        HM["Health Monitor"]
        IP["Info Providers"]
    end

    CM --> DPM
    DPM --> RPM
    DPM --> DSF
    DPM --> RS

    DDS --> SRIOV
    DDS --> PCI
    DDS --> SF

    RPM --> ND
    RPM --> AD
    RPM --> AND

    DSF --> NDP
    DSF --> ADP
    DSF --> ANDP

    DPM --> K8S
    DPM --> CNI
    DPM --> CRI

    HM --> DPM
    IP --> DPM

    CDI --> CRI

    %% Click events for component mapping
    click DPM "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/cmd/sriovdp/manager.go"
    click DSF "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/resources/deviceSelectors.go"
    click RS "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/resources/server.go"
    click DDS "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/devices/"
    click ND "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/netdevice/"
    click AD "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/accelerator/"
    click AND "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/auxnetdevice/"
    click CM "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/deployments/configMap.yaml"
    click CDI "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/cdi/cdi.go"
    click NDP "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/netdevice/netDeviceProvider.go"
    click ADP "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/accelerator/accelDeviceProvider.go"
    click ANDP "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/pkg/auxnetdevice/auxNetDeviceProvider.go"
    click IP "https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/infoprovider/"

    %% Styling
    classDef core fill:#2374ab
    classDef external fill:#57a773
    classDef hardware fill:#ff8c42
    classDef config fill:#ffd275
    classDef monitoring fill:#845a6d

    class DPM,RPM,DSF,RS core
    class K8S,CNI,CRI external
    class SRIOV,PCI,SF hardware
    class CM,CDI config
    class HM,IP monitoring
```
