如何使用pvc创建postgres掌舵图 [英] how to create helm chart of postgres with pvc
问题描述
我想为具有PVC(持久卷声明)的PostgreSQL创建一个舵图.
I would like to create a helm chart for PostgreSQL with PVC (persistent volume claim).
我看过尝试katacoda https://www.katacoda. com/courses/kubernetes/helm-package-manager 用pvc创建Postgres掌舵图.
I've looked at trying katacoda https://www.katacoda.com/courses/kubernetes/helm-package-manager Create Postgres helm chart with pvc.
我该怎么办?
推荐答案
我们可以从 PostgreSQL 掌舵图表文档,可以与以下参数一起使用:
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 | {} |
+----------------------------+-----------------------------------------------------------------+---------------+
持久性
默认情况下,数据使用PostgreSQL状态集中的PVC模板保留.您可以禁用将
persistence.enabled
参数设置为false
的持久性. Kubernetes集群中需要默认的StorageClass
来动态配置卷.在persistence.storageClass
中指定另一个StorageClass,或者如果已经存在要使用的永久卷,则设置persistence.existingClaim
.
Persistence
The data is persisted by default using PVC templates in the PostgreSQL statefulset. You can disable the persistence setting the
persistence.enabled
parameter tofalse
. A defaultStorageClass
is needed in the Kubernetes cluster to dynamically provision the volumes. Specify another StorageClass in thepersistence.storageClass
or setpersistence.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
一旦部署并限制了边界,就可以安装PostgreSQL图表:
Once those are deployed and bounded you can install the PostgreSQL chart:
helm install my-release bitnami/postgresql --set persistence.existingClaim=task-pv-claim
这篇关于如何使用pvc创建postgres掌舵图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!