【问题标题】:How can I put multi configmap in the same mount path in kubernetes?如何将多个 configmap 放在 kubernetes 的同一挂载路径中?
【发布时间】:2020-02-20 08:24:29
【问题描述】:

我有两个 python 文件,testing_1.pytesting_2.py。 然后,我创建了带有testing-config1 的配置映射来存储testing_1.pytesting-config2 分别存储testing_2.py

在 Kubernetes yaml 中,

...
      containers:
      - name: spark-master
        image: bde2020/spark-master:2.4.4-hadoop2.7
        volumeMounts:
        - name: testing
          mountPath: /jobs
        - name: testing2
          mountPath: /jobs
      volumes:
        - name: testing
          configMap:
            name: testing-config1
        - name: testing2
          configMap:
            name: testing-config2
...

在最终结果中,路径只包含 testing_1.py。

【问题讨论】:

  • 您想实现什么样的结构?

标签: kubernetes configmap


【解决方案1】:

您可以通过在指定路径时提供subPath 来实现。修改如下:

containers:
      - name: spark-master
        image: bde2020/spark-master:2.4.4-hadoop2.7
        volumeMounts:
        - name: testing
          mountPath: /jobs/testing_1.py
          subPath: testing_1.py
        - name: testing2
          mountPath: /jobs/testing_2.py
          subPath: testing_2.py
      volumes:
        - name: testing
          configMap:
            name: testing-config1
        - name: testing2
          configMap:
            name: testing-config2

【讨论】:

    【解决方案2】:

    您可以将两个文件放在同一个 ConfigMap 中。

    或者,使用projected 音量:

    投影卷将多个现有卷源映射到同一个 目录。

    目前,可以投影以下类型的音量源:

    • 秘密
    • 向下API
    • 配置映射
    • serviceAccountToken

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 2021-09-08
      • 2017-07-21
      • 2022-08-16
      • 2023-03-22
      • 2020-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多