sample kubectl config

I seem to always forget the syntax for setting up a new connection to a cluster via kubectl. Here's my quick cheat sheet which just is what I typically use:

kubectl config set-cluster <env> --server=<apiServer>  
kubectl config set-context <env> --cluster=<env> --user=<env> --namespace=<namespace>  
kubectl config set-credentials <env> --token=<token>  
kubectl config use-context <env>  

NOTE: This setup assumes the you are using tokens for auth to the cluster.

Legend:

  • env = What you want to use to reference the environment
  • token = The token to access the API server
  • namespace = Namespace to use if not wanting to use default