I have a yml file where I create a pvc on my provider (digital ocean)

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: test-pvc namespace: test spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: do-block-storage 

I am also using a helm chart and want to be able to point to the already created pvc How can I do this? This helm chart is deployed after the PVC is already created/deployed

 master: persistence: enabled: true ## mariadb data Persistent Volume Storage Class ## If defined, storageClassName: <storageClass> ## If set to "-", storageClassName: "", which disables dynamic provisioning ## If undefined (the default) or set to null, no storageClassName spec is ## set, choosing the default provisioner. (gp2 on AWS, standard on ## GKE, AWS & OpenStack) ## # storageClass: "-" accessMode: ReadWriteOnce size: 10Gi 
2

1 Answer

To mount your PVC in your helm chart, do this:

  • Disable persistence volume creation in helm chart
master: persistence: enabled: false #Setting it to false 

Something like this:

apiVersion: v1 kind: Pod metadata: name: task-pv-pod spec: volumes: - name: task-pv-storage persistentVolumeClaim: claimName: test-pvc # pointing to existing test-pvc containers: - name: task-pv-container image: nginx ports: - containerPort: 80 name: "http-server" volumeMounts: - mountPath: "/usr/share/nginx/html" name: task-pv-storage 

Update:

Specifically in your case, you can specify your pvc name against existingClaim parameter in values.yaml, it will be picked up by your deployment.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.