gpt4 book ai didi

postgresql - kubernetes : saving users and settings in a volume 上的 Pgadmin4

转载 作者:行者123 更新时间:2023-12-02 12:09:40 24 4
gpt4 key购买 nike

我想将用户帐户和其他设置保存在 pgadmin4 k8s 实例的卷中,我这样做了:

    apiVersion: apps/v1
kind: Deployment
metadata:
name: pgadmin
namespace: pgadmin
spec:
selector:
matchLabels:
app: pgadmin
replicas: 1
template:
metadata:
labels:
app: pgadmin
spec:
containers:
- name: pgadmin4
image: dpage/pgadmin4
env:
- name: PGADMIN_DEFAULT_EMAIL
value: "admin@example.com"
- name: PGADMIN_DEFAULT_PASSWORD
value: "mysecpwd"
- name: PGADMIN_PORT
value: "80"
ports:
- containerPort: 80
name: pgadminport
volumeMounts:
- mountPath: /
name: pgadmin-storage

volumes:
- name: pgadmin-storage
persistentVolumeClaim:
claimName: pgadmin-pv-claim
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: pgadmin-pv-volume
namespace: pgadmin
labels:
type: local
app: pgadmin
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pgadmin-pv-claim
namespace: pgadmin
labels:
app: pgadmin
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi

问题是当我重新启动 pod 时,即使 pv 绑定(bind)到 pod,创建的用户也会消失,我不确定这部分:

              volumeMounts:
- mountPath: /
name: pgadmin-storage

我想我必须指定保存用户信息和设置的目录,我尝试了默认目录 /pgadmin4 但 pod 崩溃了。

最佳答案

根据@Wytrzymały的回答,我检查了用helm创建的deployment,发现正确的mountPath/var/lib/pgadmin,section应该是像这样:

      ...
volumeMounts:
- mountPath: /var/lib/pgadmin
name: pgadmin-storage
...

另一件事是我必须更改该目录的所有者以便应用程序可以写入它,为此我使用了 InitContainers (pgadmin uid = 5050):

...
spec:
initContainers:
- name: volume-mount-hack
image: busybox
command: ["sh", "-c", "chown -R 5050:5050 /var/lib/pgadmin"]
volumeMounts:
- name: pgadmin-storage
mountPath: /var/lib/pgadmin
....

希望对大家有帮助

关于postgresql - kubernetes : saving users and settings in a volume 上的 Pgadmin4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64223555/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com