PostgreSQL在Kubernetes上的卷权限错误

时间:2018-08-11 15:35:50

标签: postgresql kubernetes google-kubernetes-engine

我正在尝试在GKE上部署postgres / postgis,但是我继续收到权限错误:initdb: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted。我已经尝试了各种研究过的修复程序,但尚未通过此错误。以下是我的部署Yaml。

我想念什么?

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      terminationGracePeriodSeconds: 10
      securityContext:
        runAsUser: 1000
        fsGroup: 1000
      containers:
        - name: postgres
          image: mdillon/postgis:10
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_DB
              value: "database"
            - name: POSTGRES_USER
              value: "postgres"
            - name: POSTGRES_PASSWORD
              value: "postgres"
          volumeMounts:
            - name: postgredb
              mountPath: /var/lib/postgresql/data
              subPath: data
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pvc

1 个答案:

答案 0 :(得分:2)

虽然问题不完全相同,但这个“使用initContainer:chmod”的答案会让您感兴趣:chown: changing ownership of '/data/db': Operation not permitted