Oh-My-Zsh Kubectl

Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser.

This cheat sheet refers to the Kubectl plugin for Oh My Zsh.

Note: Unless otherwise stated, commands work within the current Namespace context. Use -n|--namespace <namespace> as part of the command-line to change the target.

Aliases

k

kubectl

The kubectl command.

kaf

kubectl apply -f

Apply resources as described by the YAML file(s) specified after the -f argument.

kca

kubectl --all-namespaces

Apply the subsequent command across all Namespaces.

kccc

kubectl config current-context

Display the current context.

kcdc

kubectl config delete-context

Delete the specified context from the kubeconfig file.

kcgc

kubectl config get-contexts

List all available contexts.

kcn

kubectl config set-context --current --namespace

Change the current Namespace context.

kcp

kubectl cp

Copy files and directories to/from containers.

kcsc

kubectl config set-context

Set a context entry in kubeconfig file.

kcuc

kubectl config use-context

Set the current context in the kubeconfig file.

kdcj

kubectl describe cronjob

Display details about CronJob resource(s).

kdcm

kubectl describe configmap

Display details about ConfigMap resource(s).

kdd

kubectl describe deployment

Display details about Deployment resource(s).

kdds

kubectl describe daemonset

Display details about DaemonSet resource(s).

kdel

kubectl delete

Delete resources by filenames, stdin, resources and names, or by resources and label selector.

kdelcj

kubectl delete cronjob

Delete CronJob resources matching the name(s) passed.

kdelcm

kubectl delete configmap

Delete ConfigMap resources matching the name(s) passed.

kdeld

kubectl delete deployment

Delete Deployment resources matching the name(s) passed.

kdelds

kubectl delete daemonset

Delete DaemonSets resources matching the name(s) passed.

kdelf

kubectl delete -f

Delete resources described by the YAML file(s) specified with the -f argument.

kdeli

kubectl delete ingress

Delete Ingress resources matching the name(s) passed.

kdelj

kubectl delete job

Delete Job resources matching the name(s) passed.

kdelno

kubectl delete node

Delete Node resources matching the name(s) passed.

kdelns

kubectl delete namespace

Delete the specified Namespace(s). WARNING: This deletes everything in the Namespace!

kdelp

kubectl delete pods

Delete Pod resources matching the name(s) passed.

kdelpvc

kubectl delete pvc

Delete PersistentVolumeClaim resources matching the name(s) passed.

kdels

kubectl delete svc

Delete Service resources matching the name(s) passed.

kdelsa

kubectl delete sa

Delete ServiceAccount resources matching the name(s) passed.

kdelsec

kubectl delete secret

Delete Secret resources matching the name(s) passed.

kdelss

kubectl delete statefulset

Delete StatefulSet resources matching the name(s) passed.

kdi

kubectl describe ingress

Display details about Ingress resource(s).

kdj

kubectl describe job

Display details about Job resources(s).

kdno

kubectl describe node

Display details about Node resources(s).

kdns

kubectl describe namespace

Display details about Namespace resources(s).

kdp

kubectl describe pods

Display details about Pod resources(s).

kdpvc

kubectl describe pvc

Display details about PersistentVolumeClaim resources(s).

kdrs

kubectl describe replicaset

Display details about ReplicaSet resources(s).

kds

kubectl describe svc

Display details about Service resources(s).

kdsa

kubectl describe sa

Display details about ServiceAccount resources(s).

kdsec

kubectl describe secret

Display details about Secret resource(s).

kdss

kubectl describe statefulset

Display details about StatefulSet resource(s).

kecj

kubectl edit cronjob

Edit a CronJob with the default editor.

kecm

kubectl edit configmap

Edit a ConfigMap with the default editor.

ked

kubectl edit deployment

Edit a Deployment with the default editor.

keds

kubectl edit daemonset

Edit a DaemonSet with the default editor.

kei

kubectl edit ingress

Edit an Ingress with the default editor.

kej

kubectl edit job

Edit a Job with the default editor.

keno

kubectl edit node

Edit a Node with the default editor.

kens

kubectl edit namespace

Edit a Namespace with the default editor.

kep

kubectl edit pods

Edit a Pod with the default editor.

kepvc

kubectl edit pvc

Edit a PersistentVolumeClaim with the default editor.

kers

kubectl edit replicaset

Edit a ReplicaSet with the default editor.

kes

kubectl edit svc

Edit a Service (svc) with the default editor.

kess

kubectl edit statefulset

Edit a StatefulSet with the default editor.

keti

kubectl exec -ti

Open an interactive terminal session in a container.

kga

kubectl get all

List all resources in tabular output format.

kgaa

kubectl get all --all-namespaces

List all resources across all Namespaces in the cluster (tabular output).

kgcj

kubectl get cronjob

List specified/all CronJobs in tabular output format.

kgcm

kubectl get configmaps

List specified/all ConfigMaps in tabular output format.

kgd

kubectl get deployment

List specified/all Deployments in tabular output format.

kgds

kubectl get daemonset

List specified/all DaemonSets in tabular output format.

kgdsw

kgds --watch

List specified/all DaemonSets and watch for changes.

kgdw

kgd --watch

List specified/all Deployments and watch for changes.

kgdwide

kgd -o wide

List specified/all Deployments with additional columns of information.

kgi

kubectl get ingress

List specified/all Ingresses in tabular output format.

kgj

kubectl get job

List specified/all Jobs in tabular output format.

kgno

kubectl get nodes

List specified/all Nodes in tabular output format.

kgns

kubectl get namespaces

List specified/all Namespaces in a cluster (tabular output).

kgp

kubectl get pods

List specified/all Pods in tabular output format.

kgpl

kgp -l

Get Pods by Label. Example: kgpl "app=myapp" -n myns

kgpn

kgp -n

Get Pods by Namespace. Example: kgpn kube-system

kgpvc

kubectl get pvc

List specified/all PersistentVolumeClaims in tabular output format.

kgpvcw

kgpvc --watch

List specified/all PersistentVolumeClaims and watch for changes.

kgpw

kgp --watch

List specified/all Pods and watch for changes.

kgpwide

kgp -o wide

List specified/all Deployments with additional columns of information.

kgrs

kubectl get replicaset

List specified/all ReplicaSets in tabular output format.

kgs

kubectl get svc

List specified/all Services in tabular output format.

kgsec

kubectl get secret

List specified/all Secrets in tabular output format.

kgss

kubectl get statefulset

List specified/all StatefulSets in tabular output format.

kgssw

kgss --watch

List specified/all StatefulSets and watch for changes.

kgsswide

kgss -o wide

List specified/all StatefulSets with additional columns of information.

kgsw

kgs --watch

List specified/all Services and watch for changes.

kgswide

kgs -o wide

List specified/all Services with additional columns of information.

kl

kubectl logs

Display the logs for a container or resource.

klf

kubectl logs -f

Stream (follow) the logs for a container or resource.

kpf

kubectl port-forward

Forward one or more local ports to a Pod.

kres

kubectl set env $@ REFRESHED_AT=...

Recreate all Pods in a Deployment with zero-downtime.

krh

kubectl rollout history

Check the revisions of a Deployment.

krsd

kubectl rollout status deployment

Check the rollout status of a Deployment.

krsss

kubectl rollout status statefulset

Check the rollout status of a StatefulSet.

kru

kubectl rollout undo

Rollback to the previous revision.

ksd

kubectl scale deployment

Scale a Deployment.

ksss

kubectl scale statefulset

Scale a StatefulSet.

Wrappers

kj

JSON, colorized with jq

kjx

JSON, colorized with fx

ky

YAML, colorized with yh