sixeyed / kiamol

Learn Kubernetes in a Month of Lunches
Creative Commons Attribution Share Alike 4.0 International
306 stars 224 forks source link

initdb: directory "/var/lib/postgresql/data" exists but is not empty It contains a lost+found directory, perhaps due to it being a mount point. Using a mount point directly as the data directory is not recommended. Create a subdirectory under the mount point. #72

Closed ifduyue closed 1 month ago

ifduyue commented 1 month ago

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: directory "/var/lib/postgresql/data" exists but is not empty It contains a lost+found directory, perhaps due to it being a mount point. Using a mount point directly as the data directory is not recommended. Create a subdirectory under the mount point. Stream closed EOF for default/todo-list-db-64c7587854-m68bt (db)

ifduyue commented 1 month ago

Fixed by setting PGDATA env var to a subfoler like this:

--- a/ch12/todo-list/helm/v1/todo-list/templates/todo-db-deployment.yaml
+++ b/ch12/todo-list/helm/v1/todo-list/templates/todo-db-deployment.yaml
@@ -19,6 +19,8 @@ spec:
           env:
           - name: POSTGRES_PASSWORD_FILE
             value: /secrets/postgres_password
+            name: PGDATA
+            value: /var/lib/postgresql/data/pgdata