在部署PostgreSQL的时候遇到了权限不足的问题

chmod: changing permissions of ‘/var/lib/postgresql/data’: Permission denied

设置NFS目录权限的时候指定no_root_squash权限

echo “NFS目录 *(rw,sync,no_root_squash)” >> /etc/exports

这里写图片描述

如果不行也可以试试下面的方法:
在创建Pod,绑定mountPath 时加上:Z
PostgreSQL文档

You can also set the following mount points by passing the -v /host/dir:/container/dir:Z flag to Docker.

例如:

--- 
apiVersion: v1
kind: ReplicationController
metadata: 
  name: postgres
spec: 
  replicas: 1
  template: 
    metadata: 
      labels: 
        app: postgres
    spec: 
      containers: 
        - env: 
            - name: POSTGRES_USER
              value: kong
            - name: POSTGRES_PASSWORD
              value: kong
            - name: POSTGRES_DB
              value: kong
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
          image: "postgres:9.4"
          name: postgres
          ports: 
            - containerPort: 5432
          volumeMounts: 
            - mountPath: /var/lib/postgresql/data:Z
              name: pg-data
      volumes: 
        - name: pg-data
          persistentVolumeClaim:
          claimName: pg-data    
Logo

开源、云原生的融合云平台

更多推荐