Hey Guys, I have setup drone on a kubernetes cluster with the google cloud console and everything is working fine using the local sqllite database. I want to connect drone to a database that persists between resets of the kubernetes pod, so of course I want to connect drone to either a mysql or postgres database.
I thought this would be a straightforward change, I followed the guide, set the appropriate environment variables, but I consistently get the following error message from the pod:
To eliminate kubernetes as the culprit I created a docker compose (see below) and tested the issue locally. I received the same error message as I did on the cluster:
I do see some configuration issues that would explain the error messages. I definitely recommend the docker-compose networking documentation as a primer.
Pinging the database only fails when there is an issue with the connection string or network configuration. In this case, it looks like the network is configured correctly, but the address used in the connection string is the root cause.
You won’t be able to connect to the postgres container using 0.0.0.0 from inside the drone container, because containers have isolated networks. You need to connect to the postgres container using its actual IP address, which is discoverable by hostname.
Below is a sample connection string that we use in our unit tests, which I can confirm works. Note that we use the container hostname, postgres, to resolve the postgres container IP address.
You also won’t be able to connect to the postgres container using port 1000 from inside the drone container. Postgres is going to be available at postgres:5432 on the default bridge network that is created by docker-compose. Port 1000 is only available from the host machine network.
I also meant to attach a sample configuration. I just tested this locally to confirm it works, so you can use it as a reference. This should in turn help to eliminate drone as the culprit