How openebs/lvm-localpv works
Purpose and Runtime
OpenEBS Local PV LVM is a Go-based Kubernetes CSI plugin that provisions node-local Persistent Volumes backed by Linux LVM logical volumes. It is control-plane only: Kubernetes workloads consume host-local block devices or mounted filesystems; LVM2 performs the underlying volume operations. Primary binary entry point: cmd/main.go.
CSI Driver Boundary
The driver implements CSI identity, controller, and node-facing services, accepts gRPC CSI requests, and coordinates Kubernetes/LVM actions. Driver setup, service registration, controller behavior, and node agent behavior are centered in:
• pkg/driver/driver.go
• pkg/driver/grpc.go
• pkg/driver/controller.go
• pkg/driver/agent.go
The CSI controller initiates provisioning; node-side execution owns host-specific operations and volume publication.
Kubernetes Custom Resources and Reconciliation
The repository defines LVMVolume, LVMSnapshot, and LVMNode CRDs as the asynchronous contract between controller decisions and node-local execution:
• pkg/apis/openebs.io/lvm/v1alpha1/lvmvolume.go
• pkg/apis/openebs.io/lvm/v1alpha1/lvmsnapshot.go
• pkg/apis/openebs.io/lvm/v1alpha1/lvmnode.go
Generated clientsets, informers, and listers provide Kubernetes API access/watch machinery under pkg/generated/. CRD installation is delivered through deploy/helm/charts/charts/crds/templates/.
Volume Provisioning Flow
A PVC-driven CSI CreateVolume request is handled by the controller, which selects eligible topology/node capacity and creates an LVMVolume CR. The node volume manager watches that CR, creates/configures the LV locally, and updates status; CSI then returns/uses the resulting volume identity. Core stages:
• Controller and scheduling support: pkg/driver/controller.go, pkg/driver/schd_helper.go
• Volume reconciler/manager: pkg/mgmt/volume/start.go, pkg/mgmt/volume/volume.go
• Volume CR construction: pkg/builder/volbuilder/volume.go
Deletion and expansion follow the same controller-to-CR-to-node pattern. Responses for create, delete, resize, and snapshots are separated in pkg/response/.
Node LVM and Publish Operations
Node-local logic is the boundary to the host Linux environment: LVM command/utilities manage VGs/LVs, while mount and volume code expose filesystem or raw-block volumes to kubelet. This layer also supports thin provisioning, resize, and I/O limiting:
• pkg/lvm/volume.go
• pkg/lvm/mount.go
• pkg/lvm/lvm_util.go
• pkg/lvm/iolimiter_cgroup.go
The required external substrate is a Kubernetes node with local disks, Linux kernel LVM support, LVM2, and kubelet CSI integration. Volumes remain bound to the hosting node; the system provides no replication/dataplane.
Snapshot and Node Capacity Management
Snapshot requests create LVMSnapshot resources and are fulfilled locally by the snapshot manager. Node discovery/capacity reporting is managed through LVMNode resources. Collectors inspect local PV/VG/LV state for capacity and metrics:
• pkg/mgmt/snapshot/start.go
• pkg/mgmt/snapshot/snapshot.go
• pkg/mgmt/lvmnode/start.go
• pkg/collector/vg_collector.go
Deployment and Operations
Helm deploys the CSI controller and node DaemonSet, RBAC, CSI driver registration, monitoring resources, and CRDs:
• deploy/helm/charts/templates/lvm-controller.yaml
• deploy/helm/charts/templates/lvm-node.yaml
• deploy/helm/charts/templates/lvm-node-service.yaml
• deploy/helm/charts/values.yaml
CI builds and publishes container artifacts through GitHub Actions, notably .github/workflows/build_and_push.yml and .github/workflows/release.yml.
Components 17
Deployment
- Helm chart · Installs controller, node DaemonSet, RBAC, registration, and monitoring.
deploy/helm/charts/values.yaml - CRD templates
- CSI controller
deploy/helm/charts/templates/lvm-controller.yaml - CSI node agent · Runs node-local CSI and reconciliation on each eligible node.
deploy/helm/charts/templates/lvm-node.yaml
CSI Driver
- Plugin binary
cmd/main.go - CSI gRPC driver · Registers identity, controller, and node CSI services.
pkg/driver/grpc.go - CSI controller · Handles create, delete, expand, and snapshot requests.
pkg/driver/controller.go - CSI node service · Publishes local volumes through kubelet CSI calls.
pkg/driver/agent.go
CR Reconciliation
- LVMVolume · Asynchronous contract for local volume lifecycle work.
pkg/apis/openebs.io/lvm/v1alpha1/lvmvolume.go - LVMSnapshot · Asynchronous contract for local snapshots.
pkg/apis/openebs.io/lvm/v1alpha1/lvmsnapshot.go - LVMNode · Publishes node-local LVM capacity and state.
pkg/apis/openebs.io/lvm/v1alpha1/lvmnode.go - Volume manager · Watches LVMVolume resources and performs local lifecycle actions.
pkg/mgmt/volume/start.go - Snapshot manager
pkg/mgmt/snapshot/start.go - VG capacity collector · Inspects local PV, VG, and LV state for LVMNode reporting.
pkg/collector/vg_collector.go
Node LVM Operations
- LVM and mount layer · Creates, resizes, mounts, and limits local logical volumes.
pkg/lvm/volume.go - Linux node and LVM2 · Provides local disks, kernel LVM support, and LVM2 commands.
Other components
- Kubernetes API and kubelet · Supplies CSI requests, CR storage/watch, and node publication integration.
Connections 23
- Helm chart → CSI controller: deploys
- Helm chart → CSI node agent: deploys
- CRD templates → LVMVolume: installs
- CRD templates → LVMSnapshot: installs
- CRD templates → LVMNode: installs
- CSI controller → Plugin binary: runs
- CSI node agent → Plugin binary: runs
- Plugin binary → CSI gRPC driver: initializes
- CSI gRPC driver → CSI controller: routes controller RPCs
- CSI gRPC driver → CSI node service: routes node RPCs
- Kubernetes API and kubelet → CSI gRPC driver: CSI gRPC requests
- CSI controller → LVMVolume: creates and updates
- CSI controller → LVMSnapshot: creates and updates
- CSI controller → LVMNode: reads capacity
- Volume manager → LVMVolume: watches and updates
- Snapshot manager → LVMSnapshot: watches and updates
- VG capacity collector → LVMNode: reports capacity
- Volume manager → LVM and mount layer: provisions and resizes
- Snapshot manager → LVM and mount layer: creates snapshots
- CSI node service → LVM and mount layer: mounts and publishes
- LVM and mount layer → Linux node and LVM2: LVM2 and mount operations
- Kubernetes API and kubelet → Volume manager: CR watch API
- Kubernetes API and kubelet → Snapshot manager: CR watch API