how to create helm chart of postgres with pvc

前端 未结 2 1745
说谎
说谎 2021-01-22 21:09

I would like to create a helm chart for PostgreSQL with PVC (persistent volume claim).

I\'ve looked at trying katacoda https://www.katacoda.com/courses/kubernetes/helm-pa

2条回答
  •  执笔经年
    2021-01-22 22:07

    As we can read from PostgreSQL helm charts docs it can be used with following parameters:

    +----------------------------+-----------------------------------------------------------------+---------------+
    |         Parameter          |                           Description                           |    Default    |
    +----------------------------+-----------------------------------------------------------------+---------------+
    | persistence.enabled        | Enable data persistence                                         | true          |
    | persistence.existingClaim  | Use a existing PVC which must be created manually before bound  | nil           |
    | persistence.storageClass   | Specify the storageClass used to provision the volume           | nil           |
    | persistence.mountPath      | Path to mount data volume at                                    | nil           |
    | persistence.accessMode     | Access mode of data volume                                      | ReadWriteOnce |
    | persistence.size           | Size of data volume                                             | 8Gi           |
    | persistence.annotations    | Persistent Volume Claim annotations                             | {}            |
    +----------------------------+-----------------------------------------------------------------+---------------+
    

    Persistence

    The data is persisted by default using PVC templates in the PostgreSQL statefulset. You can disable the persistence setting the persistence.enabled parameter to false. A default StorageClass is needed in the Kubernetes cluster to dynamically provision the volumes. Specify another StorageClass in the persistence.storageClass or set persistence.existingClaim if you have already existing persistent volumes to use.

    This means you just need to create your own Persistent Volume which can for example look like this:

    pv.yaml

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: task-pv-volume
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 10Gi
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/data"
    

    pvc.yaml

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: task-pv-claim
    spec:
      storageClassName: manual
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 8Gi
    

    Once those are deployed and bounded you can install the PostgreSQL chart:

    helm install my-release bitnami/postgresql --set persistence.existingClaim=task-pv-claim

提交回复
热议问题