fix: set PostgreSQL SSL options in django #4550
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're attempting to deploy Label Studio to GCP using the official Helm chart but it's unable to connect to Cloud SQL with SSL.
These are the values we're using:
(replaced the real IP with
1.2.3.4
)These are the logs from the k8s pod:
When the pod runs the wait for db script on startup it's able to connect to the database successfully with SSL:
However when it continues to start the django app we get an error:
It seems django is trying to connect to the database without SSL which is blocked by our Cloud SQL configuration because it requires a client certificate.
Looking at the django settings it seems the app is not using the
POSTGRE_*
environment variables to set the SSL options when connecting to PostgreSQL. This is a little surprising as there's documentation etc. for this feature, so perhaps there's something we've missed?This pull request updates the django settings to use those environment variables where available. I've tested this PR in our cluster and the django app is able to connect to the database, and the app starts successfully.