如何使用 Kubernetes yaml 文件设置动态值 [英] How to set dynamic values with Kubernetes yaml file

查看:41
本文介绍了如何使用 Kubernetes yaml 文件设置动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如部署 yaml 文件:

For example, a deployment yaml file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: guestbook
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: guestbook
      spec:
        container:
          - name: guestbook
            image: {{Here want to read value from config file outside}}

Kubernetes 有一个 ConfigMap 功能,但这也会将键/值写入 yaml 文件.有没有办法设置环境变量的key?

There is a ConfigMap feature with Kubernetes, but that's also write the key/value to the yaml file. Is there a way to set the key to environment variables?

推荐答案

我认为在 Kubernetes 中通过变量或 Config Map 设置图像是不可能的.但是您可以使用例如 Helm 使您的部署更加灵活和可配置.

I don't think it is possible to set image through variable or Config Map in Kubernetes. But you can use for example Helm to make your deployments much more flexible and configurable.

这篇关于如何使用 Kubernetes yaml 文件设置动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆