我们可以将ConfigMap中定义的数据用作部署的密钥吗?
我创建了一个configmap。我在configmap中添加了数据作为键值对,
data:
EXTERNAL_CONFIG_FILE: /user/app/api/config
我需要使用此变量在部署中设置一个安装路径,
- name: config-properties-volume-mnt
mountPath: {{ $EXTERNAL_CONFIG_FILE }}
我在部署时会获得未定义的变量“ $ external_config_file”。 我不想在value.yaml中定义此变量。有没有办法在部署中使用ConfigMap中定义的此变量?
I have a configmap created. I have added data as a key-value pair in configmap
data:
EXTERNAL_CONFIG_FILE: /user/app/api/config
I need to use this variable to set a mount path in deployment
- name: config-properties-volume-mnt
mountPath: {{ $EXTERNAL_CONFIG_FILE }}
I am getting undefined variable "$EXTERNAL_CONFIG_FILE" while deploying. I do not want to define this variable in values.yaml. Is there a way where I can use this variable defined in configmap in deployment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可能动态定义清单上的任何参数,您必须使用掌舵或kustomize
,否则您可以使用 sed 来替换文本在清单中,
您不能以这种方式使用这种方式, configmap secret 通常是将变量或文件注入pod,而不是在声明步骤中。
如果您有掌舵图表,将详细信息保留到
vaules.yaml
是唯一的选择。subpath方法:
您可以使用子路口实现, subpath 您可以使用环境: https://kubernetes.io/docs/docs/concepts/concepts/storage/storage/volumes/#using-subpath-path-path-path-path-path-path-path-spath-eppand- expand- expand- expand- expanded-environment
env 在上面示例中使用的您可以使用 configmap
It's not possible to dynamically define any parameter on a manifest, you have to use the Helm or Kustomize
Or else you can use the sed to replace the Text in manifest simply
You can not use this way, configmap and secret are normally to inject the variables or file into the POD not at declare step.
if you have helm chart keeping details into the
vaules.yaml
is the only option.Subpath method :
You can use the subpath to achieve, with subpath you can use the environment: https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-expanded-environment
Instead of env used in the above example you can use the configmap