Skip to content

kubectl

Default config location

~/.kube/config

Dry run and sending output to a local YAML file

kubectl create deployment --image hello-world hello --dry-run=client -o yaml > hello-world.yaml
kubectl describe pod hello-5b464657d4-2lb9q

Updating current config / context

If Kubernetes client is installed (with Docker), an easy way to toggle the context is via service icon.

Alternative via the following...

kubectl config set-context default
kubectl config set-context docker-desktop

Check current cluster config

kubectl cluster-info

Notes on .kube/config

  • It can contain references to multiple cluster instances
  • From within the Kubernetes plugin for VSCode, you can switch between cluster instances (although note that you'll need to right-click and select "Set as Current Cluster")