我正试图通过配置映射在pod中创建一个卷装载。以下是我的定义文件:
configmap def:
apiVersion: v1
kind: ConfigMap
metadata:
name: firstcm
data:
appname: springboot
database: inmemory
tool: h2
type: singlecontainer
部署定义:
apiVersion: apps/v1
kind: Deployment
metadata:
name: firstspring
labels:
app: firstspring
spec:
replicas: 1
selector:
matchLabels:
app: firstspring
template:
metadata:
labels:
app: firstspring
spec:
containers:
- name: firstspring
image: mukhou/firstspring
volumeMounts:
- name: firstvol
mountPath: /etc/config/db.properties
subPath: db.properties
volumes:
- name: firstvol
configMap:
name: firstcm
所有对象都创建得很好,我可以看到带有我放置的数据的配置映射。但是从配置映射创建的db.properties文件是空的,里面没有数据。有人知道我在这里缺少什么吗?
drwxrwxrwx 2 root root 4096 Jun 6 00:17 db.properties
/etc/config # more db.properties/
/etc/config #
将配置映射更改为
apiVersion: v1
kind: ConfigMap
metadata:
name: firstcm
data:
db.properties: |
appname: springboot
database: inmemory
tool: h2
type: singlecontainer
这是必需的,因为您正在从配置映射装载特定密钥(db.properties(