Skip to content

Instantly share code, notes, and snippets.

@achanda
Created August 10, 2017 15:47
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 achanda/05f70b186ab6c5f38372bee18bde00b2 to your computer and use it in GitHub Desktop.
Save achanda/05f70b186ab6c5f38372bee18bde00b2 to your computer and use it in GitHub Desktop.
$USER="autodeploy"
kubectl create "$USER"
secret=$(kubectl get sa "$USER" -o json | jq -r .secrets[].name)
kubectl get secret $secret -o json | jq -r '.data["ca.crt"]' | base64 -D > ca.crt
user_token=$(kubectl get secret $secret -o json | jq -r '.data["token"]' | base64 -D)
kubectl config set-cluster mycluster \
--embed-certs=true \
--server="$ENDPOINT" \
--certificate-authority=./ca.crt
kubectl config set-credentials "$USER" --token="$user_token"
kubectl config set-context deployment-context \
--cluster=mycluster \
--user="$USER
kubectl config use-context deployment-context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment