<p>I am deploy a elasticsearch cluster in kubernetes,now the cluster pod restart for many times.For elasticsearch cluster stable,I want to find out why the cluster restart.Now I check the restart pods log it only shows the restarted log output,but the restarted log is no errors,I try to set the cluster not start automatic and I could see the error output on fail,It shows:</p>

<pre><code>StatefulSet.apps "es-cluster" is invalid: spec.template.spec.restartPolicy: Unsupported value: "Never": supported values: "Always"
</code></pre>

<p>so which is the best way to find out why the pods restart?</p>

<p><a href="https://i.stack.imgur.com/Jhmht.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jhmht.png" alt="enter image description here"></a></p>

<p>To get a detailed view of the log snipper or immediate reasons for startup failures of a pod, run</p>

<pre><code>kubectl describe pod &lt;pod&gt; -n &lt;namespace&gt;
</code></pre>

<p>Ideally you should run it as soon as a pod restarts (or you can force it by deleting the pod). This can/should be done in addition to the above comment that suggests tailing the logs, up to the moment when the pods fail to start. Be mindful that if there are multiple containers in a pod you may also need to </p>

<pre><code>kubectl logs -f &lt;pod&gt; -n &lt;namespace&gt; -c &lt;container name&gt; --previous
</code></pre>

<p>Cheers</p>
