<p>I am using <a href="https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation" rel="nofollow noreferrer">Mount propagation</a> feature of Kubernetes to check the health of mount points of certain type. I create a daemonset and run a script which would do a simple <code>ls</code> on these mount points. I noticed that new mount points are not getting listed from the pods. Is this the expected behaviour.</p>

<pre><code>volumeMounts:
            - mountPath: /host
              name: host-kubelet
              mountPropagation: HostToContainer
      volumes:
          - name: host-kubelet
            hostPath:
              path: /var/lib/kubelet
</code></pre>

<p>Related Issue : <a href="https://github.com/kubernetes/kubernetes/issues/44713" rel="nofollow noreferrer">hostPath containing mounts do not update as they change on the host #44713</a></p>

<p>In brief, <strong>Mount propagation</strong> allows sharing volumes mounted by a Container to other Containers in the same Pod, or even to other Pods on the same node.<br>
Mount propagation of a volume is controlled by <code>mountPropagation</code> field in <code>Container.volumeMounts</code>. Its values are:</p>

<ul>
<li><code>HostToContainer</code> - one way propagation, from host to container. If you
mount anything inside the volume, the Container will see it there.</li>
<li><code>Bidirectional</code> - In addition to propagation from host to container,
all volume mounts created by the Container will be propagated back to
the host, so all Containers of all Pods that use the same volume will
see it as well.</li>
</ul>

<p>Based on <a href="https://v1-9.docs.kubernetes.io/docs/concepts/storage/volumes/" rel="noreferrer">documentation</a> the Mount propagation feature is in alpha state for clusters v1.9, and going to be beta on v1.10</p>

<p>I've reproduced your case on kubernetes v1.9.2 and found that it completely ignores <code>MountPropagation</code> configuration parameter. If you try to check current state of the <code>DaemonSet</code> or <code>Deployment</code>, you'll see that this option is missed from the listed yaml configuration</p>

<pre><code>$ kubectl get daemonset --export -o yaml
</code></pre>

<p>If you try to run just docker container with mount propagation option you may see it is working as expected:</p>

<pre><code>docker run -d -it -v /tmp/mnt:/tmp/mnt:rshared ubuntu
</code></pre>

<p>Comparing docker container configuration with kubernetes pod container in the volume mount section, you may see that the last flag (<code>shared</code>/<code>rshared</code>) is missing in kubernetes container.</p>

<p>And that's why it happens in <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/alpha-clusters#about_feature_stages" rel="noreferrer">Google kubernetes clusters</a> and may happen to clusters managed by other providers:</p>

<blockquote>
  <p>To ensure stability and production quality, normal Kubernetes Engine
  clusters only enable features that are beta or higher. Alpha features
  are not enabled on normal clusters because they are not
  production-ready or upgradeable.</p>
  
  <p>Since Kubernetes Engine automatically upgrades the Kubernetes control
  plane, enabling alpha features in production could jeopardize the
  reliability of the cluster if there are breaking changes in a new
  version.</p>
</blockquote>

<p><a href="https://github.com/kubernetes/community/blob/master/contributors/devel/api_changes.md#alpha-beta-and-stable-versions" rel="noreferrer">Alpha level features availability</a>: committed to main kubernetes repo; appears in an official release; feature is disabled by default, but may be enabled by flag (in case you are able to set flags)</p>

<p>Before mount propagation can work properly on some deployments (CoreOS, RedHat/Centos, Ubuntu) mount share must be configured correctly in Docker as shown below.</p>

<p>Edit your Docker’s <code>systemd</code> service file. Set <code>MountFlags</code> as follows:</p>

<pre><code>MountFlags=shared
</code></pre>

<p>Or, remove <code>MountFlags=slave</code> if present. Then restart the Docker daemon:</p>

<pre><code> $ sudo systemctl daemon-reload
 $ sudo systemctl restart docker
</code></pre>
