{"id":19838526,"url":"https://github.com/metal-stack/csi-lvm","last_synced_at":"2025-04-09T07:06:53.929Z","repository":{"id":40409133,"uuid":"216034641","full_name":"metal-stack/csi-lvm","owner":"metal-stack","description":"kubernetes csi for bare metal deployments, uses local storage","archived":false,"fork":false,"pushed_at":"2025-03-13T01:11:35.000Z","size":357,"stargazers_count":85,"open_issues_count":9,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T08:44:00.705Z","etag":null,"topics":["bare-metal","csi","csi-lvm","kubernetes","lvm","lvm2","persistent-volumes","storage-provider"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metal-stack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-18T13:50:30.000Z","updated_at":"2025-03-25T16:33:29.000Z","dependencies_parsed_at":"2024-06-18T23:01:14.942Z","dependency_job_id":"db3a6f09-08eb-4111-bb0f-b60df09c92e5","html_url":"https://github.com/metal-stack/csi-lvm","commit_stats":{"total_commits":98,"total_committers":8,"mean_commits":12.25,"dds":0.4693877551020408,"last_synced_commit":"d5d506a6b9c61658bdd5b4625dfe1ad2e5955d26"},"previous_names":["metal-pod/csi-lvm"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fcsi-lvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fcsi-lvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fcsi-lvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fcsi-lvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metal-stack","download_url":"https://codeload.github.com/metal-stack/csi-lvm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bare-metal","csi","csi-lvm","kubernetes","lvm","lvm2","persistent-volumes","storage-provider"],"created_at":"2024-11-12T12:18:03.528Z","updated_at":"2025-04-09T07:06:53.913Z","avatar_url":"https://github.com/metal-stack.png","language":"Go","readme":"# CSI LVM Provisioner\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/metal-stack/csi-lvm)](https://goreportcard.com/report/github.com/metal-stack/csi-lvm)\n\n## Overview\n\nThis driver is replaced by [csi-driver-lvm](https://github.com/metal-stack/csi-driver-lvm), all further development happens there\n\nCSI LVM Provisioner utilizes local storage of Kubernetes nodes to provide persistent storage for pods.\n\nIt automatically creates `hostPath` based persistent volumes on the nodes and makes use of the [Local Persistent Volume feature](https://kubernetes.io/blog/2018/04/13/local-persistent-volumes-beta/) introduced by Kubernetes 1.10 but it's simpler to use than the built-in `local` volume feature in Kubernetes.\n\nUnderneath it creates a LVM logical volume on the local disks. A grok pattern, which disks to use can be specified.\n\nThis Provisioner is derived from the [Local Path Provisioner](https://github.com/rancher/local-path-provisioner).\n\n## Compare to Local Path Provisioner\n\n### Pros\n\nDynamic provisioning the volume using host path.\n\n* Currently the Kubernetes [Local Volume provisioner](https://github.com/kubernetes-incubator/external-storage/tree/master/local-volume) cannot do dynamic provisioning for the host path volumes.\n* Support for volume capacity limit.\n* Performance speedup if more than one local disk is available because it can create lv´s which are stripe across all physical volumes.\n\n## Requirement\n\nKubernetes v1.12+.\n\n## Deployment\n\n### Installation\n\nThe deployments consists of two parts:\n\n* A controller deployment, which is registerd as storage controller and schedules the creation and deletion of volumes\n* A reviver daemonset, which is responsible for re-creating the mount-structure after a reboot\n\nIn this setup, the directory `/tmp/csi-lvm/\u003cname of the pv\u003e` will be used across all the nodes as the path for provisioning (a.k.a, store the persistent volume data). The provisioner will be installed in `csi-lvm` namespace by default.\n\nThe default grok pattern for disks to use is `/dev/nvme[0-9]n*`, please check if this matches your setup, otherwise, copy *controller.yaml* to your local machine and modify the value of `CSI_LVM_DEVICE_PATTERN` accordingly.\n\n```yaml\n- name: CSI_LVM_DEVICE_PATTERN\n  value: /dev/nvme[0-9]n*\"\n```\n\nIf this is set you can install the csi-lvm with:\n\n```bash\nkubectl apply -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/deploy/controller.yaml\nkubectl apply -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/deploy/reviver.yaml\n\n```\n\nAfter installation, you should see something like the following:\n\n```bash\n$ kubectl -n csi-lvm get pod\nNAME                                     READY     STATUS    RESTARTS   AGE\ncsi-lvm-controller-d744ccf98-xfcbk       1/1       Running   0          7m\ncsi-lvm-reviver-ndh46                    1/1       Running   0          7m\n```\n\nCheck and follow the provisioner log using:\n\n```bash\n$ kubectl -n csi-lvm logs -f csi-lvm-controller-d744ccf98-xfcbk\nI1021 14:09:31.108535       1 main.go:132] Provisioner started\nI1021 14:09:31.108830       1 leaderelection.go:235] attempting to acquire leader lease  csi-lvm/metal-stack.io-csi-lvm...\nI1021 14:09:31.121305       1 leaderelection.go:245] successfully acquired lease csi-lvm/metal-stack.io-csi-lvm\nI1021 14:09:31.124339       1 controller.go:770] Starting provisioner controller metal-stack.io/csi-lvm_csi-lvm-controller-7f94749d78-t5nh8_17d2f7ef-1375-4e36-aa71-82e237430881!\nI1021 14:09:31.126248       1 event.go:258] Event(v1.ObjectReference{Kind:\"Endpoints\", Namespace:\"csi-lvm\", Name:\"metal-stack.io-csi-lvm\", UID:\"04da008c-36ec-4966-a4f6-c2028e69cdd5\", APIVersion:\"v1\", ResourceVersion:\"589\", FieldPath:\"\"}): type: 'Normal' reason: 'LeaderElection' csi-lvm-controller-7f94749d78-t5nh8_17d2f7ef-1375-4e36-aa71-82e237430881 became leader\nI1021 14:09:31.225917       1 controller.go:819] Started provisioner controller metal-stack.io/csi-lvm_csi-lvm-controller-7f94749d78-t5nh8_17d2f7ef-1375-4e36-aa71-82e237430881!\n```\n\n## Usage\n\nCreate a `hostPath` backed Persistent Volume and a pod uses it:\n\n```bash\nkubectl create -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pvc.yaml\nkubectl create -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pod.yaml\n```\n\nYou should see the PV has been created:\n\n```bash\n$ kubectl get pv\nNAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                    STORAGECLASS   REASON    AGE\npvc-bc3117d9-c6d3-11e8-b36d-7a42907dda78   50Mi       RWO            Delete           Bound     default/lvm-pvc          csi-lvm                  4s\n```\n\nThe PVC has been bound:\n\n```bash\n$ kubectl get pvc\nNAME             STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE\nlvm-pvc          Bound     pvc-bc3117d9-c6d3-11e8-b36d-7a42907dda78   50Mi       RWO            csi-lvm        16s\n```\n\nAnd the Pod started running:\n\n```bash\n$ kubectl get pod\nNAME          READY     STATUS    RESTARTS   AGE\nvolume-test   1/1       Running   0          3s\n```\n\nWrite something into the pod\n\n```bash\nkubectl exec volume-test -- sh -c \"echo lvm-test \u003e /data/test\"\n```\n\nNow delete the pod using\n\n```bash\nkubectl delete -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pod.yaml\n```\n\nAfter confirm that the pod is gone, recreated the pod using\n\n```bash\nkubectl create -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pod.yaml\n```\n\nCheck the volume content:\n\n```bash\n$ kubectl exec volume-test cat /data/test\nlvm-test\n```\n\nDelete the pod and pvc\n\n```bash\nkubectl delete -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pvc.yaml\nkubectl delete -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/example/pod.yaml\n```\n\nThe volume content stored on the node will be automatically cleaned up. You can check the log of `csi-lvm-controller-xxx` for details.\n\nNow you've verified that the provisioner works as expected.\n\n## Configuration\n\nThe configuration of the csi-lvm-controller is done via Environment variables:\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: csi-lvm-controller\n  namespace: csi-lvm\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: csi-lvm-controller\n  template:\n    metadata:\n      labels:\n        app: csi-lvm-controller\n    spec:\n      serviceAccountName: csi-lvm-controller\n      containers:\n      - name: csi-lvm-controller\n        image: ghcr.io/metal-stack/csi-lvm-controller:v0.6.3\n        imagePullPolicy: IfNotPresent\n        command:\n        - /csi-lvm-controller\n        args:\n        - start\n        env:\n        - name: CSI_LVM_PROVISIONER_NAMESPACE\n          valueFrom:\n            fieldRef:\n              fieldPath: metadata.namespace\n        - name: CSI_LVM_PROVISIONER_IMAGE\n          value: \"ghcr.io/metal-stack/csi-lvm-provisioner:v0.6.3\"\n        - name: CSI_LVM_DEVICE_PATTERN\n          value: \"/dev/loop[0,1]\"\n---\napiVersion: apps/v1\nkind: DaemonSet\nmetadata:\n  name: csi-lvm-reviver\n  namespace: csi-lvm\nspec:\n  selector:\n    matchLabels:\n      app: csi-lvm-reviver\n  template:\n    metadata:\n      labels:\n        app: csi-lvm-reviver\n    spec:\n      serviceAccountName: csi-lvm-reviver\n      containers:\n      - name: csi-lvm-reviver\n        image: ghcr.io/metal-stack/csi-lvm-provisioner:v0.6.3\n        imagePullPolicy: IfNotPresent\n        securityContext:\n          privileged: true\n        env:\n          - name: CSI_LVM_MOUNTPOINT\n            value: \"/tmp/csi-lvm\"\n        command:\n        - /csi-lvm-provisioner\n        args:\n        - revivelvs\n        volumeMounts:\n          - mountPath: /tmp/csi-lvm\n            name: data\n            mountPropagation: Bidirectional\n          - mountPath: /dev\n            name: devices\n          - mountPath: /lib/modules\n            name: modules\n      volumes:\n        - hostPath:\n            path: /tmp/csi-lvm\n            type: DirectoryOrCreate\n          name: data\n        - hostPath:\n            path: /dev\n            type: DirectoryOrCreate\n          name: devices\n        - hostPath:\n            path: /lib/modules\n            type: DirectoryOrCreate\n          name: modules\n\n```\n\n### Definition\n\n`CSI_LVM_DEVICE_PATTERN` is a grok pattern to specify which block devices to use for lvm devices on the node. This can be for example `/dev/sd[bcde]` if you want to use only /dev/sdb - /dev/sde.\n***IMPORTANT***: no wildcard (*) allowed currently.\n\n### PVC Striped, Mirrored\n\nBy default the LV´s are created in `linear` mode on the devices specified by the grok pattern, beginning on the first found device. If this is full, the next LV will be created on the next device and so forth.\n\nIf more than 1 device was found with the given pattern, two more options for the created lvs are available:\n\n* `mirror`: all block will be mirrored with one additional copy to a additional disk found if more than one disk is present.\n* `striped`: the pvc will be a stripe across all found block devices specified by the above grok pattern. If for example 4 disk where found, all blocks written are spread across 4 devices in chunks. This gives ~4 times the read/write performance for the volume, but also a 4 times higher risk of data loss in case a single disk fails.\n\n```yaml\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: lvm-pvc\n  namespace: default\nspec:\n  accessModes:\n    - ReadWriteOnce\n  storageClassName: csi-lvm\n  resources:\n    requests:\n      storage: 50Mi\n```\n\n```yaml\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: lvm-pvc-striped\n  namespace: default\n  annotations:\n    csi-lvm.metal-stack.io/type: \"striped\"\nspec:\n  accessModes:\n    - ReadWriteOnce\n  storageClassName: csi-lvm\n  resources:\n    requests:\n      storage: 50Mi\n```\n\n```yaml\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: lvm-pvc-mirrored\n  namespace: default\n  annotations:\n    csi-lvm.metal-stack.io/type: \"mirror\"\nspec:\n  accessModes:\n    - ReadWriteOnce\n  storageClassName: csi-lvm\n  resources:\n    requests:\n      storage: 50Mi\n```\n\n## Uninstall\n\nBefore un-installation, make sure the PVs created by the provisioner have already been deleted. Use `kubectl get pv` and make sure no PV with StorageClass `csi-lvm`.\n\nTo uninstall, execute:\n\n```bash\nkubectl delete -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/deploy/controller.yaml\nkubectl delete -f https://raw.githubusercontent.com/metal-stack/csi-lvm/master/deploy/reviver.yaml\n```\n\n## Migration\n\nIf you want to migrate your existing PVC to / from csi-driver-lvm, you can use [korb](https://github.com/BeryJu/korb).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetal-stack%2Fcsi-lvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetal-stack%2Fcsi-lvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetal-stack%2Fcsi-lvm/lists"}