chown:/var/lib/postgresql/data/postgresql.conf:只读文件系统

问题描述 投票:0回答:1

我通过跟随/var/lib/postgresql/datathis 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
1个回答
3
投票

从kubernetes 1.8开始,configmap以只读方式挂载,摘自CHANGELOG-1.8.md:

更改secret,configMap,upwardAPI和预计卷以挂载只读,而不是允许应用程序写入数据然后自动还原。在版本1.11之前,设置要素门ReadOnlyAPIDataVolumes = false将保留旧行为。 (#58720,@ joelsmith)

如果要更改从configmap挂载的文件,可以将其复制到另一个目录,然后进行更新。

© www.soinside.com 2019 - 2024. All rights reserved.