How to mount multiple files / secrets into common directory in kubernetes?

前端 未结 3 1264
无人及你
无人及你 2021-02-05 14:08

I\'ve multiple secrets created from different files. I\'d like to store all of them in common directory /var/secrets/. Unfortunately, I\'m unable to do that because

3条回答
  •  梦毁少年i
    2021-02-05 14:31

    Projected Volume

    You can use a projected volume to have two secrets in the same directory

    Example

    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        run: alpine-secret
      name: alpine-secret
    spec:
      containers:
      - command:
        - sleep
        - "3600"
        image: alpine
        name: alpine-secret
        volumeMounts:
        - name: xyfiles
          mountPath: "/var/secrets/"
          readOnly: true
      volumes:
      - name: xyfiles
        projected:
          sources:
          - secret:
              name: my-secret-one
          - secret:
              name: my-secret-two
    

提交回复
热议问题