<p>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.</p>
<p>I want to ask which value should be the <code>DATABASE_URL</code> at the helm chart deployment?
My situation is the following:</p>
<ul>
<li>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 <code>DATABASE_URL</code> value, <a href="https://github.com/pivotal/postfacto/blob/master/deployment/helm/templates/deployment.yaml#L72-L73" rel="nofollow noreferrer">given here</a> to connect to the container inside K8s, I've modified in this way:</li>
</ul>
<pre><code> name: DATABASE_URL
 # value: &quot;postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql&quot;
 value: &quot;postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db&quot;
</code></pre>
<p>but I am getting this error</p>
<pre><code>/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)
</code></pre>
<p>Which should be the real <code>DATABASE_URL</code> value if I want to contact to a fully Postgres managed service?</p>
<p>Which is the equivalent value to this?:</p>
<pre><code>value: &quot;postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql&quot;
</code></pre>
<p>I mean is</p>
<pre><code>postgres//&lt;username&gt;:&lt;my-pg-password&gt;@&lt;WHICH VALUE SHOULD BE HERE?&gt;
</code></pre>
<p>What is the value of <code>{{ .Release.Name }}-postgresql&quot;</code> ?</p>
<p>Just for the record, my customize <code>postfacto/deployment/helm/templates/deployment.yaml</code> is <a href="https://gist.github.com/bgarcial/22ac1722a778cc17cc57f05a20e46ad1" rel="nofollow noreferrer">this</a></p>
<p><strong>UPDATE</strong></p>
<p>I changed the value for this</p>
<pre><code>- name: DATABASE_URL
            # value: &quot;postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql&quot;
            # value: &quot;postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com:5432/postfacto-staging-db&quot;
            value: &quot;postgres://postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db&quot;
          
</code></pre>
<p>And I got a different error:</p>
<pre><code>Caused by:
PG::ConnectionBad: FATAL:  Invalid Username specified. Please check the Username and retry connection. The Username should be in &lt;username@hostname&gt; format.
FATAL:  Invalid Username specified. Please check the Username and retry connection. The Username should be in &lt;username@hostname&gt; format.
</code></pre>
<p>But is not clear how should be the syntax format since <a href="https://medium.com/avmconsulting-blog/how-to-deploy-rails-application-to-kubernetes-da8f23d45c6b" rel="nofollow noreferrer">this article</a> says:</p>
<blockquote>
<p>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</p>
</blockquote>
<p>The format <code>DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME</code>, it is the same I was using at the beginning</p>

bgarcial
<p>I think the problem with your connection string is, its <em>username</em> has a special character <code>@</code>, which might be breaking the connection string format and causing the validation error.</p>
<p>Your value</p>
<pre><code>- name: DATABASE_URL
  value: &quot;postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db&quot;
</code></pre>
<p>You can try to do an URL encoding for the <em>username</em> part like</p>
<pre><code>- name: DATABASE_URL
  value: &quot;postgres://nmbrs%40postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db&quot;
</code></pre>
