Mik*_*ike 1 postgresql kubernetes google-kubernetes-engine
/var/lib/postgresql/data我通过遵循此答案解决了安装时的权限问题initContainers。
现在我尝试postgresql.conf作为卷安装,并且遇到了类似的权限问题,抛出chown: /var/lib/postgresql/data/postgresql.conf: Read-only file system.
我可能会错过什么?我尝试了很多不同的变体,但运气不佳。
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: postgres
labels:
app: postgres
spec:
serviceName: postgres
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: postgres
spec:
terminationGracePeriodSeconds: 10
initContainers:
- name: chmod-er
image: busybox:latest
command:
- /bin/chown
- -R
- '0'
- /var/lib/postgresql/data
volumeMounts:
- name: postgredb
mountPath: /var/lib/postgresql/data
- name: pg-config
mountPath: /var/lib/postgresql/data/postgresql.conf
subPath: postgresql.conf
containers:
- name: postgres
image: mdillon/postgis:10-alpine
ports:
- containerPort: 5432
volumeMounts:
- name: postgredb
mountPath: /var/lib/postgresql/data
subPath: data
- name: pg-config
mountPath: /var/lib/postgresql/data/postgresql.conf
subPath: postgresql.conf
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pvc
- name: pg-config
configMap:
name: pg-config
items:
- key: postgresql.conf
path: postgresql.conf
Run Code Online (Sandbox Code Playgroud)
从 kubernetes 1.8 开始,configmap 被只读挂载,摘自 CHANGELOG-1.8.md:
将 Secret、configMap、downAPI 和投影卷更改为只读安装,而不是允许应用程序写入数据然后自动恢复。在版本 1.11 之前,设置功能门 ReadOnlyAPIDataVolumes=false 将保留旧行为。(#58720,@joelsmith)
如果要更改从configmap挂载的文件,可以将其复制到另一个目录,然后更新它。
| 归档时间: |
|
| 查看次数: |
5852 次 |
| 最近记录: |