Skip to content

Instantly share code, notes, and snippets.

@p0vidl0
Last active August 25, 2021 04:00
Show Gist options
  • Save p0vidl0/844181f7f11dd7922e9e1433999c5f7b to your computer and use it in GitHub Desktop.
Save p0vidl0/844181f7f11dd7922e9e1433999c5f7b to your computer and use it in GitHub Desktop.
Kubectl cheat sheet

Import cluster to kubeconfig

aws eks --region us-west-2 update-kubeconfig --name CLUSTER_NAME

Show current kubectl context

kubectl config current-context

Rename kubectl context

kubectl config rename-context CURRENT_NAME NEW_NAME

Show all kubectl contexts

kubectl config get-contexts

Switch kubectl to the context

kubectl config use-context CONTEXT_NAME

Set default namespace for the context

kubectl config set-context --current --namespace=NAMESPACE

Forward port from pod to localhost

kubectl port-forward pod/POD_NAME LOCAL_PORT:POD_PORT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment