Skip to content

Instantly share code, notes, and snippets.

@acmlira
Created July 19, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acmlira/a8f2536c5a7ff4d8646ba0d2903ea3bf to your computer and use it in GitHub Desktop.
Save acmlira/a8f2536c5a7ff4d8646ba0d2903ea3bf to your computer and use it in GitHub Desktop.
How to connect to a k8s cluster
export K8S_USER="my-user"
export K8S_CLUSTER="my-cluster"
export K8S_TOKEN="my-token"
kubectl config set-cluster ${K8S_CLUSTER} --server=https://api.${K8S_CLUSTER} --insecure-skip-tls-verify=true
kubectl config set-context ${K8S_USER}-${K8S_CLUSTER} --cluster=${K8S_CLUSTER} --user=${K8S_USER}
kubectl config use-context ${K8S_USER}-${K8S_CLUSTER}
kubectl config set-credentials ${K8S_USER} -- ${K8S_TOKEN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment