-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaks-start-stop.sh
41 lines (36 loc) · 908 Bytes
/
aks-start-stop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# AKS Cluster Start/Stop script
RG=pkar-aks-rg
CLUSTER=prod-aks-win
CLUSTER_RG=$(az aks show -g $RG -n $CLUSTER --query nodeResourceGroup -o tsv)
# To Stop AKS Cluster
stop()
{
for i in $(az vmss list --resource-group $CLUSTER_RG -o table | awk '{print $1}' | grep aks); do
echo "Stoping & deallocating AKS Cluster .."
az vmss deallocate --resource-group $CLUSTER_RG --name $i --instance-ids 0
done
}
# To Start AKS Cluster
start()
{
for i in $(az vmss list --resource-group $CLUSTER_RG -o table | awk '{print $1}' | grep aks); do
echo "Starting AKS Cluster .."
az vmss start --resource-group $CLUSTER_RG --name $i --instance-ids 0
done
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
*)
echo
echo "Usage: $0 { start | stop }"
echo
exit 1
;;
esac
exit 0