<p>Is there a way to get a command and image which the pod is running in GKE? To my knowledge <code>kubectl</code> does not have this facility. Maybe it's possible to do so with some dedicated <code>gcloud</code> tool? <code>docker ps</code>, <code>kubectl exec ps</code> is not an option unfortunately.</p>

Some Name
<p><code>kubectl</code> gives you a variety of options, among those is <code>describe</code>, which let's you get the information you are looking for like so:</p>
<pre><code>$ kubectl describe pods etcd-minikube
Name:                 etcd-minikube
Namespace:            kube-system
Priority:             2000001000
Priority Class Name:  system-node-critical
Node:                 minikube/192.168.49.2
Start Time:           Fri, 21 Apr 2023 14:57:11 +0200
Labels:               component=etcd
                      tier=control-plane
Annotations:          kubeadm.kubernetes.io/etcd.advertise-client-urls: https://192.168.49.2:2379
                      kubernetes.io/config.hash: 9d3d310935e5fabe942511eec3e2cd0c
                      kubernetes.io/config.mirror: 9d3d310935e5fabe942511eec3e2cd0c
                      kubernetes.io/config.seen: 2023-04-21T12:57:10.854200840Z
                      kubernetes.io/config.source: file
                      seccomp.security.alpha.kubernetes.io/pod: runtime/default
Status:               Running
SeccompProfile:       RuntimeDefault
IP:                   192.168.49.2
IPs:
  IP:           192.168.49.2
Controlled By:  Node/minikube
Containers:
  etcd:
    Container ID:  docker://172b7490d79dcb36f2c81e3ce82611b18c09f128b5030c7b225636b345d5c7d4
    Image:         k8s.gcr.io/etcd:3.5.1-0
    Image ID:      docker-pullable://k8s.gcr.io/etcd@sha256:64b9ea357325d5db9f8a723dcf503b5a449177b17ac87d69481e126bb724c263
    Port:          &lt;none&gt;
    Host Port:     &lt;none&gt;
    Command:
      etcd
      --advertise-client-urls=https://192.168.49.2:2379
      --cert-file=/var/lib/minikube/certs/etcd/server.crt
      --client-cert-auth=true
      --data-dir=/var/lib/minikube/etcd
      --initial-advertise-peer-urls=https://192.168.49.2:2380
      --initial-cluster=minikube=https://192.168.49.2:2380
      --key-file=/var/lib/minikube/certs/etcd/server.key
      --listen-client-urls=https://127.0.0.1:2379,https://192.168.49.2:2379
      --listen-metrics-urls=http://127.0.0.1:2381
      --listen-peer-urls=https://192.168.49.2:2380
      --name=minikube
      --peer-cert-file=/var/lib/minikube/certs/etcd/peer.crt
      --peer-client-cert-auth=true
      --peer-key-file=/var/lib/minikube/certs/etcd/peer.key
      --peer-trusted-ca-file=/var/lib/minikube/certs/etcd/ca.crt
      --proxy-refresh-interval=70000
      --snapshot-count=10000
      --trusted-ca-file=/var/lib/minikube/certs/etcd/ca.crt
</code></pre>
<p>If you need to access things programmatically, you can also use <code>get</code> and json format the output to then pipe into utilities like <code>jq</code> like so:</p>
<pre><code>$ kubectl get pod etcd-minikube -o json
{
    &quot;apiVersion&quot;: &quot;v1&quot;,
    &quot;kind&quot;: &quot;Pod&quot;,
    &quot;metadata&quot;: {
        &quot;annotations&quot;: {
            &quot;kubeadm.kubernetes.io/etcd.advertise-client-urls&quot;: &quot;https://192.168.49.2:2379&quot;,
            &quot;kubernetes.io/config.hash&quot;: &quot;9d3d310935e5fabe942511eec3e2cd0c&quot;,
            &quot;kubernetes.io/config.mirror&quot;: &quot;9d3d310935e5fabe942511eec3e2cd0c&quot;,
            &quot;kubernetes.io/config.seen&quot;: &quot;2023-04-21T12:57:10.854200840Z&quot;,
            &quot;kubernetes.io/config.source&quot;: &quot;file&quot;,
            &quot;seccomp.security.alpha.kubernetes.io/pod&quot;: &quot;runtime/default&quot;
        },
        &quot;creationTimestamp&quot;: &quot;2023-04-21T12:57:11Z&quot;,
        &quot;labels&quot;: {
            &quot;component&quot;: &quot;etcd&quot;,
            &quot;tier&quot;: &quot;control-plane&quot;
        },
        &quot;name&quot;: &quot;etcd-minikube&quot;,
        &quot;namespace&quot;: &quot;kube-system&quot;,
        &quot;ownerReferences&quot;: [
            {
                &quot;apiVersion&quot;: &quot;v1&quot;,
                &quot;controller&quot;: true,
                &quot;kind&quot;: &quot;Node&quot;,
                &quot;name&quot;: &quot;minikube&quot;,
                &quot;uid&quot;: &quot;cfe42b77-7cfc-4248-af39-1dec62196242&quot;
            }
        ],
        &quot;resourceVersion&quot;: &quot;294&quot;,
        &quot;uid&quot;: &quot;58dced46-2ac0-4986-bced-5e7f9a097cf9&quot;
    },
    &quot;spec&quot;: {
        &quot;containers&quot;: [
            {
                &quot;command&quot;: [
                    &quot;etcd&quot;,
                    &quot;--advertise-client-urls=https://192.168.49.2:2379&quot;,
                    &quot;--cert-file=/var/lib/minikube/certs/etcd/server.crt&quot;,
                    &quot;--client-cert-auth=true&quot;,
                    &quot;--data-dir=/var/lib/minikube/etcd&quot;,
                    &quot;--initial-advertise-peer-urls=https://192.168.49.2:2380&quot;,
                    &quot;--initial-cluster=minikube=https://192.168.49.2:2380&quot;,
                    &quot;--key-file=/var/lib/minikube/certs/etcd/server.key&quot;,
                    &quot;--listen-client-urls=https://127.0.0.1:2379,https://192.168.49.2:2379&quot;,
                    &quot;--listen-metrics-urls=http://127.0.0.1:2381&quot;,
                    &quot;--listen-peer-urls=https://192.168.49.2:2380&quot;,
                    &quot;--name=minikube&quot;,
                    &quot;--peer-cert-file=/var/lib/minikube/certs/etcd/peer.crt&quot;,
                    &quot;--peer-client-cert-auth=true&quot;,
                    &quot;--peer-key-file=/var/lib/minikube/certs/etcd/peer.key&quot;,
                    &quot;--peer-trusted-ca-file=/var/lib/minikube/certs/etcd/ca.crt&quot;,
                    &quot;--proxy-refresh-interval=70000&quot;,
                    &quot;--snapshot-count=10000&quot;,
                    &quot;--trusted-ca-file=/var/lib/minikube/certs/etcd/ca.crt&quot;
                ],
</code></pre>
<p>If for a given image that a pod uses, you would like to get the command of the actual container image and not the one that is passed via its spec, you can use the information about the image and then docker inspect. The following image is deployed as per the <a href="https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/" rel="nofollow noreferrer">kubernetes documentation</a>, so it does not have a command in the spec but still runs nginx.</p>
<p>Get the right pods (they are both the same in our case)</p>
<pre><code>$ kubectl get pods | grep nginx
nginx-deployment-9456bbbf9-gqzhp   1/1     Running   0             10m
nginx-deployment-9456bbbf9-lthrc   1/1     Running   0             10m
</code></pre>
<p>Use one of them and get the container image:</p>
<pre><code>$ kubectl get pod nginx-deployment-9456bbbf9-gqzhp -o jsonpath=&quot;{.spec.containers[*].image}&quot;
nginx:1.14.2
</code></pre>
<p>Use <code>docker image inspect</code> to analyze the image (not that you have to have it pulled)</p>
<pre><code>$ docker pull nginx:1.14.2
1.14.2: Pulling from library/nginx
007027d142c8: Pull complete
925342e1fcde: Pull complete
668b9ac9804b: Pull complete
Digest: sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
Status: Downloaded newer image for nginx:1.14.2
docker.io/library/nginx:1.14.2

$ docker image inspect nginx:1.14.2
[
    {
        &quot;Id&quot;: &quot;sha256:7bbc8783b8ecfdb6453396805cc0fb5fcdaf1b16cbb907c8ab1b8685732d50a4&quot;,
        &quot;RepoTags&quot;: [
            &quot;nginx:1.14.2&quot;
        ],
        &quot;RepoDigests&quot;: [
            &quot;nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d&quot;
        ],
        &quot;Parent&quot;: &quot;&quot;,
        &quot;Comment&quot;: &quot;&quot;,
        &quot;Created&quot;: &quot;2019-03-27T09:51:29.346495571Z&quot;,
        &quot;Container&quot;: &quot;877b55d528f890d650358f37048a361f24b8c4d1e414c79e4d2c82bb8d186310&quot;,
        &quot;ContainerConfig&quot;: {
            &quot;Hostname&quot;: &quot;877b55d528f8&quot;,
            &quot;Domainname&quot;: &quot;&quot;,
            &quot;User&quot;: &quot;&quot;,
            &quot;AttachStdin&quot;: false,
            &quot;AttachStdout&quot;: false,
            &quot;AttachStderr&quot;: false,
            &quot;ExposedPorts&quot;: {
                &quot;80/tcp&quot;: {}
            },
            &quot;Tty&quot;: false,
            &quot;OpenStdin&quot;: false,
            &quot;StdinOnce&quot;: false,
            &quot;Env&quot;: [
                &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;,
                &quot;NGINX_VERSION=1.14.2-1~stretch&quot;,
                &quot;NJS_VERSION=1.14.2.0.2.6-1~stretch&quot;
            ],
            &quot;Cmd&quot;: [
                &quot;/bin/sh&quot;,
                &quot;-c&quot;,
                &quot;#(nop) &quot;,
                &quot;CMD [\&quot;nginx\&quot; \&quot;-g\&quot; \&quot;daemon off;\&quot;]&quot;
</code></pre>
<p>Now make it a one-line using <code>jq</code>:</p>
<pre><code>$ docker pull $(kubectl get pod nginx-deployment-9456bbbf9-gqzhp -o jsonpath=&quot;{.spec.containers[*].image}&quot;) &amp;&amp; docker image inspect $(kubectl get pod nginx-deployment-9456bbbf9-gqzhp -o jsonpath=&quot;{.spec.containers[*].image}&quot;) | jq .[].ContainerConfig.Cmd
1.14.2: Pulling from library/nginx
Digest: sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
Status: Image is up to date for nginx:1.14.2
docker.io/library/nginx:1.14.2
[
  &quot;/bin/sh&quot;,
  &quot;-c&quot;,
  &quot;#(nop) &quot;,
  &quot;CMD [\&quot;nginx\&quot; \&quot;-g\&quot; \&quot;daemon off;\&quot;]&quot;
]
</code></pre>
