reactive-tech / kubegres

Kubegres is a Kubernetes operator allowing to deploy one or many clusters of PostgreSql instances and manage databases replication, failover and backup.
https://www.kubegres.io
Apache License 2.0
1.32k stars 74 forks source link

Primary Postgres Crashes Upon Starting #61

Closed ghost closed 3 years ago

ghost commented 3 years ago

I am following the getting-started guide: https://www.kubegres.io/doc/getting-started.html I am following it word for word, step by step. No changes whatsoever.

I am running Kubernetes locally Bare Metal. The storageClass I am using is nfs-client (default) and I have it working with other pods and I have it basically wide open: *(rw,sync,no_subtree_check,no_root_squash) Kubernetes version: v1.22.2 Docker Container Runtime: docker://20.10.8

I am tailing the logs of the first pod mypostgres-1-0 and it gets as far as this and then it seems to crash. kubectl logs mypostgres-1-0 -f

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.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ...

After the last line I am back in my terminal and no longer following the logs. I look at the pods and see it has a restart count of 1.

NAME                                               READY   STATUS                  RESTARTS        AGE
mypostgres-1-0                                     1/1     Running                 1 (2m30s ago)   4m56s
mypostgres-2-0                                     0/1     Init:CrashLoopBackOff   4 (24s ago)     2m18s

Since it automatically restarts and there is already data in /var/lib/postgresql/data/, none of the initialization scripts will ever run.

No idea why this is happening. Any help would be appreciated.

alex-arica commented 3 years ago

Thank you for your message.

This type of error happens when the provisioner does not support dynamic provisioning. Kubegres specifies in a StatefulSet a storage class name and the wanted size of the volume. It does not do anything else. Then the StatefulSet uses the storage class which dynamically creates PV and PVC.

I suggest you check Kubernetes documentation about this issue.