# Document for exec command api endpoint?

**URL:** <https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242>\
**Category:** General Discussions\
**Created:** [August 28, 2021, 6:31pm UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242 "2021-08-28T18:31:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Code\_Dirty](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/code_dirty/32/8468_2.png) [@Code\_Dirty](https://discuss.kubernetes.io/u/Code_Dirty)\
**Post date:** [August 28, 2021, 6:31pm UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242/1 "2021-08-28T18:31:14Z")

</div>

i cannot found any exec command apiserver endpoint in kubernetes pages. In particular, it is worse if it is not a pod. I could not find the contents of the command to exec for deployment anywhere.

```auto
kubectl exec deploy/[deploymentname] -- commands

```

Is there any documentation with information about this?

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [August 28, 2021, 10:31pm UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242/2 "2021-08-28T22:31:39Z")

</div>

As far as I know you can’t run exec against any resource other than pods.

The API path is `/api/v1/namespaces/{namespace}/pods/{name}/exec`. Also [it doesn’t appear to be documented](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/). I had to find this by looking at the [python client code](https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api/core_v1_api.py).

---

<div class="post-metadata">

**Author:** ![rael](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rael/32/2769_2.png) [@rael](https://discuss.kubernetes.io/u/rael)\
**Post date:** [August 29, 2021, 6:29am UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242/3 "2021-08-29T06:29:50Z")

</div>

The documentation can be found in the `kubectl`reference docs:

[https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec)

And some examples at:

> **[Get a Shell to a Running Container](https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/)**
>
> This page shows how to use kubectl exec to get a shell to a running container.
> Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run...

You can run against a deployment, it will only be executed in the _first_ pod:

```auto
❯ kubectl exec --help
Execute a command in a container.

Examples:
  # Get output from running 'date' command from pod mypod, using the first container by default
  kubectl exec mypod -- date

```

To broadcast a command to all pods, you can always pipe the commands like:

```auto
❯ k get pods -l k8s-app=traefik -o name | xargs -n 1 -I {} echo kubectl exec {} comand
kubectl exec pod/kubone-k8s-traefik-ds-4d4xw comand
kubectl exec pod/kubone-k8s-traefik-ds-jjlgn comand

```

---

<div class="post-metadata">

**Author:** ![rael](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rael/32/2769_2.png) [@rael](https://discuss.kubernetes.io/u/rael)\
**Post date:** [August 29, 2021, 6:54am UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242/4 "2021-08-29T06:54:42Z")

</div>

The API documentation is:

[https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#execaction-v1-core](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#execaction-v1-core)

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [August 29, 2021, 7:17am UTC](https://discuss.kubernetes.io/t/document-for-exec-command-api-endpoint/17242/5 "2021-08-29T07:17:02Z")

</div>

I saw that and wasn’t confident that was `pods/{name}/exec`. There’s HTTP Requests documented for things like `eviction`, `status`, `ephemeralcontainers`, and so on. Seems weird that `exec` doesn’t have something similar.

On another note, I’m slightly confused now as to if OP wanted API references or kubectl command references. Assumed the mention of using kubectl was demonstrating what OP wanted to do with the underlying API.
