From 6309ac80727528758eaa41717a531f5d7e8dcae7 Mon Sep 17 00:00:00 2001 From: jaskaransarkaria Date: Thu, 18 Jan 2024 14:47:30 +0000 Subject: [PATCH 1/2] =?UTF-8?q?style:=20=F0=9F=92=84=20create=20one=20tick?= =?UTF-8?q?et=20per=20upgrade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/eks-addon-updates.sh | 58 +++++++++++++++++++----------------- scripts/eks-updates.sh | 47 +++++++++++++++-------------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/scripts/eks-addon-updates.sh b/scripts/eks-addon-updates.sh index ec1aee8d..bc8729ce 100644 --- a/scripts/eks-addon-updates.sh +++ b/scripts/eks-addon-updates.sh @@ -1,32 +1,37 @@ #!/bin/bash -# list clusters -CLUSTERS=(live live-2 manager) +set -ex -for CLUSTER in "${CLUSTERS[@]}"; -do - # get cluster versions - CLUSTER_VERSION=$(aws eks describe-cluster --name "$CLUSTER" | jq -r '.cluster.version') +CLUSTER=live + +# get cluster versions +CLUSTER_VERSION=$(aws eks describe-cluster --name "$CLUSTER" | jq -r '.cluster.version') - # get addons - CLUSTER_ADDONS=($(aws eks list-addons --cluster-name "$CLUSTER" | jq -r '.addons[] | .')) +# get addons +CLUSTER_ADDONS=($(aws eks list-addons --cluster-name "$CLUSTER" | jq -r '.addons[] | .')) - for CLUSTER_ADDON in "${CLUSTER_ADDONS[@]}"; - do - # get addon version for cluster - CLUSTER_ADDON_VERSION=$(aws eks describe-addon --cluster-name "$CLUSTER" --addon-name "$CLUSTER_ADDON" | jq -r '.addon.addonVersion') +for CLUSTER_ADDON in "${CLUSTER_ADDONS[@]}"; +do + # get addon version for cluster + CLUSTER_ADDON_VERSION=$(aws eks describe-addon --cluster-name "$CLUSTER" --addon-name "$CLUSTER_ADDON" | jq -r '.addon.addonVersion') - # get latest supported addon version for the cluster/k8s version - LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION=$(aws eks describe-addon-versions --addon-name "$CLUSTER_ADDON" --kubernetes-version "$CLUSTER_VERSION" | jq -r '.addons[0].addonVersions[0].addonVersion') + # get latest supported addon version for the cluster/k8s version + LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION=$(aws eks describe-addon-versions --addon-name "$CLUSTER_ADDON" --kubernetes-version "$CLUSTER_VERSION" | jq -r '.addons[0].addonVersions[0].addonVersion') - TITLE="EKS addon ($CLUSTER): Update $CLUSTER_ADDON from $CLUSTER_ADDON_VERSION to the latest version" + TITLE="EKS addon ($CLUSTER): Update $CLUSTER_ADDON from $CLUSTER_ADDON_VERSION to the latest version" - if [[ "$LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION" != "$CLUSTER_ADDON_VERSION" ]]; then # check if newer version is supported - BODY=$(cat << END + if [[ "$LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION" != "$CLUSTER_ADDON_VERSION" ]]; then # check if newer version is supported + BODY=$(cat << END ## Background There is a new version of the EKS add-on $CLUSTER_ADDON. $CLUSTER_ADDON needs updating on the $CLUSTER cluster. When this issue was created, the latest supported add-on version for Kubernetes $CLUSTER_VERSION was $LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION. +## Environments Checklist: + +- [ ] live-2 +- [ ] manager +- [ ] live + See the [Amazon EKS add-ons](https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html) documentation for more information about addons, or find the latest versions for these EKS add-ons directly: - [coredns](https://docs.aws.amazon.com/eks/latest/userguide/managing-coredns.html) @@ -35,18 +40,17 @@ See the [Amazon EKS add-ons](https://docs.aws.amazon.com/eks/latest/userguide/ek END ) - GITHUB_ISSUES=$(gh issue list --repo ministryofjustice/cloud-platform --state all --search "in:title \"$TITLE\"" --limit 50 --json title | jq -r "[ .[] | select(.title == \"$TITLE\") ] | length") + GITHUB_ISSUES=$(gh issue list --repo ministryofjustice/cloud-platform --state all --search "in:title \"$TITLE\"" --limit 50 --json title | jq -r "[ .[] | select(.title == \"$TITLE\") ] | length") - # if no issues yet, create one - if (( $(echo "0 == $GITHUB_ISSUES" | bc -l) )); then - echo "No issue found for $TITLE, creating one..." - gh issue create --title "$TITLE" --body "$BODY" --repo ministryofjustice/cloud-platform - else - echo "Issue already exists for $TITLE, skipping..." - fi + # if no issues yet, create one + if (( $(echo "0 == $GITHUB_ISSUES" | bc -l) )); then + echo "No issue found for $TITLE, creating one..." + gh issue create --title "$TITLE" --body "$BODY" --repo ministryofjustice/cloud-platform else - echo "Up to date, skipping issue creation for $TITLE" + echo "Issue already exists for $TITLE, skipping..." fi + else + echo "Up to date, skipping issue creation for $TITLE" + fi - done done diff --git a/scripts/eks-updates.sh b/scripts/eks-updates.sh index 9e65daac..8677e6b3 100644 --- a/scripts/eks-updates.sh +++ b/scripts/eks-updates.sh @@ -1,42 +1,45 @@ #!/bin/bash +set -ex + # get supported versions VERSIONS=($(aws eks describe-addon-versions | jq -r ".addons[] | .addonVersions[] | .compatibilities[] | .clusterVersion" | sort | uniq)) -# list clusters -CLUSTERS=(live live-2 manager) +CLUSTER=live -for CLUSTER in "${CLUSTERS[@]}"; +# get cluster versions +CLUSTER_VERSION=$(aws eks describe-cluster --name "$CLUSTER" | jq -r '.cluster.version') +for VERSION in "${VERSIONS[@]}"; do - # get cluster versions - CLUSTER_VERSION=$(aws eks describe-cluster --name "$CLUSTER" | jq -r '.cluster.version') - - for VERSION in "${VERSIONS[@]}"; - do - if [[ "$CLUSTER_VERSION" != "$VERSION" ]]; then - if (( $(echo "$CLUSTER_VERSION < $VERSION" | bc -l) )); then # check if newer version is supported - TITLE="EKS: Upgrade $CLUSTER to Kubernetes v$VERSION"; - BODY=$(cat << END + if [[ "$CLUSTER_VERSION" != "$VERSION" ]]; then + if (( $(echo "$CLUSTER_VERSION < $VERSION" | bc -l) )); then # check if newer version is supported + TITLE="EKS: Upgrade $CLUSTER to Kubernetes v$VERSION"; + BODY=$(cat << END ## Background EKS supports Kubernetes $VERSION. The $CLUSTER cluster needs upgrading to Kubernetes $VERSION. +## Environments Checklist: + +- [ ] live-2 +- [ ] manager +- [ ] live + See [Amazon EKS Kubernetes versions](https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html) for more details. END ) - # get github issues and check if one already exists - GITHUB_ISSUES=$(gh issue list --repo ministryofjustice/cloud-platform --state all --search "in:title \"$TITLE\"" --limit 50 --json title | jq -r "[ .[] | select(.title == \"$TITLE\") ] | length") + # get github issues and check if one already exists + GITHUB_ISSUES=$(gh issue list --repo ministryofjustice/cloud-platform --state all --search "in:title \"$TITLE\"" --limit 50 --json title | jq -r "[ .[] | select(.title == \"$TITLE\") ] | length") - # if no issues yet, create one - if (( $(echo "0 == $GITHUB_ISSUES" | bc -l) )); then - echo "No issue found for $TITLE, creating one..." - gh issue create --title "$TITLE" --body "$BODY" --label EPIC --repo ministryofjustice/cloud-platform - else - echo "Issue already exists for $TITLE, skipping..." - fi + # if no issues yet, create one + if (( $(echo "0 == $GITHUB_ISSUES" | bc -l) )); then + echo "No issue found for $TITLE, creating one..." + gh issue create --title "$TITLE" --body "$BODY" --label EPIC --repo ministryofjustice/cloud-platform + else + echo "Issue already exists for $TITLE, skipping..." fi fi - done + fi done From bab3b579a3047506a653d6ed6180495630a4e641 Mon Sep 17 00:00:00 2001 From: jaskaransarkaria Date: Thu, 18 Jan 2024 14:58:39 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fixup!=20style:=20=F0=9F=92=84=20create=20o?= =?UTF-8?q?ne=20ticket=20per=20upgrade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/eks-addon-updates.sh | 6 +++--- scripts/eks-updates.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/eks-addon-updates.sh b/scripts/eks-addon-updates.sh index bc8729ce..4846cd62 100644 --- a/scripts/eks-addon-updates.sh +++ b/scripts/eks-addon-updates.sh @@ -18,15 +18,15 @@ do # get latest supported addon version for the cluster/k8s version LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION=$(aws eks describe-addon-versions --addon-name "$CLUSTER_ADDON" --kubernetes-version "$CLUSTER_VERSION" | jq -r '.addons[0].addonVersions[0].addonVersion') - TITLE="EKS addon ($CLUSTER): Update $CLUSTER_ADDON from $CLUSTER_ADDON_VERSION to the latest version" + TITLE="EKS addon Production Clusters: Update $CLUSTER_ADDON from $CLUSTER_ADDON_VERSION to the latest version" if [[ "$LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION" != "$CLUSTER_ADDON_VERSION" ]]; then # check if newer version is supported BODY=$(cat << END ## Background -There is a new version of the EKS add-on $CLUSTER_ADDON. $CLUSTER_ADDON needs updating on the $CLUSTER cluster. When this issue was created, the latest supported add-on version for Kubernetes $CLUSTER_VERSION was $LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION. +There is a new version of the EKS add-on $CLUSTER_ADDON. $CLUSTER_ADDON needs updating on all of our clusters. When this issue was created, the latest supported add-on version for Kubernetes $CLUSTER_VERSION was $LATEST_SUPPORTED_ADDON_VERSION_FOR_KUBERNETES_VERSION. -## Environments Checklist: +## Production Clusters Checklist: - [ ] live-2 - [ ] manager diff --git a/scripts/eks-updates.sh b/scripts/eks-updates.sh index 8677e6b3..6ac2920d 100644 --- a/scripts/eks-updates.sh +++ b/scripts/eks-updates.sh @@ -14,13 +14,13 @@ for VERSION in "${VERSIONS[@]}"; do if [[ "$CLUSTER_VERSION" != "$VERSION" ]]; then if (( $(echo "$CLUSTER_VERSION < $VERSION" | bc -l) )); then # check if newer version is supported - TITLE="EKS: Upgrade $CLUSTER to Kubernetes v$VERSION"; + TITLE="EKS: Upgrade Production Clusters to Kubernetes v$VERSION"; BODY=$(cat << END ## Background -EKS supports Kubernetes $VERSION. The $CLUSTER cluster needs upgrading to Kubernetes $VERSION. +EKS supports Kubernetes $VERSION. Our Production Clusters need upgrading to Kubernetes $VERSION. -## Environments Checklist: +## Production Clusters Checklist: - [ ] live-2 - [ ] manager