如何在部署配置中为秘密mountPath使用相对路径

时间:2019-02-17 11:51:01

标签: kubernetes kubernetes-secrets

我很难将mountPath配置为相对路径。 假设我正在/user/app文件夹中运行部署,并且想在/user/app/secret/secret-volume下创建秘密文件,如下所示:

apiVersion: v1
kind: Pod
metadata:
  name: secret-test-pod
spec:
  containers:
    - name: test-container
      image: nginx
      volumeMounts:
          # name must match the volume name below
          - name: secret-volume
            mountPath: secret/secret-volume
  # The secret data is exposed to Containers in the Pod through a Volume.
  volumes:
    - name: secret-volume
      secret:
        secretName: test-secret

由于某种原因,在根目录secret-volume中创建了文件/secret/secret-volume

2 个答案:

答案 0 :(得分:1)

这是因为您已将mountPath: secret/secret-volume更改为mountPath: /user/app/secret/secret-volume

Check documentation here

答案 1 :(得分:0)

容器的安装路径需要更正。