Attach existing volume into postgres slave using helm

3/25/2020

This are the two yml file that I created for both master and slave

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: db-disk-master
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 5Gi

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: db-disk-slave
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 5Gi

This is the command I used to install postgress

helm install postgresql-db \
  --set persistence.existingClaim="db-disk-master"\
  --set replication.slaveReplicas=1 \
  --set replication.enabled=true \
  --values <(echo '{
      "slave": {
        "extraVolumes": [
          {
            "name": "db-disk-slave"
          }
        ]
      }
   }') \
  bitnami/postgresql -n development

But when executing this in the slave node create a new volume and attaching to it without using the "db-disk-slave" volume. I want to attched the slave node into "db-disk-slave" without creating a new volume

-- Padmasankha
azure-aks
azure-kubernetes
kubernetes
kubernetes-helm
kubernetes-pod

1 Answer

3/26/2020

For the Slave pod, the HELM chart allows you to set the PVC correct

{{- if .Values.slave.extraVolumes }}
        {{- toYaml .Values.slave.extraVolumes | nindent 8 }}
        {{- end }}

to problem is in the content of the extraVolume variable

volumes: - name: volume persistentVolumeClaim: claimName: db-disk-slave

this will allow the slave pod to receive a volume form an existing PVC

Hoping to helps you out, let me know if you would have any more questions

REF:

https://github.com/helm/charts/blob/master/stable/postgresql/templates/statefulset-slaves.yaml#L271-L273

https://docs.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv#use-the-persistent-volume

Additional from below comment:

--values <(echo '{
"slave": {
"extraVolumes": [
{
"name": "db-disk-slave"
}
]
}
}')

this needs to be updated to

--values <(echo '{
"slave": {
"extraVolumes": [
{
"name": "volume",
"persistentVolumeClaim": { "claimName":  "db-disk-slave" }
}
]
}
}')

look at the reference documents https://docs.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv#use-the-persistent-volume

-- Joe Mellin
Source: StackOverflow