<p>Is it possible to run commands on host from within a pod in kubernetes.</p>

<p>So for example, I have a pod running a python image which calculates the size of the os. But the command it uses runs inside the pod, not in the host. Is it possible to run the command on the host from pod.</p>

S Andrew
<p>Actually a command run inside a pod is run on the host. It's a container (Docker), not a virtual machine.
That means when you execute something in the pod like retrieving the size of your RAM it will usually return the RAM of the whole machine.
If you want to get the "size of the os" and you mean the hard drive with it, you need to mount the hard drive to count it.</p>

<p>If your actual problem is that you want to do something, which a normal container isn't allowed to, you can run a pod in <em>privileged</em> mode or configure whatever you exactly need.
You need to add a <em>security context</em> to your pod like this (taken from the docs):</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo
spec:
  securityContext:
    runAsUser: 1000
    fsGroup: 2000
  volumes:
  - name: sec-ctx-vol
    emptyDir: {}
  containers:
  - name: sec-ctx-demo
    image: gcr.io/google-samples/node-hello:1.0
    volumeMounts:
    - name: sec-ctx-vol
      mountPath: /data/demo
    securityContext:
      privileged: true
</code></pre>

<p>Sources:</p>

<ul>
<li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/security-context/</a></li>
<li><a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/#privileged" rel="noreferrer">https://kubernetes.io/docs/concepts/policy/pod-security-policy/#privileged</a></li>
</ul>
