我有多个由不同文件创建的secret。我想把它们都存储在公共目录/var/secrets/
中。不幸的是,我无法做到这一点,因为kubernetes抛出了 'Invalid value: "/var/secret": must be unique 错误,在pod验证步骤中。下面是我的pod定义的一个例子。
apiVersion: v1
kind: Pod
metadata:
labels:
run: alpine-secret
name: alpine-secret
spec:
containers:
- command:
- sleep
- "3600"
image: alpine
name: alpine-secret
volumeMounts:
- name: xfile
mountPath: "/var/secrets/"
readOnly: true
- name: yfile
mountPath: "/var/secrets/"
readOnly: true
volumes:
- name: xfile
secret:
secretName: my-secret-one
- name: yfile
secret:
secretName: my-secret-two
如何在同一目录下挂载多个secret的文件?
Projected Volume
您可以使用一个
projected
在相同的目录中挂两个secrets。例如
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
你的答案