我正试图访问通过-f
参数传递给helm的自定义值文件secretvalues.yaml
中的键值。这个文件中的键值被传递给yaml文件postgres.configmap.yml
。
这是我的文件夹结构(还有一些其他图表,但为了简单起见,我已经删除了它们(
├── k8shelmcharts
│ ├── Chart.yaml
│ ├── charts
│ │ ├── postgres-service
│ │ │ ├── Chart.yaml
│ │ │ ├── templates
│ │ │ │ ├── postgres.configmap.yml
│ │ │ │ ├── postgres.deployment.yml
│ │ │ │ └── postgres.service.yml
│ │ │ └── values.yaml
│ └── secretvalues.yaml
postgres-services/
文件夹中values.yaml
文件的内容为
config:
postgres_admin_name: "postgres"
k8shelmchars/
文件夹中secretvalues.yaml
文件的内容为
secrets:
postgres_admin_password: "password"
并且CCD_ 9文件夹中的CCD_
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
data:
# property-like keys; each key maps to a simple value
POSTGRES_USER: {{ .Values.config.postgres_admin_name }}
POSTGRES_PASSWORD: {{ .secretvalues.secrets.postgres_admin_password }}
我在这里尝试了几种组合,如.secretvalues.secrets.postgres_admin_password
、.Secretvalues.secrets.postgres_admin_password
,并试图删除secrets
密钥,但没有成功。
当我运行安装图表helm install -f k8shelmcharts/secretvalues.yaml testapp k8shelmcharts/ --dry-run --debug
的命令时我得到错误:
Error: template: flask-k8s-app/charts/postgresdb/templates/postgres.configmap.yml:8:37: executing "flask-k8s-app/charts/postgresdb/templates/postgres.configmap.yml" at <.secretvalues.parameters.postgres_admin_password>: nil pointer evaluating interface {}.parameters
helm.go:94: [debug] template: flask-k8s-app/charts/postgresdb/templates/postgres.configmap.yml:8:37: executing "flask-k8s-app/charts/postgresdb/templates/postgres.configmap.yml" at <.secretvalues.parameters.postgres_admin_password>: nil pointer evaluating interface {}.parameters
我的问题是如何访问secret.postgres_admin_password
?
我正在使用helm3
谢谢!
试图通过在postgres.configmap.yml
中使用POSTGRES_PASSWORD: {{ .Values.config.postgres_admin_password }}
来访问secretvalues.yaml
文件中的键值似乎会拉取null/nil值。
运行helm install testapp k8shelmcharts/ --dry-run --debug -f k8shelmcharts/secretvalues.yaml
:时出现错误
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: unknown object type "nil" in ConfigMap.data.POSTGRES_PASSWORD
helm.go:94: [debug] error validating "": error validating data: unknown object type "nil" in ConfigMap.data.POSTGRES_PASSWORD
当我尝试使用helm template k8shelmcharts/ --debug
调试模板时,我看到:
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
data:
# property-like keys; each key maps to a simple value
POSTGRES_USER: postgres
POSTGRES_PASSWORD:
指示helm不能从CCD_ 21文件中提取值。注意:我已将secretvalues.yaml
文件中的密钥从secrets
更新为config
。
所有文件中的值都合并到一个对象Values
中,因此您应该像访问其他文件一样访问secretvalues.yaml
中的变量,即
.Values.secrets.postgres_admin_password