<p>I have a Python script that should have slightly different behaviour if it's running inside a Kubernetes pod.</p>
<p>But how can I find out that whether I'm running inside Kubernetes -- or not?</p>

Felix
<p>An easy way I use (and it's not Python specific), is to check whether <code>kubernetes.default.svc.cluster.local</code> resolves to an IP (you don't need to try to access, just see if it resolves successfully)</p>
<p>If it does, the script/program is running inside a cluster. If it doesn't, proceed on the assumption it's not running inside a cluster.</p>
