# kubernetes-sigs/nfs-subdir-external-provisioner architecture

> Architecture diagram of the GitHub repository kubernetes-sigs/nfs-subdir-external-provisioner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubernetes-sigs/nfs-subdir-external-provisioner
- Repository: https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner

## Overview

##### Project Type and Purpose
- This is a Kubernetes storage provisioner that leverages an already configured NFS server. Its main purpose is to dynamically provision Kubernetes Persistent Volumes (PVs) when Persistent Volume Claims (PVCs) are created by users.
- The README explains deployment via Helm, Kustomize, or manual YAML application. The project is structured as an “external provisioner” controller written in Go and integrated with Kubernetes.

##### Major Components
a. Provisioner Container and Controller:
– Represent the central control logic (“nfs-client-provisioner” or “nfs-subdir-external-provisioner”) from the code under cmd/nfs-subdir-external-provisioner (provisioner.go). This component is responsible for watching PVC events and provisioning storage.
b. Kubernetes Cluster Components:
– API Server & Scheduler: (implied) that interacts with the provisioner.
– Custom Kubernetes Resources: Include the StorageClass (deploy/class.yaml), RBAC configuration (deploy/rbac.yaml), Deployment manifests (deploy/deployment.yaml), and test resources.
– PVCs and PVs: Indicate that upon PVC creation, the provisioner creates a corresponding PV with a naming convention based on the namespace and PVC name.
c. NFS Server (External Dependency):
– Represent the NFS server as an external resource. This is the storage backend where the provisioner creates subdirectories for each new volume.
d. Build, CI/CD & Packaging:
– Show that the project uses Docker (Dockerfile, Dockerfile.multiarch) and release tools (release-tools, GitHub Actions workflows) for building and publishing container images.
– Include the Helm chart (charts/nfs-subdir-external-provisioner) and Kustomize deployment strategies (deploy/kustomization.yaml), highlighting that multiple deployment distribution methods exist.

##### Relationships and Data Flow
- PVC creation (in Kubernetes) triggers the provisioner.
- The provisioner then communicates with the NFS server (via NFS protocol) to create new directories for storage.
- The provisioner registers the created Persistent Volume with the Kubernetes API.

##### Architectural Patterns and Design Principles
- Controller Pattern: Highlight that the provisioner acts as a controller, constantly reconciling the PV/PVC state.
- Declarative Configuration: The use of YAML manifests, Helm charts, and Kustomize illustrate Kubernetes’ declarative deployment style.
- CI/CD and Multi-Architecture Support: Showcase the integration of GitHub Actions and Docker multi-arch builds which ensure consistent deployment across environments.

##### Final Touches
- Annotations where useful—for example, mention that the naming convention of provisioned volumes uses the format “${namespace}-${pvcName}-${pvName}”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kubernetes Cluster Subgraph
    subgraph "Kubernetes Cluster"
        APIServer["API Server"]:::k8s
        PVCRequest["PVC Creation"]:::k8s
        subgraph "Kubernetes Manifests"
            StorageClass["StorageClass Manifest"]:::k8s
            RBAC["RBAC Configuration"]:::k8s
            DeploymentManifest["Deployment Manifest"]:::k8s
            TestResources["Test Resources"]:::k8s
        end
    end

    %% Provisioner Controller Subgraph
    subgraph "Provisioner"
        ProvisionerController["Provisioner Controller"]:::controller
    end

    %% External Dependency
    NFSServer["External NFS Server"]:::external

    %% Build, CI/CD and Packaging Subgraph
    subgraph "Build & Packaging"
        HelmChart["Helm Chart"]:::build
        KustomizeConfig["Kustomize Config"]:::build
        DockerFiles["Docker Build Files"]:::build
        CICDPipelines["CI/CD Pipelines"]:::build
        MakefileNode["Makefile"]:::build
    end

    %% Relationships and Data Flow
    PVCRequest -->|"PVC_event"| ProvisionerController
    ProvisionerController -->|"Provision_Volume"| NFSServer
    ProvisionerController -->|"Register_PV"| APIServer

    %% Build and Deployment Relationships
    CICDPipelines -->|"builds"| DockerFiles
    CICDPipelines -->|"deploys"| HelmChart
    CICDPipelines -->|"deploys"| KustomizeConfig
    MakefileNode -->|"triggers"| CICDPipelines
    HelmChart -->|"configures"| DeploymentManifest
    KustomizeConfig -->|"configures"| DeploymentManifest

    %% Click Events
    click ProvisionerController "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/cmd/nfs-subdir-external-provisioner/provisioner.go"
    click StorageClass "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/deploy/class.yaml"
    click RBAC "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/deploy/rbac.yaml"
    click DeploymentManifest "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/deploy/deployment.yaml"
    click TestResources "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/deploy/test-claim.yaml"
    click HelmChart "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/charts/nfs-subdir-external-provisioner"
    click KustomizeConfig "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/deploy/kustomization.yaml"
    click DockerFiles "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/Dockerfile"
    click CICDPipelines "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/.github/workflows"
    click MakefileNode "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/Makefile"

    %% Styles
    classDef k8s fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef controller fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#ABEBC6,stroke:#239B56,stroke-width:2px;
    classDef build fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
