mirror of
https://codeberg.org/caye/k8s-hostpath-provisioner.git
synced 2026-09-12 19:53:10 +00:00
Simple hostpath provisioner for Kubernetes
- Go 90.9%
- Makefile 6%
- Dockerfile 3.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| deployment/k8s | ||
| .dockerignore | ||
| .gitignore | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| Makefile | ||
| provisioner.go | ||
| provisioner_test.go | ||
| README.md | ||
Kubernetes hostpath provisioner
k8s-hostpath-provisioner is a simple storage provisioner to manage dynamic provisioning in Kubernetes on local storages.
Compatible with Kubernetes 1.35. Built with Go 1.26, k8s.io/client-go v0.35 and sig-storage-lib-external-provisioner v13.
Getting started
You can configure multiple storage classes with different configurations on one parent host path. Each configuration uses its own sub-directory.
Deploy
kubectl apply -f deploy/k8s/rbac.yaml
kubectl apply -f deploy/k8s/deployment.yaml
kubectl apply -f deploy/k8s/storageclass.yaml
The controller creates directories under PROVISIONER_PATH (default /persistentvolumes) on the node. Mount a host path there, for example /var/lib/k8s-hostpath.
Image: codeberg.org/caye/k8s-hostpath-provisioner.
Storage class
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: storage-default
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: cluster.local/k8s-hostpath-provisioner
parameters:
namingStrategy: dynamic # or 'static' to use namespace-PVC without the claim UID
onDelete: delete # 'delete', 'archive', or 'retain'
subPath: default # sub folder under PROVISIONER_PATH
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
WaitForFirstConsumer is recommended for hostPath: the provisioner then pins the PV to the scheduled node via kubernetes.io/hostname affinity.
Environment
| Variable | Default | Description |
|---|---|---|
PROVISIONER_PATH |
/persistentvolumes |
Parent directory for provisioned volumes |
ENABLE_LEADER_ELECTION |
true |
Leader election via coordination.k8s.io leases |
KUBECONFIG |
(in-cluster) | Optional kubeconfig for local runs |
METRICS_PORT |
unset | Prometheus metrics port (e.g. 8080) |
Build
make test vet
make build
make docker