last day (16 days later) » 

1:41 PM
0
Q: Unable to connect to postgres dockerized in Kubernetes from Windows

Guy GrinI'm using a Windows host to run a Postgres docker container in Kubernetes. Since my laptop is Windows, I'm using Docker-Desktop... This is my K8s yaml file: kind: Namespace apiVersion: v1 metadata: name: sample-namespace --- kind: PersistentVolume apiVersion: v1 metadata: name: db-pv name...

 
The database password is set once when the database is created, i.e. when you have started the container for the first time. After that the database is read from the volume mounts. You have most likely changed the database password in the secrets after the initial creation if the database.
 
Thanks @MSpiller. Any idea what I should change in my yaml files?
 
There is nothing wrong with the YAML files. The database password has changed between creation and usage. Either you use the correct password or you recreate the database with the new password.
 
How can I go about doing that? The same issue still happens even after I delete the namespace and PersistentVolume @MSpiller
 
What is the password stored in the secret vs. the password you use to connect?
 
1:41 PM
@MSpiller I'm using db_password. It should be in the secret
 
Have you tried to empty path /data/db-pv on your host and restart?
 
Hey @MSpiller, I'm not really sure how to do it. i need to find the related path in my Windows. I did try something else - I purged all of my K8s and redeployed everything. It's now failing on the db not answering the psql calls which looks like a network issue
 
Any errors in the log of the db container?
 
2:02 PM
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 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
(sample-python-project) λ psql -h localhost -U db_user --password -p 5432 -d sample-db
Password:
psql: error: connection to server at "localhost" (::1), port 5432 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
db
No other errors.. now it seems like the connection isn't working
This is what I have on the service:
(sample-python-project) λ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
db-service LoadBalancer 10.96.220.248 <pending> 5432:30760/TCP 5m48s
 
The LoadBalancer has no ingress IP assigned. It says <pending>.
How is your k8s setup? Where should it get an IP from?
 
 
1 hour later…
3:34 PM
Great catch! I will dig into this
 
4:13 PM
@MSpiller I managed to get the EXTERNAL-IP to change to localhost via restart but I still get the same error
 

  last day (16 days later) »