有没有办法创建 Kubernetes Secret 子目录?
is there a way to create a Kubernetes Secret subdirectory?
Kubernetes Secrets 创建挂载为 volumeMount.[=11= 的文件]
可以将多个文件放在一个 Secret 中。
有没有办法创建一个将文件放入 目录结构(即文件夹)的 Secret?
文档中没有它的迹象,并且在密钥名称中不允许使用 /
,所以这似乎是不可能的(除了制作多个秘密并将它们安装在不同的卷中)
有谁更了解吗?
不,目前无法创建子目录。目前正在进行的工作是对如何将来自秘密的数据注入 Pod 进行更多控制,但这在今天是不可能的
现在这实际上是可能的:您需要使用 items
字段将秘密中的 key/value 对投影到您想要的特定路径。请参阅机密文档中标题为 "Projection of secret keys to specific paths" 的部分中的示例,我已将其链接并复制如下:https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mypod
image: redis
volumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
volumes:
- name: foo
secret:
secretName: mysecret
items:
- key: username
path: my-group/my-username
这会将带有密钥 "username" 的密钥放置在路径 /my_secret_volume/my-group/my-username
Kubernetes Secrets 创建挂载为 volumeMount.[=11= 的文件]
可以将多个文件放在一个 Secret 中。
有没有办法创建一个将文件放入 目录结构(即文件夹)的 Secret?
文档中没有它的迹象,并且在密钥名称中不允许使用 /
,所以这似乎是不可能的(除了制作多个秘密并将它们安装在不同的卷中)
有谁更了解吗?
不,目前无法创建子目录。目前正在进行的工作是对如何将来自秘密的数据注入 Pod 进行更多控制,但这在今天是不可能的
现在这实际上是可能的:您需要使用 items
字段将秘密中的 key/value 对投影到您想要的特定路径。请参阅机密文档中标题为 "Projection of secret keys to specific paths" 的部分中的示例,我已将其链接并复制如下:https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mypod
image: redis
volumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
volumes:
- name: foo
secret:
secretName: mysecret
items:
- key: username
path: my-group/my-username
这会将带有密钥 "username" 的密钥放置在路径 /my_secret_volume/my-group/my-username