-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-nodegroups.sh
26 lines (22 loc) · 954 Bytes
/
update-nodegroups.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
#!/bin/bash
# Get a list of all EKS clusters in the region
REGION=us-east-2
clusters=($(aws eks list-clusters --region ${REGION} --output json | jq -r '.clusters[]'))
# Loop through each cluster
for cluster in ${clusters[@]}; do
# Get a list of all nodegroups in the cluster
nodegroups=($(aws eks list-nodegroups --cluster-name $cluster --region ${REGION} --output json | jq -r '.nodegroups[]'))
# skip if there are no node groups
echo "checking for nodegroups in $cluster"
if [[ ${#nodegroups[@]} -eq 0]]; then
echo "No nodegroups found in cluster $cluster."
continue
fi
# Loop through each nodegroup
for nodegroup in ${nodegroups[@]}; do
# Update the nodegroup
echo "Updating nodegroup $nodegroup in cluster $cluster..."
echo $nodegroup
aws eks update-nodegroup-version --cluster-name ${cluster} --nodegroup-name ${nodegroup} --region $REGION || echo $?
done
done