Skip to content

Instantly share code, notes, and snippets.

@dnegi-dev
Last active August 27, 2023 10:24
Show Gist options
  • Save dnegi-dev/2e5f0184231967a46118acd971f9c92f to your computer and use it in GitHub Desktop.
Save dnegi-dev/2e5f0184231967a46118acd971f9c92f to your computer and use it in GitHub Desktop.
Mount a Openstack Cinder Volume in Kubernetes

How to mount a already existing Volume in K8s with the openstack cloud controler

1) check out the id of the volume

openstack_volume

its the ID Value

Create a PV with the following settings

apiVersion: v1
kind: PersistentVolume
metadata:
  name: <PV-Name>
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: <Capacity-of-the-openstack-volume e.g.: "10Gi">
  csi:
    driver: cinder.csi.openstack.org
    volumeHandle: <Volume-ID>
  persistentVolumeReclaimPolicy: Retain
  storageClassName: csi-sc-cinderplugin
  volumeMode: Filesystem

Create a PVC which uses the created PV

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: <Name of the PVC>
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: <Same as the PV before>
  volumeName: <Name of the previously created PV>

End

Apply both files and then enter the PVC inside the Deployment you want to use in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment