如何在configmap中设置密码
How to set passwords in configmap
我想在配置 map.YAML 而不是 deployment.yaml.able 中配置密码来设置用户名和其他 variables.attcahing 我处理的配置 map.YAML 文件。
kind: ConfigMap
apiVersion: v1
metadata:
name: poc-configmapconfiguration-configmap
data:
Environment: [[.Environment]]
dockerRegistryUrl: [[.Env.dockerRegistryUrl]]
CassandraSettings__CassandraPassword:
valueFrom:
secretKeyRef:
name: abcd-passwords
key: "[[ .Environment ]]-abcd-cassandra-password
正如您从 secretKeyRef
中看到的那样,使用 Secret 会更常见,但是存在等效的 configMapRef
并以相同的方式使用。
正如已经建议的使用秘密存储密码的更好做法
Secrets 使用 Base64 编码使您的数据变得模糊,因此最好将 Secrets 用于机密数据而不是使用 ConfigMap。
如果您对 ConfigMap 字段执行解释以从 CLI 获取更多详细信息,它会在 ConfigMap.data 上自行接受字符串映射。
$ kubectl explain ConfigMap.data
KIND: ConfigMap
VERSION: v1
FIELD: data <map[string]string>
DESCRIPTION:
Data contains the configuration data. Each key must consist of alphanumeric
characters, '-', '_' or '.'. Values with non-UTF-8 byte sequences must use
the BinaryData field. The keys stored in Data must not overlap with the
keys in the BinaryData field, this is enforced during validation process.
所以上面 你使用的 yaml 结构应该在创建时抛出一个错误 类似于下面..
invalid type for io.k8s.api.core.v1.ConfigMap.data
参考此 git 此类功能请求,该请求已关闭,未考虑支持。
我想在配置 map.YAML 而不是 deployment.yaml.able 中配置密码来设置用户名和其他 variables.attcahing 我处理的配置 map.YAML 文件。
kind: ConfigMap
apiVersion: v1
metadata:
name: poc-configmapconfiguration-configmap
data:
Environment: [[.Environment]]
dockerRegistryUrl: [[.Env.dockerRegistryUrl]]
CassandraSettings__CassandraPassword:
valueFrom:
secretKeyRef:
name: abcd-passwords
key: "[[ .Environment ]]-abcd-cassandra-password
正如您从 secretKeyRef
中看到的那样,使用 Secret 会更常见,但是存在等效的 configMapRef
并以相同的方式使用。
正如已经建议的使用秘密存储密码的更好做法 Secrets 使用 Base64 编码使您的数据变得模糊,因此最好将 Secrets 用于机密数据而不是使用 ConfigMap。
如果您对 ConfigMap 字段执行解释以从 CLI 获取更多详细信息,它会在 ConfigMap.data 上自行接受字符串映射。
$ kubectl explain ConfigMap.data
KIND: ConfigMap
VERSION: v1
FIELD: data <map[string]string>
DESCRIPTION:
Data contains the configuration data. Each key must consist of alphanumeric
characters, '-', '_' or '.'. Values with non-UTF-8 byte sequences must use
the BinaryData field. The keys stored in Data must not overlap with the
keys in the BinaryData field, this is enforced during validation process.
所以上面 你使用的 yaml 结构应该在创建时抛出一个错误 类似于下面..
invalid type for io.k8s.api.core.v1.ConfigMap.data
参考此 git 此类功能请求,该请求已关闭,未考虑支持。