<p>Worker node is getting into "NotReady" state with an error in the output of <strong>kubectl describe node</strong>:</p>

<p>ContainerGCFailed  rpc error: code = DeadlineExceeded desc = context deadline exceeded</p>

<p>Environment: </p>

<p>Ubuntu, 16.04 LTS</p>

<p>Kubernetes version: v1.13.3</p>

<p>Docker version: 18.06.1-ce</p>

<p>There is a closed issue on that on Kubernetes GitHub <a href="https://github.com/kubernetes/kubernetes/issues/42164" rel="noreferrer">k8 git</a>, which is closed on the merit of being related to Docker issue. </p>

<p>Steps done to troubleshoot the issue: </p>

<ol>
<li><strong>kubectl describe node</strong> - error in question was found(root cause isn't clear). </li>
<li><p><strong>journalctl -u kubelet</strong> - shows this related message:</p>

<p>skipping pod synchronization - [container runtime status check may not have completed yet PLEG is not healthy: pleg has yet to be successful]</p>

<p>it is related to this open k8 issue <a href="https://github.com/kubernetes/kubernetes/issues/45419" rel="noreferrer">Ready/NotReady with PLEG issues</a></p></li>
<li><p>Check node health on AWS with cloudwatch - everything seems to be fine.</p></li>
<li><strong>journalctl -fu docker.service</strong> : check docker for errors/issues -
 the output doesn't show any erros related to that.</li>
<li><strong>systemctl restart docker</strong> - after restarting docker, the node gets into "Ready" state but in  3-5 minutes becomes "NotReady" again. </li>
</ol>

<p>It all seems to start when I deployed more pods to the node( close to its resource capacity but don't think that it is direct dependency) or was stopping/starting instances( after restart it is ok, but after some time node is NotReady).</p>

<p>Questions: </p>

<p>What is the root cause of the error?</p>

<p>How to monitor that kind of issue and make sure it doesn't happen? </p>

<p>Are there any workarounds to this problem?</p>

Alexz
<blockquote>
  <p>What is the root cause of the error?</p>
</blockquote>

<p>From what I was able to find it seems like the error happens when there is an issue contacting Docker, either because it is overloaded or because it is unresponsive. This is based on my experience and what has been mentioned in the GitHub issue you provided. </p>

<blockquote>
  <p>How to monitor that kind of issue and make sure it doesn't happen?</p>
</blockquote>

<p>There seem to be no clarified mitigation or monitoring to this. But it seems like the best way would be to make sure your node will not be overloaded with pods. I have seen that it is not always shown on disk or memory pressure of the Node - but this is probably a problem of not enough resources allocated to Docker and it fails to respond in time. Proposed solution is to set limits for your pods to prevent overloading the Node. </p>

<p>In case of managed Kubernetes in GKE (not sure but other vendors probably have similar feature) there is a feature called <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/node-auto-repair" rel="noreferrer">node auto-repair</a>. Which will not prevent node pressure or Docker related issue but when it detects an unhealthy node it can drain and redeploy the node/s. </p>

<p>If you already have resources and limits it seems like the best way to make sure this does not happen is to increase memory resource requests for pods. This will mean fewer pods per node and the actual used memory on each node should be lower. </p>

<p>Another way of monitoring/recognizing this could be done by SSH into the node check the memory, the processes with <code>PS</code>, monitoring the <code>syslog</code> and <a href="https://docs.docker.com/engine/reference/commandline/stats/#usage" rel="noreferrer">command</a> <code>$docker stats --all</code></p>
