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

Issue with Kubegres cluster deployment #145

Open rrpatil7279 opened 1 year ago

rrpatil7279 commented 1 year ago

Hello,

I need your help to troubleshoot the following issue I am facing with the Kubegres deployment.

I have a K8S environment having 2 nodes, 1 Master & 1 Worker. I followed the instructions to deploy the Kubegres-controller and it is up & running. I am trying to deploy the Postgres Cluster with 2 replicas. Primary Pod is up & running however Secondary Pod is getting into the error. Looking at the logs I figured out that the “replication” role & user is not created by the Primary Pod hence Secondary Pod is not able to connect and is failing. I am using the base config and I can see that the .sh files are mounted successfully on Primary Pod but unable to figure out why it did not execute .sh? Please help.

k get pods NAME READY STATUS RESTARTS AGE ssodb-1-0 1/1 Running 0 10m ssodb-2-0 0/1 Init:CrashLoopBackOff 6 (2m15s ago) 10m

< -- Copied form ssodb-1-0 Pod description -- > Mounts: /docker-entrypoint-initdb.d/primary_create_replication_role.sh from base-config (rw,path="primary_create_replication_role.sh") /docker-entrypoint-initdb.d/primary_init_script.sh from base-config (rw,path="primary_init_script.sh") /etc/pg_hba.conf from base-config (rw,path="pg_hba.conf") /etc/postgres.conf from base-config (rw,path="postgres.conf") /var/lib/postgresql/data from postgres-db (rw) /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-dcnfz (ro) < -- end -- >

k logs ssodb-2-0 -c setup-replica-data-directory 20/01/2023 05:32:05 - Attempting to copy Primary DB to Replica DB... ls: cannot access '/var/lib/postgresql/data/pgdata': No such file or directory 20/01/2023 05:32:05 - Copying Primary DB to Replica DB folder: /var/lib/postgresql/data/pgdata 20/01/2023 05:32:05 - Running: pg_basebackup -R -h ssodb -D /var/lib/postgresql/data/pgdata -P -U replication; pg_basebackup: error: connection to server at "ssodb" (192.168.191.126), port 5432 failed: FATAL: password authentication failed for user "replication"

am4am5 commented 1 year ago

Hi, rrpatil7279,

I have the same issue after editing the secret, containing passwords with kubectl edit or trying to create it from YAML.

Try to make yor secret with kubectl create like this:

kubectl create secret generic <secret_name> \
    --from-literal=<name1>='<password1>' \
    --from-literal=<name2>='<password2>'