The q
plugin queries the namespace for a pod and prompts the user for selection, after which it will forward the selected pod to a provided kubectl command. Some commands are handled directly by q
and require further input from the user, simpler use cases should be handled by the custom
command.
This plugin is not yet available in the krew index, but can be installed directly from the repository (go1.20 required).
# edit makefile to set the correct plugin path
make build
kubectl q [command] [flags]
kubectl q custom [flags] -- [command + args + optional(replacement string)]
This command will prompt the user for a pod and then forward the selected pod to the provided command. The command must be provided after the --
flag as the first argument. The pod name will replace every instance of the string %%
in the command.
# Describe the selected pod
kubectl q custom -- describe pod # -> kubectl describe pod <pod>
# Follow the logs of the selected pod (custom is the default command)
kubectl q -- logs -f # -> kubectl logs -f <pod>
# Execute a custom command on the selected pod (tty not supported)
kubectl q -- exec %% -- ls # -> kubectl exec <pod> -- ls
kubectl q port-forward [flags] -- [args]
This command will prompt the user for a pod and then forward the selected ports using the kubectl port-forward command.
kubectl q -r [regex]
This flag will filter the list of pods by the provided regex. The regex is applied to the pod name.