Kubernetes VolumeMount 路径包含时间戳
Kubernetes VolumeMount Path contains Timestamp
我正在使用以下技术:
- 头盔
- argocd
- k8s
我创建了一个秘密:
╰ kubectl create secret generic my-secret --from-file=my-secret=/Users/superduper/project/src/main/resources/config-file.json --dry-run=client -o yaml
apiVersion: v1
data:
my-secret: <content>
kind: Secret
metadata:
creationTimestamp: null
name: my-secret
然后我通过卷装载将秘密添加到我的 pod:
volumeMounts:
- mountPath: "/etc/config"
name: config
readOnly: true
volumes:
- name: config
secret:
secretName: my-secret
但问题是,当我查看 /etc/config 目录时,内容显示 my-secret
在时间戳目录下:
directory:/etc/config/..2021_07_10_20_14_55.980073047
file:/etc/config/..2021_07_10_20_14_55.980073047/my-secret
这正常吗?无论如何我可以摆脱那个时间戳,这样我就可以以编程方式获取配置秘密吗?
这是 Kubernetes 默认挂载 Secrets 和 ConfigMap 的方式,以便在上游发生更改时将更改向下传播到这些卷挂载。如果您不想使用符号链接并想放弃这种能力,请使用 subPath
指令,您的坐骑将如您所愿地出现。
volumeMounts:
- mountPath: /etc/config/my-secret
name: config
subPath: my-secret
readOnly: true
volumes:
- name: config
secret:
secretName: my-secret
$ k exec alpine -it -- /bin/ash
/ # ls -lah /etc/config/
total 12K
drwxr-xr-x 2 root root 4.0K Jul 10 22:58 .
drwxr-xr-x 1 root root 4.0K Jul 10 22:58 ..
-rw-r--r-- 1 root root 9 Jul 10 22:58 my-secret
/ # cat /etc/config/my-secret
hi there
我正在使用以下技术:
- 头盔
- argocd
- k8s
我创建了一个秘密:
╰ kubectl create secret generic my-secret --from-file=my-secret=/Users/superduper/project/src/main/resources/config-file.json --dry-run=client -o yaml
apiVersion: v1
data:
my-secret: <content>
kind: Secret
metadata:
creationTimestamp: null
name: my-secret
然后我通过卷装载将秘密添加到我的 pod:
volumeMounts:
- mountPath: "/etc/config"
name: config
readOnly: true
volumes:
- name: config
secret:
secretName: my-secret
但问题是,当我查看 /etc/config 目录时,内容显示 my-secret
在时间戳目录下:
directory:/etc/config/..2021_07_10_20_14_55.980073047
file:/etc/config/..2021_07_10_20_14_55.980073047/my-secret
这正常吗?无论如何我可以摆脱那个时间戳,这样我就可以以编程方式获取配置秘密吗?
这是 Kubernetes 默认挂载 Secrets 和 ConfigMap 的方式,以便在上游发生更改时将更改向下传播到这些卷挂载。如果您不想使用符号链接并想放弃这种能力,请使用 subPath
指令,您的坐骑将如您所愿地出现。
volumeMounts:
- mountPath: /etc/config/my-secret
name: config
subPath: my-secret
readOnly: true
volumes:
- name: config
secret:
secretName: my-secret
$ k exec alpine -it -- /bin/ash
/ # ls -lah /etc/config/
total 12K
drwxr-xr-x 2 root root 4.0K Jul 10 22:58 .
drwxr-xr-x 1 root root 4.0K Jul 10 22:58 ..
-rw-r--r-- 1 root root 9 Jul 10 22:58 my-secret
/ # cat /etc/config/my-secret
hi there