I am trying to contact from a customized helm chart to a fully managed Postgres service on azure, and then I have to put the url connection string according to the app I want to deploy.
I want to ask which value should be the DATABASE_URL
at the helm chart deployment?
My situation is the following:
- I want to use an external Azure managed PostgreSQL and no the PostgreSQL container that comes with the helm chart.
So in consequence, I modified the
DATABASE_URL
value, given here to connect to the container inside K8s, I've modified in this way:
name: DATABASE_URL
# value: "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql"
value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"
but I am getting this error
/usr/local/lib/ruby/2.7.0/uri/generic.rb:208:in `initialize': the scheme postgres does not accept registry part: nmbrs@postgresql-nmb-psfc-stag:mypassword*@postgresql-nmb-psfc-stag.postgres.database.azure.com (or bad hostname?) (URI::InvalidURIError)
Which should be the real DATABASE_URL
value if I want to contact to a fully Postgres managed service?
Which is the equivalent value to this?:
value: "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql"
I mean is
postgres//<username>:<my-pg-password>@<WHICH VALUE SHOULD BE HERE?>
What is the value of {{ .Release.Name }}-postgresql"
?
Just for the record, my customize postfacto/deployment/helm/templates/deployment.yaml
is this
UPDATE
I changed the value for this
- name: DATABASE_URL
# value: "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql"
# value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com:5432/postfacto-staging-db"
value: "postgres://postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"
And I got a different error:
Caused by:
PG::ConnectionBad: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username@hostname> format.
FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username@hostname> format.
But is not clear how should be the syntax format since this article says:
Next, encode the database credentials. Use the format DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME. If you are using mysql with a user ‘deploy’ and a password ‘secret’ on 127.0.0.1 and have a database railsapp, run
The format DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME
, it is the same I was using at the beginning
CodePudding user response:
From what I see this helm chart is poorly written, and badly assumes things i.e. the DATABASE_URL has is build to only properly format a kubernetes posgress helm release and nothing else.
What I would suggest:
- Instead of installing this chart on k8s by helm, use
helm template
functionality to locally render the template. - Edit the exported plain manifest, to match your needs
- Go to your Azure DB, and get it
ConnectionString
, depending on how you mange your secrets in k8s, pass it to theDATABASE_URL
environment - Manually apply the manifests
CodePudding user response:
I think the problem with your connection string is, its username has a special character *
, which might be breaking the connection string format and causing the validation error.
Your value
- name: DATABASE_URL
value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"
You can try to do an URL encoding for the username part like
- name: DATABASE_URL
value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"