【发布时间】:2021-11-01 22:33:27
【问题描述】:
我正在尝试从自定义 helm chart 联系 azure 上完全托管的 Postgres 服务,然后我必须根据我要部署的应用程序放置 url 连接字符串。
我想问在 helm chart 部署中,DATABASE_URL 应该是哪个值?
我的情况如下:
- 我想使用外部 Azure 托管的 PostgreSQL,而不是 helm chart 附带的 PostgreSQL 容器。
因此,我修改了
DATABASE_URL的值,given here连接到K8s内部的容器,我是这样修改的:
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"
但我收到此错误
/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)
如果我想联系完全 Postgres 托管的服务,那么真正的 DATABASE_URL 值应该是什么?
与此等价的值是多少?:
value: "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(POSTGRESQL_PASSWORD)@{{ .Release.Name }}-postgresql"
我的意思是
postgres//<username>:<my-pg-password>@<WHICH VALUE SHOULD BE HERE?>
{{ .Release.Name }}-postgresql" 的值是多少?
为了记录,我自定义的postfacto/deployment/helm/templates/deployment.yaml是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"
我得到了一个不同的错误:
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.
但不清楚语法格式应该如何,因为this article 说:
接下来,对数据库凭据进行编码。使用格式 DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME。如果您在 127.0.0.1 上使用用户“deploy”和密码“secret”的 mysql,并且有一个数据库 railsapp,请运行
DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME的格式,和我一开始用的一样
【问题讨论】:
-
value: "postgres://nmbrs:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"- 为什么将数据库名称添加到用户名/密码段 -
是的,数据库名称不应该在那里,if we see the url defined in the helm chart 我只是在尝试不同的格式。无论如何,如果我最后删除数据库名称,错误是一样的。
-
@ArunPJohny 我认为 Rails 作为一种框架有一种特定的方式来定义数据库 url 连接,我正在检查这个 guides.rubyonrails.org/configuring.html#configuring-a-database 但我不清楚
-
改后报错是什么?另外,
test2021*是什么?是密码吗 -
@ArunPJohny 是的,这是一个测试密码,对不起,你能在问题中看到我上面的更新吗?
标签: postgresql kubernetes