Postgresql 用于PgAdmin的Kubernetes持久卷装载
我正在尝试为我的pgadmin部署创建一个持久的卷声明,以便在每次从CD管道部署后推出更新时可以持久化我的设置、服务器等 在我的日志中,我发现以下错误:Postgresql 用于PgAdmin的Kubernetes持久卷装载,postgresql,kubernetes,pgadmin,Postgresql,Kubernetes,Pgadmin,我正在尝试为我的pgadmin部署创建一个持久的卷声明,以便在每次从CD管道部署后推出更新时可以持久化我的设置、服务器等 在我的日志中,我发现以下错误: ... [2020-10-05 00:54:56 +0000] [91] [INFO] Worker exiting (pid: 91) WARNING: Failed to set ACL on the directory containing the configuration database: [Errno 1]
...
[2020-10-05 00:54:56 +0000] [91] [INFO] Worker exiting (pid: 91)
WARNING: Failed to set ACL on the directory containing the configuration database:
[Errno 1] Operation not permitted: '/var/lib/pgadmin'
HINT : You may need to manually set the permissions on
/var/lib/pgadmin to allow pgadmin to write to it.
ERROR : Failed to create the directory /var/lib/pgadmin/sessions:
[Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
HINT : Create the directory /var/lib/pgadmin/sessions, ensure it is writeable by
'pgadmin', and try again, or, create a config_local.py file
and override the SESSION_DB_PATH setting per
https://www.pgadmin.org/docs/pgadmin4/4.26/config_py.html
只是一堆写入权限失败:
PGAdmin部署
apiVersion:apps/v1
种类:部署
元数据:
姓名:pgadmin
规格:
选择器:
火柴标签:
app:pgadmin
副本:1份
模板:
元数据:
标签:
app:pgadmin
规格:
容器:
-姓名:pgadmin4
图片:dpage/pgadmin4
体积数量:
-装载路径:/var/lib/pgadmin
名称:pgadminstorage
环境:
-名称:PGADMIN\u默认\u电子邮件
价值来源:
secretKeyRef:
名称:联合国
关键词:联合国
-名称:PGADMIN\u默认\u密码
价值来源:
secretKeyRef:
姓名:pw
键:pw
-名称:PGADMIN_端口
值:“80”
端口:
-集装箱港口:80
名称:pgadminport
卷数:
-名称:pgadminstorage
persistentVolumeClaim:
claimName:pgadmin持久卷声明
卷
我会错过什么
更新:
这可能是digitalocean特有的问题,并且无法设置权限。PVC会将perms设置为root,但以pgadmin的身份编写会在启动时引起问题,将此添加到我的pgadmin部署中修复了所有问题
initContainers:
- name: pgadmin-data-permission-fix
image: busybox
command: ["/bin/chown", "-R", "5050:5050", "/var/lib/pgadmin"]
volumeMounts:
- name: pgadminstorage
mountPath: /var/lib/pgadmin
您也可以在dir上使用chmod recursive,这样也很好。我已经复制了您的问题。根本原因在于问题,而不是库伯内特斯。吊舱将毫无问题地部署。您将收到错误,因为容器无法在文件夹
/var/lib
中创建文件夹。如果您检查pgadmin
pod日志-kubectl日志
,您将看到以下错误:
$ kubectl logs pgadmin-d569b67fd-8rnkc
WARNING: Failed to set ACL on the directory containing the configuration database:
[Errno 1] Operation not permitted: '/var/lib/pgadmin'
HINT : You may need to manually set the permissions on
/var/lib/pgadmin to allow pgadmin to write to it.
ERROR : Failed to create the directory /var/lib/pgadmin/sessions:
[Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
HINT : Create the directory /var/lib/pgadmin/sessions, ensure it is writeable by
'pgadmin', and try again, or, create a config_local.py file
and override the SESSION_DB_PATH setting per
https://www.pgadmin.org/docs/pgadmin4/4.26/config_py.html
sudo: setrlimit(RLIMIT_CORE): Operation not permitted
如果您要检查/var/lib/
文件夹权限,则您将认为您只能读取
和执行
,因此您将无法在此文件夹中创建任何内容(默认情况下,您将以pgadmin
用户身份登录)
根据你的需要,你可以用几种方法来解决它。作为最快的解决方法,您只需更改允许写入的文件夹路径,如tmp
drwxrwxrwt 1 root root 4096 Oct 5 14:28 tmp
在YAML
中,它看起来像:
containers:
- name: pgadmin4
image: dpage/pgadmin4
volumeMounts:
- mountPath: /var/tmp/pgadmin
name: pgadminstorage
当您检查日志时,不会出现任何问题
$ kubectl logs pgadmin-6bb74cffb8-6q9tr
NOTE: Configuring authentication for SERVER mode.
sudo: setrlimit(RLIMIT_CORE): Operation not permitted
[2020-10-05 14:28:15 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2020-10-05 14:28:15 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
[2020-10-05 14:28:15 +0000] [1] [INFO] Using worker: threads
/usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
return io.open(fd, *args, **kwargs)
[2020-10-05 14:28:15 +0000] [89] [INFO] Booting worker with pid: 89
user@cloudshell:~/pgadmin (project)$
关于PgAdmin
权限问题,已经有一些关于StackOverflow
或Github
的主题,如:
简而言之,您可以尝试手动更改权限或使用特定用户
此外,如果您使用的是云环境,您可以考虑使用,而不是尝试将数据库放到云中。例如,带有GKE的PostgreSQL
编辑
根据此答案下方的@Ryan注释,您还可以使用更改/var/lib/
权限。每个init容器
必须在下一个容器启动之前成功完成,并在pod
中的应用容器之前运行
在Pod中的应用程序容器之前运行的专用容器。Init容器可以包含应用程序映像中不存在的实用程序或设置脚本
你需要提供更多的细节。是您的本地环境还是云环境?由于您只有
PVC
我假设您想要使用动态资源调配
。如果没有,请提供您的PV
。您是否也可以分享您的storageclass
?感谢您的回复。我会接受这个答案,尽管我通过运行initContainer脚本来修改var lib admin上的perms,然后再将任何内容写入该dir,现在一切都好了。将更新我的答复。
containers:
- name: pgadmin4
image: dpage/pgadmin4
volumeMounts:
- mountPath: /var/tmp/pgadmin
name: pgadminstorage
$ kubectl logs pgadmin-6bb74cffb8-6q9tr
NOTE: Configuring authentication for SERVER mode.
sudo: setrlimit(RLIMIT_CORE): Operation not permitted
[2020-10-05 14:28:15 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2020-10-05 14:28:15 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
[2020-10-05 14:28:15 +0000] [1] [INFO] Using worker: threads
/usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
return io.open(fd, *args, **kwargs)
[2020-10-05 14:28:15 +0000] [89] [INFO] Booting worker with pid: 89
user@cloudshell:~/pgadmin (project)$