【发布时间】:2019-01-23 21:11:43
【问题描述】:
我解决了安装/var/lib/postgresql/data 时的权限问题,方法是关注this answer 和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
【问题讨论】:
标签: postgresql kubernetes google-kubernetes-engine