<p>I'm aware of the usual way to "tail --follow" logs of a Kubernetes service:</p>

<pre><code>kubectl logs -f -lapp=service-name --all-containers=true
</code></pre>

<p>But every time I push a change to this service the <code>kubectl</code> dies when the pods get killed and I have to run it again.</p>

<p>Example error message:</p>

<blockquote>
  <p>Received interrupt, cleaning up...
  rpc error: code = Unknown desc = Error: No such container: b48a1ad3c0080680465c79903d03748a026becf397bc780921674b2f0d7078ffReceived interrupt, cleaning up...</p>
  
  <p>rpc error: code = Unknown desc = Error: No such container: 6258e31702ea678eacec5ad0df15b5620b5609cd5e4822f2e4991fd26c9906b6
  $</p>
</blockquote>

<p>What I wonder is if there is a way to tell Kubernetes to keep looking for new pods which match the <code>-lapp=service-name</code> tag and tail them. A bit similar to <code>tail --follow=name --retry</code></p>

<p>I suppose I can run the command in a simple shell loop but was wondering if there is something smarter that can use <code>Kubernetes</code>, one which will avoid lots of errors while the new pods get deployed.</p>

<p>What about instead of using <a href="https://github.com/wercker/stern" rel="nofollow noreferrer"><code>stern</code></a>?</p>

<p>Basically, you can use the same structure of the command, just replace <code>kubectl logs -f -lapp=service-name --all-containers=true</code> into <code>stern -l app=service-name</code></p>
