我正在尝试使用外部数据库(即 CloudSQL postrges db)在 GCP 中的 GKE 集群上安装 keycloak。我想使用 helm 来安装它,因此:
helm repo add bitnami https://charts.bitnami.com/bitnami
我从 bitnami repo 下载了 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,但找不到任何可能存在问题的东西(我是 helm 新手)。第 88 行指的是生成的 yaml 文件,而不是模板文件,这使得查找错误变得更加困难。
我的配置中缺少什么?我该如何进一步调试?请帮忙
PS. 有关将 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