<p>How to reload open shift config yaml file automatically when config value was updated?</p>
<p>Current I am redeploying to reload open shift config yaml. I don't want to redeploy application one more time for a config value change?</p>
<p>Below is my config.yaml file. How to write a syntax to Trigger pod and redepoy pod automatically and config value got change automatically?</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: config
parameters:
- name: APPLICATION
  required: true
- name: BLUE_GREEN_VERSION
  required: true
- name: SQL_CONNECTION
  required: true
- name: API_URL
  required: true 
objects:
- apiVersion: v1
  kind: ConfigMap
  metadata:
    name: ${APPLICATION}-${BLUE_GREEN_VERSION}
  data:
    appsettings.json: |-
      {
        &quot;ConnectionStrings&quot;: {
          &quot;SQLDB&quot;: &quot;${SQL_CONNECTION}&quot;
        },
        &quot;URL&quot;:&quot;${API_URL}&quot;,
        &quot;AllowedHosts&quot;: &quot;*&quot;
      }
</code></pre>

Shakeer Hussain
<p>I was checking the watch command, and it did not behave as expected.</p>
<p>So I made a simple script and tested it.</p>
<pre><code>#!/bin/bash

# Set initial time of the last file update
INTIAL_LAST_MODIFICATION_TIME=`stat -c %Z $1`

while true
do
# Check time of the last time update
   LAST_MODIFICATIO_TIME=`stat -c %Z $1`

# Execute command, If file has changed
   if [[ &quot;$LAST_MODIFICATIO_TIME&quot; != &quot;$INTIAL_LAST_MODIFICATION_TIME&quot; ]]
   then
       $2
       INTIAL_LAST_MODIFICATION_TIME=$LAST_MODIFICATIO_TIME
   fi
   sleep ${3:-5}
done
</code></pre>
<p>Example usage will be,</p>
<pre><code>./name_of_the_script 

{file_to_watch} 

{command_to_execute_if_file_have_changed} 

{time_to_wait_before_checking_again_in_seconds_default_is_5}
</code></pre>
<p>In your case, would be something like the following
<code>./watch config.yaml &quot;oc apply -f config.yaml&quot; 2</code></p>
<p>Hope this will be helpful. And there are few 3rd party libraries that will provide more options. like <a href="https://github.com/eradman/entr" rel="nofollow noreferrer">entr</a>, <a href="https://github.com/inotify-tools/inotify-tools/wiki" rel="nofollow noreferrer">inotify-tools</a> and <a href="https://github.com/watchexec/watchexec" rel="nofollow noreferrer">watch exec</a></p>
