Are you trying to mount a directory onto a file (or vice-versa) with kuberneters/configMap?
This is not well documented but as per my experience name of configmap yaml (config-prom-prometheus.yml in your case) should be the same as mountPath
and subPath
in Deployment
.
If you use subPath: prometheus.yml
- rename config-prom-prometheus.yml
to prometheus.yml
and try again.
This is probably slightly rewording the accepted answer, but one thing that confused me was that the mount path expected full path of to the target file.
subPath
is the key in the volume (e.g. config map) for the source.
mountPath
is target full path for the file.
For some reason my brain was thinking mountPath
was the target directory and the subPath
would infer the target file name. All I had to do was add the filename at the end of the mountPath
.
For example:
Bad:
- name: config-volume
mountPath: "/opt/config/path/"
subPath: "config-file.json"
Good:
- name: config-volume
mountPath: "/opt/config/path/config-file.json"
subPath: "config-file.json"