我通过遵循使用 initContainers 的答案.
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,downlineAPI和计划的卷以进行挂载只读,而不是允许应用程序写入数据,然后自动还原.在1.11版之前,设置功能Gate ReadOnlyAPIDataVolumes = false将保留旧的行为.(#58720,@ joelsmith)
Changes secret, configMap, downwardAPI and projected volumes to mount read-only, instead of allowing applications to write data and then reverting it automatically. Until version 1.11, setting the feature gate ReadOnlyAPIDataVolumes=false will preserve the old behavior. (#58720, @joelsmith)
如果要更改从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:只读文件系统
发布评论