我正在嘗試使用外部資料庫(即 CloudSQL postrges db)在 GCP 中的 GKE 叢集上安裝 keycloak。我想使用 helm 來安裝它,所以:
helm repo add bitnami https://charts.bitnami.com/bitnami
我已經從 bitnami 存儲庫下載了 Values.yml 文件,並且更新了該文件的“externalDatabase.externalSecret”部分,因為我不想以純文字形式輸入憑證。相反,我創建了 Kubernetes Secret:
$ kubectl get secret keycloak-db-secret -o yaml
apiVersion: v1
data:
POSTGRES_DATABASE: <value>
POSTGRES_EXTERNAL_ADDRESS: <value>
POSTGRES_EXTERNAL_PORT: <value>
POSTGRES_PASSWORD: <value>
POSTGRES_USERNAME: <value>
kind: Secret
metadata:
...
Values.yml 中的修改為(文件的其餘部分未更改):
postgresql:
enabled: false
externalDatabase:
existingSecret:
name: keycloak-db-secret
keyMapping:
host: POSTGRES_EXTERNAL_ADDRESS
port: POSTGRES_EXTERNAL_PORT
user: POSTGRES_USERNAME
password: POSTGRES_PASSWORD
database: POSTGRES_DATABASE
當我跑步時
helm install --debug my-keycloak bitnami/keycloak -f Values.yml
我收到一條錯誤訊息
install.go:173: [debug] Original chart version: ""
install.go:190: [debug] CHART PATH: /home/michal/.cache/helm/repository/keycloak-5.0.7.tgz
coalesce.go:203: warning: destination for existingSecret is a table. Ignoring non-table value
coalesce.go:203: warning: destination for existingSecret is a table. Ignoring non-table value
Error: YAML parse error on keycloak/templates/statefulset.yaml: error converting YAML to JSON: yaml: line 88: mapping values are not allowed in this context
helm.go:81: [debug] error converting YAML to JSON: yaml: line 88: mapping values are not allowed in this context
YAML parse error on keycloak/templates/statefulset.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
/home/circleci/helm.sh/helm/pkg/action/action.go:165
helm.sh/helm/v3/pkg/action.(*Install).Run
/home/circleci/helm.sh/helm/pkg/action/install.go:240
main.runInstall
/home/circleci/helm.sh/helm/cmd/helm/install.go:242
main.newInstallCmd.func2
/home/circleci/helm.sh/helm/cmd/helm/install.go:120
github.com/spf13/cobra.(*Command).execute
/go/pkg/mod/github.com/spf13/[email protected]/command.go:850
github.com/spf13/cobra.(*Command).ExecuteC
/go/pkg/mod/github.com/spf13/[email protected]/command.go:958
github.com/spf13/cobra.(*Command).Execute
/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
main.main
/home/circleci/helm.sh/helm/cmd/helm/helm.go:80
runtime.main
/usr/local/go/src/runtime/proc.go:204
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1374
我檢查了 templates/statefulset.yaml 但找不到任何可能出現問題的內容(我是舵初學者)。第 88 行指的是產生的 yaml 文件,而不是範本文件,這使得尋找 bug 變得更加困難。
我的配置中缺少什麼?我怎樣才能進一步調試它?請幫忙
附言。將 Keycloak 連接到外部資料庫的文檔在這裡:(https://docs.bitnami.com/kubernetes/apps/keycloak/configuration/use-external-database/
答案1
密鑰externalDatabase.existingSecret
只需要一個秘密名稱。
相關行是這裡。
例如
postgresql:
enabled: false
externalDatabase:
existingSecret: keycloak-db-secret
host: pg.ns.svc.cluster.local
port: 5432
user: pg_username
database: db_name
注意:密鑰必須具有“密碼”密鑰,才能使用完全自訂的版本填入
auth.existingSecret
或auth.existingSecretPerPassword