Kubernetes 中的持久化存储不会持久化数据

鲁特网

在我的 Kubernetes 集群中,在我的数据库容器上,如果 pod 被删除,我的持久性存储(在 Digital Ocean 上动态配置)不会持久化存储。

我已将存储的回收策略从删除更改为保留,但这并没有什么区别。

这是 DB YAML 文件的副本:

apiVersion: v1
kind: Service
metadata:
  name: db
  namespace: hm-namespace01
    app: app1
spec:
  type: NodePort
  ports:
   - port: 5432
  selector:
   app: app1

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: hm-pv-claim
  namespace: hm-namespace01
  labels:
    app: app1
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: do-block-storage

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1
  namespace: hm-namespace01
  labels:
    app: app1
spec:
  selector:
    matchLabels:
      app: app1
      tier: backend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: app1
        tier: backend
    spec:
      containers:
        - name: app1
          image: postgres:11
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          volumeMounts:
          - name: postgredb
            mountPath: /var/lib/postgresql

      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: hm-pv-claim
爱德华多·拜泰洛

您必须将您的mountPath与 PostgresPGDATA环境变量相匹配

默认值PGDATA/var/lib/postgresql/data(不/var/lib/postgresql)。

您需要调整mountPath或设置PGDATAenv 以匹配它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章