我正在嘗試從自定義的舵圖聯系到 azure 上的完全托管的 Postgres 服務,然后我必須根據我要部署的應用程式放置 url 連接字串。
我想問一下,DATABASE_URL掌舵圖部署應該是哪個值?我的情況如下:
- 我想使用外部 Azure 托管的 PostgreSQL,而不是 Helm Chart 附帶的 PostgreSQL 容器。因此,我修改了此處給出的
DATABASE_URL值以連接到 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)
DATABASE_URL如果我想聯系完全 Postgres 管理的服務,哪個應該是真正的價值?
與此等效的值是什么?:
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是這個
更新
我改變了這個值
- 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.
但不清楚語法格式應該如何,因為這篇文章說:
接下來,對資料庫憑據進行編碼。使用格式 DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME。如果您在 127.0.0.1 上使用帶有用戶“deploy”和密碼“secret”的 mysql 并且有一個資料庫 railsapp,請運行
格式DB_ADAPTER://USER:PASSWORD@HOSTNAME/DB_NAME,和我一開始用的一樣
uj5u.com熱心網友回復:
我認為您的連接字串的問題是,它的用戶名有一個特殊字符*,這可能會破壞連接字串格式并導致驗證錯誤。
你的價值
- name: DATABASE_URL
value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"
您可以嘗試對用戶名部分進行 URL 編碼,例如
- name: DATABASE_URL
value: "postgres://nmbrs@postgresql-nmb-psfc-stag:$(POSTGRESQL_PASSWORD)@postgresql-nmb-psfc-stag.postgres.database.azure.com/postfacto-staging-db"
uj5u.com熱心網友回復:
從我所看到的這個舵圖寫得不好,并且錯誤地假設了一些東西,即 DATABASE_URL 的構建只是為了正確格式化 kubernetes posgress helm 版本,沒有別的。
我的建議是:
- 不是通過 helm 在 k8s 上安裝這個圖表,而是使用
helm template功能在本地渲染模板。 - 編輯匯出的普通清單,以滿足您的需求
- 轉到您的 Azure DB,獲取它
ConnectionString,取決于您在 k8s 中管理機密的方式,將其傳遞給DATABASE_URL環境 - 手動應用清單
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/343264.html
上一篇:SQLDELETE-只保留組中的最后n條記錄(洗掉組中的舊記錄)
下一篇:如何使用ESQL/C顯示約束?
