Skip to content

Instantly share code, notes, and snippets.

@dfar-io
Created July 10, 2019 18:17
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 dfar-io/f8c7a8b92c3c7cd86176e582f28fa2c5 to your computer and use it in GitHub Desktop.
Save dfar-io/f8c7a8b92c3c7cd86176e582f28fa2c5 to your computer and use it in GitHub Desktop.
Programmatically adds a AKS cluster to a Ubuntu box
#!/bin/bash
set -e
set -o pipefail
if [ "$1" == "" ]
then
echo "AKS RG is required."
exit 1
fi
if [ "$2" == "" ]
then
echo "AKS Name is required."
exit 1
fi
if [ "$3" == "" ]
then
echo "Subscription ID is required."
exit 1
fi
if [ "$4" == "" ]
then
echo "Context name is required."
exit 1
fi
echo Connecting to AKS...
az aks get-credentials -g $1 -n $2 --subscription $3
echo Renaming cluster...
kubectl config set-context $4 --cluster $2 --user clusterUser_$1_$2
kubectl config delete-context $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment