kx exec
Runs a command inside an indexed resource. With no command, tries each configured shell in turn — bash, then sh, unless the shells key in the config file says otherwise.
Given a workload rather than a Pod, kubectl picks one of its pods — the same way kx port-forward leaves the choice to kubectl. Which pod is not guaranteed to be the same one across the shell probe and the session that follows.
A flag kx doesn’t know is refused.
Usage
kx exec [OPTIONS] <index> [kubectl flags] [-- command...]Arguments
| Argument | Description |
|---|---|
<index> | Row number from the current listing, or @name for a mark; kx state or kx mark shows them |
[command]... | Command to run in the pod instead of a shell |
Passthrough options
| Option | Description |
|---|---|
-c, --container string | Container name. If omitted, use the kubectl.kubernetes.io/default-container annotation for selecting the container to be attached or the first container in the pod will be chosen |
-f, --filename strings | to use to exec into the resource |
--pod-running-timeout duration | The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running |
-q, --quiet | Only print output from the remote session |
-i, --stdin | Pass stdin to the container |
-t, --tty | Stdin is a TTY |
… | kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them |
Global options
| Option | Description |
|---|---|
--no-color | Disable styled output |
-h, --help | Show this message and exit |
Examples
kx exec 1
kx exec 1 -- ls /app
kx exec 1 -c sidecar
kx exec @api