我正在为 Postgres9.6 连接设置 SSL。我无法在具有适当权限的 Kubernetes secret 中安装 SSH 私钥和证书。我相信如果没有在 Kubernetes 容器上设置任何明确的用户 ID,安装的 secret 应该由 root 拥有。我已经为八进制 0640
设置了 416
十进制。如果文件由 root 拥有,这是 Postgres 的建议。
感谢任何帮助。
错误:
FATAL: could not load private key file "/var/lib/postgresql/certs/server.key": Permission denied
Helm statefulset 配置:
volumes:
- name: {{ .Values.certs_secret.volume_name }}
secret:
secretName: {{ .Values.certs_secret.secret_name }}
items:
- key: server.key
path: server.key
mode: 416
- key: server.crt
path: server.crt
mode: 511
containers:
- name: {{ .Chart.Name }}
args:
- -c
- ssl=on
- -c
- ssl_cert_file={{ .Values.certs_secret.cert_path }}
- -c
- ssl_key_file={{ .Values.certs_secret.private_key_path }}
volumeMounts:
- name: {{ .Values.certs_secret.volume_name }}
mountPath: {{ .Values.certs_secret.mount_path }}
已更新
我在没有打开 SSL 的情况下执行了,发现 secret 文件被挂载为符号链接(symbolic link)。这可能是个问题吗?群集在 AKS 中。
root@postgres-timescale-db-0:/var/lib/postgresql/certs# find . -ls
2 0 drwxrwxrwt 3 root root 120 Oct 29 16:40 .
8 0 lrwxrwxrwx 1 root root 31 Oct 29 16:40 ./..data -> ..2019_10_29_16_40_00.233198123
7 0 lrwxrwxrwx 1 root root 17 Oct 29 16:40 ./server.crt -> ..data/server.crt
6 0 lrwxrwxrwx 1 root root 17 Oct 29 16:40 ./server.key -> ..data/server.key
3 0 drwxr-xr-x 2 root root 80 Oct 29 16:40 ./..2019_10_29_16_40_00.233198123
5 8 -rwxrwxrwx 1 root root 4450 Oct 29 16:40 ./..2019_10_29_16_40_00.233198123/server.crt
4 4 -rw-r----- 1 root root 1679 Oct 29 16:40 ./..2019_10_29_16_40_00.233198123/server.key
最佳答案
postgres 以什么用户身份运行 - root 还是其他用户?一些 Docker 镜像使用 postgres
,uid
为 999...
在没有完整的部署配置的情况下,我建议您在了解用户后查看 this doc了解如何配置 securityContext
以设置挂载卷中的目录和文件的所有权。
关于postgresql - 为 Postgres 的 SSL 安装 SSH key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58595594/