Watch
0
Fork
You've already forked k8s-hostpath-provisioner
0
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%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-12 19:28:33 +02:00
.forgejo/workflows Update Kaniko action to v1.0.1 in build workflow 2026-09-11 23:33:54 +02:00
deployment/k8s Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
.dockerignore Switch Kaniko workflow to use actions/checkout for local context, fixing Codeberg git clone issues 2026-09-11 21:58:42 +02:00
.gitignore Switch Kaniko workflow to use actions/checkout for local context, fixing Codeberg git clone issues 2026-09-11 21:58:42 +02:00
Dockerfile Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
go.mod Update dependencies in go.mod and go.sum, including library version upgrades and cleanup of unused modules 2026-09-12 19:28:33 +02:00
go.sum Update dependencies in go.mod and go.sum, including library version upgrades and cleanup of unused modules 2026-09-12 19:28:33 +02:00
LICENSE Initial commit 2021-05-18 00:52:56 +02:00
main.go Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
Makefile Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
provisioner.go Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
provisioner_test.go Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00
README.md Update Dockerfile, Makefile, and tests; improve build, CI, and provisioner functionalities 2026-09-11 21:37:36 +02:00

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