Hello,
I’m facing an issue while deploying PostgreSQL in multiple namespaces on AWS EFS, which is being used as part of our SaaS (Software as a Service) application infrastructure. We chose AWS EFS because of its ability to provide scalable, persistent, and shared storage across multiple instances, which is essential for our application’s architecture.
Here’s the situation:
Initial Deployment (First Time):
When I deploy PostgreSQL for the first time in the namespace, everything works correctly. The Persistent Volumes (PV) and Persistent Volume Claims (PVC) are created properly, and there are no issues.
Second Deployment (Subsequent Deployments):
For subsequent deployments, I always run into the CrashLoopBackOff error.
The logs show the following error:
fixing permissions on existing directory /bitnami/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
2025-03-25 10:57:32.317 UTC [103] FATAL: data directory "/bitnami/postgresql/data" has wrong ownership
2025-03-25 10:57:32.317 UTC [103] HINT: The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/bitnami/postgresql/data"
running bootstrap script ...
I've ensured that the securityContext with fsGroup: 1001 is added to the deployment configuration.
I checked the ownership and permissions of the /bitnami/postgresql/data directory in the EFS volume, but it seems that the PostgreSQL container is still unable to start due to ownership issues.
Questions:
-
Is there something I am missing regarding the file system permissions for EFS in a multi-namespace setup?
-
What are the best practices for ensuring proper ownership when using EFS with PostgreSQL containers in Kubernetes?
-
How can I avoid this error and successfully deploy PostgreSQL in multiple namespaces on EFS?
Thanks for sharing ismail