I am trying to create a volume mount in a pod through a config map. Below are my defintion files:
configmap def:
apiVersion: v1
kind: ConfigMap
metadata:
name: firstcm
data:
appname: springboot
database: inmemory
tool: h2
type: singlecontainer
deployment def:
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
All objects are created fine and I can see the configmap with the data I had put. But the db.properties file that is created from config map is empty, has no data in it. Does anyone know what am I missing here?
drwxrwxrwx 2 root root 4096 Jun 6 00:17 db.properties
/etc/config # more db.properties/
/etc/config #
Change your configmap to
apiVersion: v1
kind: ConfigMap
metadata:
name: firstcm
data:
db.properties: |
appname: springboot
database: inmemory
tool: h2
type: singlecontainer
This is required because you are mounting a specific key (db.properties) from your configmap