can i use a configmap created from an init container in the pod

后端 未结 3 1678
半阙折子戏
半阙折子戏 2021-02-14 16:32

I am trying to \"pass\" a value from the init container to a container. Since values in a configmap are shared across the namespace, I figured I can use it for this purpose. Her

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 16:59

    You can create an EmptyDir volume, and mount this volume onto both containers. Unlike persistent volume, EmptyDir has no portability issue.

    apiVersion: batch/v1
    kind: Job
    metadata:
      name: installer-test
    spec:
      template:
        spec:
          containers:
          - name: installer-test
            image: installer-test:latest
            env:
            - name: clusterId
              value: "some_cluster_id"
            volumeMounts:
            - name: tmp
              mountPath: /tmp/artifact
          initContainers:
          - name: artifactory-snapshot
            image: busybox
            command: ['/bin/sh', '-c', 'cp x /tmp/artifact/x']
            volumeMounts:
            - name: tmp
              mountPath: /tmp/artifact
          restartPolicy: Never
          volumes:
          - name: tmp
            emptyDir: {}
      backoffLimit: 0
    

提交回复
热议问题