Skip to content

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

ArgumentDescription
<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

OptionDescription
-c, --container stringContainer 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 stringsto use to exec into the resource
--pod-running-timeout durationThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
-q, --quietOnly print output from the remote session
-i, --stdinPass stdin to the container
-t, --ttyStdin is a TTY
…kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them

Global options

OptionDescription
--no-colorDisable styled output
-h, --helpShow this message and exit

Examples

kx exec 1
kx exec 1 -- ls /app
kx exec 1 -c sidecar
kx exec @api