How to correctly mount configMap with subPath in Kubernetes? Not update configs after changes

2/1/2018

I tried to use configMap to mount some configs in a subdirectory. For example:

spec.template.spec.containers.[0].volumeMounts:
  - name: fh16-volume
    mountPath: /etc/fh-16/application.log
    subPath: my-config.txt
spec.template.spec.volumes:
  - name: fh16-volume
    configMap:
      name: my-config

At this scenario, all mount as expected. But after any changes in configMap, this changes not applied in a container. Need to recreate pod for this.

It looks like some bug, but maybe I make some mistake in my configurations? In the case when I don't use subPath directive, all works as expected.

-- Roman
kubernetes

3 Answers

2/1/2018
-- Slava Semushin
Source: StackOverflow

2/2/2018

This is currently expected behavior. kubelet update the content inside container on a timer.

See https://github.com/kubernetes/kubernetes/issues/30189

-- lang2
Source: StackOverflow

4/4/2018

See this note in the Kubernetes docs:

Note: A container using a ConfigMap as a subPath volume mount will not receive ConfigMap updates."

-- liukuan73
Source: StackOverflow