How kubernetes-sigs/nfs-subdir-external-provisioner works
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}”.