问题描述
我通过遵循.
I solved a permission issue when mounting /var/lib/postgresql/data
by following this answer with initContainers
.
现在,我正在尝试将 postgresql.conf
挂载为卷,并且遇到了类似的许可问题,该问题引发了 chown:/var/lib/postgresql/data/postgresql.conf:只读文件系统
.
Now I'm trying to mount postgresql.conf
as a volume, and I'm running into a similar permissioning issue that throws chown: /var/lib/postgresql/data/postgresql.conf: Read-only file system
.
我可能会缺少什么?我已经尝试了很多运气不尽相同的变化.
What could I be missing? I've tried a bunch of different variations with little luck.
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
推荐答案
从kubernetes 1.8开始,configmap只读安装,摘自CHANGELOG-1.8.md:
From kubernetes 1.8 on, configmap is mounted readonly, excerpt from the CHANGELOG-1.8.md:
如果要更改从configmap挂载的文件,可以将其复制到另一个目录,然后进行更新.
If you want to change the file that mounted from the configmap, you can copy it to another directory, then update it.
这篇关于chown:/var/lib/postgresql/data/postgresql.conf:只读文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!