Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
Error de permiso de volumen de Postgres en Azure Kubernetes

Estoy tratando de implementar Postgresql en Azure Kubernetes con persistencia de datos. Así que estoy usando PVC. Busqué muchas publicaciones aquí, la mayoría de ellas ofrecían archivos yaml como a continuación, pero está dando el error a continuación;

 chmod: changing permissions of '/var/lib/postgresql/data/pgdata': Operation not permitted The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. initdb: error: could not change permissions of directory "/var/lib/postgresql/data/pgdata": Operation not permitted fixing permissions on existing directory /var/lib/postgresql/data/pgdata ...

el archivo yaml de implementación está debajo;

 apiVersion: apps/v1 kind: Deployment metadata: name: postgresql spec: replicas: 1 selector: matchLabels: app: postgresql template: metadata: labels: app: postgresql spec: containers: - name: postgresql image: postgres:13.2 securityContext: runAsUser: 999 imagePullPolicy: "IfNotPresent" ports: - containerPort: 5432 envFrom: - secretRef: name: postgresql-secret volumeMounts: - mountPath: /var/lib/postgresql/data name: postgredb-kap volumes: - name: postgredb-kap persistentVolumeClaim: claimName: postgresql-pvc

Yaml secreto está debajo;

 apiVersion: v1 kind: Secret metadata: name: postgresql-secret type: Opaque data: POSTGRES_DB: a2V5sd4= POSTGRES_USER: cG9zdGdyZXNhZG1pbg== POSTGRES_PASSWORD: c234Rw== PGDATA: L3Za234dGF0YQ==

Los archivos pvc y sc yaml se encuentran a continuación:

 kind: PersistentVolumeClaim apiVersion: v1 metadata: name: postgresql-pvc labels: app: postgresql spec: storageClassName: postgresql-sc accessModes: - ReadWriteOnce resources: requests: storage: 5Gi --- allowVolumeExpansion: true apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: postgresql-sc mountOptions: - dir_mode=0777 - file_mode=0777 - uid=1000 - gid=1000 parameters: skuName: Standard_LRS provisioner: kubernetes.io/azure-file reclaimPolicy: Retain

Entonces, cuando uso la ruta de montaje como " - mountPath: /var/lib/postgresql/ ", está funcionando. Puedo llegar a la base de datos y es bueno. Pero cuando elimino el pod y lo vuelvo a crear, ¡no hay DB! Así que no hay persistencia de datos.

¿Puedes ayudarme, qué me estoy perdiendo aquí?

¡Gracias!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Una cosa que podría intentar es cambiar uid=1000,gid=1000 en las opciones de montaje a 999, ya que este es el uid del usuario de postgres en el contenedor de postgres (no probé esto).


Otra solución que seguramente resolverá este problema involucra los contenedores init.

El contenedor de Postgres requiere comenzar como raíz para poder chown pgdata dir ya que está montado como directorio raíz. Después de hacer esto, elimina los permisos de root y se ejecuta como usuario de postgres.

Pero puede usar el contenedor de inicio (que se ejecuta como root) para modificar el directorio de volumen para que pueda ejecutar el contenedor principal como no root.

Aquí hay un ejemplo:

 initContainers: - name: init image: alpine command: ["sh", "-c", "chown 999:999 /var/lib/postgresql/data"] volumeMounts: - mountPath: /var/lib/postgresql/data name: postgredb-kap
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!