<p>If some nodes down in a cluster and the status become <code>NotReady</code>, can I make it to trigger some action?</p>

<p>I tried to use <a href="https://gist.github.com/irake99/2062ea54bef89a072b67461cf955b079" rel="nofollow noreferrer">client-go</a> and curl to watch <code>/api/v1/watch/nodes</code> and get notifies when nodes status have <code>any</code> change. How do I get notifies <strong>only</strong> if nodes status change from <code>Ready</code> to <code>NotReady</code>?</p>

<p>As of now, there is no way to query for specific updates. There are two ways you can implement this:</p>

<ol>
<li><p>The NodeStatus has a field called <code>lastTransitionTime</code> which records a change in a field. In your application, you can check every X seconds and then compare last checked time with <code>lastTransitionTime</code> to determine if there is a change. If your application restarts, you will have to do a one time check at startup of application</p>

<pre><code>{
        "type": "Ready",
        "status": "True",
        "lastHeartbeatTime": "2017-12-27T09:52:19Z",
        "lastTransitionTime": "2017-12-26T14:55:49Z",
        "reason": "KubeletReady",
        "message": "kubelet is posting ready status"
}
</code></pre></li>
<li><p>Your app written in client-go can maintain a cache and compare the value in cache to the value from watch events. In this case as well, you will have to think of ways to not miss events when your watcher service is down. You can either store that state somewhere or use some other mechanism but it depends on criticality of your use case.</p></li>
</ol>

<p>The closest example I can find is in Calico-go, where any changes in network policies are watched for and related changes are done in a calico-etcd so that agents on nodes can implement firewall rules accordingly. Starting on this line, events are handled, of course you will have to navigate the stack further! <a href="https://github.com/projectcalico/libcalico-go/blob/master/lib/backend/watchersyncer/watchercache.go#L93" rel="nofollow noreferrer">Code</a></p>
