Skip to content

Instantly share code, notes, and snippets.

@ljtill
Last active March 1, 2023 17:46
Show Gist options
  • Save ljtill/1729c81af237c1d0a5c1720d6d81abc4 to your computer and use it in GitHub Desktop.
Save ljtill/1729c81af237c1d0a5c1720d6d81abc4 to your computer and use it in GitHub Desktop.
Provides the ability to create / delete multiple Kubernetes clusters
#!/bin/bash
configuration=$(cat ./resources.json)
length=$(echo $configuration | jq -r ".clusters | length")
for ((i=0; i<length; i++)); do
read name location country <<< $(echo $configuration | jq -r ".clusters[$i] | [.name, .location, .country] | @tsv")
echo "=> Creating Kubernetes cluster ($country)..."
az aks create \
--resource-group "Management" \
--name $name \
--location $location \
--min-count "3"\
--max-count "175" \
--enable-cluster-autoscaler \
--node-vm-size "standard_d8s_v5" \
--zones "3" \
--generate-ssh-keys \
--auto-upgrade-channel patch \
--no-wait
done
#!/bin/bash
configuration=$(cat ./resources.json)
length=$(echo $configuration | jq -r ".clusters | length")
for ((i=0; i<length; i++)); do
read name country <<< $(echo $configuration | jq -r ".clusters[$i] | [.name, .country] | @tsv")
echo "=> Deleting Kubernetes cluster ($country)..."
az aks delete \
--resource-group "Management" \
--name $name \
--yes \
--no-wait
done
{
"clusters": [
{
"name": "",
"location": "swedencentral",
"country": "Sweden"
},
{
"name": "",
"location": "francecentral",
"country": "France"
},
{
"name": "",
"location": "germanywestcentral",
"country": "Germany"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment