cat application.properties
greeter.message="hello world"
volumeMounts:
- mountPath: /tmp/test/application.properties
name: application-config
subPath: application.properties
readOnly: true
volumes:
- name: application-config
configMap:
name: spring-app-config
defaultMode: 420
items:- key: application.properties
path: application.properties
- key: application.properties
将 ConfigMap 数据添加到卷中的特定路径
使用 path 字段为特定的 ConfigMap 项目指定预期的文件路径。 在这里,ConfigMap 中键 SPECIAL_LEVEL 的内容将挂载在 config-volume 卷中 /etc/config/keys 文件中。
pods/pod-configmap-volume-specific-key.yaml Copy pods/pod-configmap-volume-specific-key.yaml to clipboard
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh","-c","cat /etc/config/keys" ]
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: special-config
items:
- key: SPECIAL_LEVEL
path: keys
restartPolicy: Never
https://www.cnblogs.com/weihanli/p/volume-configuration-file-with-configmap.html
https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-pod-configmap/
https://www.cnblogs.com/gdwkong/p/15394087.html
https://www.modb.pro/db/232040
https://developers.redhat.com/blog/2017/10/03/configuring-spring-boot-kubernetes-configmap#