【发布时间】:2021-04-28 15:09:35
【问题描述】:
我在 OpenShift 上部署了一个 postgres pod 和一个我认为我正确连接的 PVC,但我可能错了。这是我的 PVC,它已正确绑定 -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: xxxxx
我创建了带有 PGDATA env 设置为 /var/lib/postgresql/pgdata 的 postgres pod,并像这样安装了 PVC -
oc set volume dc/postgres --add --name=postgres-pvc --type=persistentVolumeClaim \
--claim-name=postgres-pvc --mount-path=/var/lib/postgresql/pgdata --containers=postgres
我最初尝试通过覆盖原始容器卷将 PVC 附加到 /var/lib/postgresql/data,但它说存在问题,例如直接安装到 data 文件夹路径,所以这就是我使用 pgdata 的原因。
oc set volume dc/postgres --add --overwrite --name=postgres-volume-1 --type=persistentVolumeClaim \
--claim-name=postgres-pvc --mount-path=/var/lib/postgresql/data --containers=postgres
我现在遇到的错误是当我尝试通过 DC 扩大 pod/添加副本时,它会出现以下错误 -
Unable to attach or mount volumes: unmounted volumes=[postgres-pvc], unattached volumes=[postgres-volume-1 postgres-pvc postgres-token-h7jvr]: timed out waiting for the condition
和
Error while attaching the device pv pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b cannot be attached to the node xx.xx.xxx.xx. Error: PV pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b is already attached to another node xx.xx.xxx.x and there are active pods [postgres-7-6p6sz] using that
是因为我的 PVC 安装不正确吗?还是我需要创建一个新的 PVC,然后手动将新的 pod 更新为新创建的 PVC?
【问题讨论】:
标签: postgresql docker kubernetes openshift kubernetes-pvc