quick notes

Using kubectl: First thing is getting bash completion

source <$(kubectl completion bash)

and make it permanent

kubectl completion bash > .bash_kubectl
echo "source ~/.bash_kubectl" >> ~/.bashrc"

Using kubectl effectively

kubectl is your Swiss Army knife. It can do pretty much anything around a cluster. Under the hood, kubectl connects to your cluster via the API. It reads your ~/.kube/config file (by default, this can be overridden with the KUBECONFIG environment variable or the --kubeconfig command-line argument), which contains the information necessary to connect to your cluster or clusters. The commands are divided into multiple categories:

  • Generic commands: Deal with resources in a generic way: create, get, delete, run, apply, patch, replace, and so on

  • Cluster management commands: Deal with nodes and the cluster at large: cluster-info, certificate, drain, and so on

  • Troubleshooting commands: describe, logs, attach, exec, and so on

  • Deployment commands: Deal with deployment and scaling: rollout, scale, auto-scale, and so on

  • Settings commands: Deal with labels and annotations: label, annotate, and so on

  • Misc commands: help, config, version

  • Customization commands: Integrate the kustomize.io capabilities into kubectl

  • Configuration commands: Deal with contexts, switch between clusters and namespaces, set current context and namespace, and so on


Common commands

Last updated