title: How to get notification inside an application in kubernetes when configmaps get updated
body: <p>I have an application running inside <code>kubernetes</code> which has a file mounted through <code>configmaps</code>. Now, from inside the application I want to perform some action when this file (from configmap) gets updated (lets say through <code>kubectl update configmaps xyz</code> command).</p>
  
  <p>Lets say I have created a configmap using the following command:</p>
  
  <pre><code>kubectl create configmap myy-config --from-file=config.json
  </code></pre>
  
  <p>and I have my Deployment created like this:</p>
  
  <pre><code>apiVersion: apps/v1beta2
  kind: Deployment
  metadata:
    name: myapp
  spec:
    selector:
      matchLabels:
        app: myapp
    template:
      metadata:
        labels:
          app: myapp
      spec:
        containers:
          -
            image: "xyz"
            name: myapp
            ports:
              -
                containerPort: 5566
            volumeMounts:
              -
                mountPath: /myapp/config
                name: config
        dnsPolicy: ClusterFirstWithHostNet
        volumes:
          -
            name: config
            configMap:
              name: my-config
  </code></pre>
  
  <p>Now, if I do <code>kubectl exec -it &lt;pod&gt; sh</code> I can see the file. If I edit the configmap using <code>kubectl edit configmap my-config</code> and change the content, the application running in my pod doesn't get the file changed notification. I am using GO Lang for the application and it doesn't receive the fsnotify on the file <code>/myapp/config/config.json</code> even though I can see that after the edit, the file has changed.</p>
  
  <p>If I run the same application in my laptop, of course, the code gets the fsnotify and my application updates it configuration. The same code from within the kubernetes with the file coming from configmap, it doesn't work. I have read other SOF questions <a href="https://stackoverflow.com/questions/37317003/restart-pods-when-configmap-updates-in-kubernetes">like this</a> and various others, but nothing specifically has solution for the problem I face.</p>
  
  <p>I understand that the file (which comes from the configmap) is a symlink and the actual file is in a folder called <code>..data/config.json</code>. I tried to add that file also, but still not getting the fsnotify signal. Is it possible to get fsnotify signal for files which come from configmap (as well as secrets) within the application? If so, can someone please help me and show how to do it (preferably in GO lang)?</p>