I have set up Postgres in Kubernetes (k3s administered with Rancher) which seems to be working fine but in order to take a look at the databases I tried to add a pgadmin4 pod.
I first tried adding the image dpage/pgadmin4
without any additional configuration (except for the a node port from port 80 and the PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD env var), got the error below and tried a few things since then:
- set PGADMIN_LISTEN_ADDRESS env var to
0.0.0.0
in case IPv6 is not supported - add a volume mount (from longhorn) for /var/lib/pgadmin
The pod is failing to start with the following log messages:
NOTE: Configuring authentication for SERVER mode.
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
[2022-03-30 08:27:31 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2022-03-30 08:27:31 +0000] [1] [ERROR] Retrying in 1 second.
[2022-03-30 08:27:32 +0000] [1] [ERROR] Retrying in 1 second.
[2022-03-30 08:27:33 +0000] [1] [ERROR] Retrying in 1 second.
[2022-03-30 08:27:34 +0000] [1] [ERROR] Retrying in 1 second.
[2022-03-30 08:27:35 +0000] [1] [ERROR] Retrying in 1 second.
[2022-03-30 08:27:36 +0000] [1] [ERROR] Can't connect to ('0.0.0.0', 80)
There seem to be two things wrong:
- the sudo error, which results from pgadmin4 starting with userid 5050 but I don't know how to solve this
- gunicorn not being able to listen on port 80
I am not very familiar with Kubernetes so I just don't know which options I have to fix this.
Thanks in advance for any help.
After troubleshooting this myself, on Kubernetes with Rancher, I've found that you'll need an init container to get started. This can be tricky from the UI but you have to go out to the workloads section to get to it. (Click the ellipses). Make sure to mount your pgadmin volume in specific place, for the sake of sanity we'll call it /var/lib/pgadmin
Use the image busybox and run the command:
Then you'll also want to set the environment variable for the deployment to something higher than 1024, I chose 5050, using the environment variable: