Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 在部署期间向configmap注入秘密值,而不使用环境变量_Kubernetes_Configmap_Kubernetes Secrets - Fatal编程技术网

Kubernetes 在部署期间向configmap注入秘密值,而不使用环境变量

Kubernetes 在部署期间向configmap注入秘密值,而不使用环境变量,kubernetes,configmap,kubernetes-secrets,Kubernetes,Configmap,Kubernetes Secrets,我有一张这样的地图 apiVersion: v1 kind: ConfigMap metadata: namespace: develop name: test-config data: app.conf: | connection conn1 address 127.0.0.1:8080 user cluster1 password: <HERE COPY PASS FROM SECRET> 读取该文件的应用程序无法读取环境变量,我无法

我有一张这样的地图

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: develop
  name: test-config
data:
  app.conf: |
    connection conn1
    address 127.0.0.1:8080
    user cluster1
    password: <HERE COPY PASS FROM SECRET>
读取该文件的应用程序无法读取环境变量,我无法更改该行为,它是第三方应用程序


我想知道在pod部署期间如何将密码从密码字段插入密码字段

您不能,您可以使用密码挂载密码-请参阅文档。因此,您将得到两个文件—一个来自配置映射,另一个来自机密

如果您的应用程序不支持多个配置文件,则必须将整个配置文件存储在机密中,而不是存储在配置映射中


另外,请注意,Kubernetes机密不能存储在源代码管理上,因为机密数据是使用base64编码的(有关更多详细信息,请参阅)。此问题有多种解决方案,请查看我的

为什么不从密码中获取密码?为什么要将其传递给configmap,而configmap并不打算保留密码?
spec:
  replicas: 1
  ...
    spec:
      containers:
        - name: container-name
          ...
          volumeMounts:
            - name: test-config-vol
              mountPath: /etc/app/app.conf
              subPath: app.conf
      volumes:
        - name: test-config-vol
          configMap:
            name: test-config