From 778ca4f793e6cdef1e764792d99f1f65b72ce440 Mon Sep 17 00:00:00 2001 From: jakemulley Date: Tue, 10 Oct 2023 15:32:06 +0100 Subject: [PATCH 1/2] Add script to create GitHub issues for EKS upgrades --- scripts/README.md | 7 +++++++ scripts/eks-updates.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 scripts/README.md create mode 100644 scripts/eks-updates.sh diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..d7e2faf9 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,7 @@ +# Creating issues for EKS upgrades + +This directory contains scripts to automatically create GitHub issues based on EKS upgrades. + +| Script | Description | +|-|-| +| [eks-updates.sh](./eks-updates.sh) | Fetches current cluster versions and compares them against supported Kubernetes versions in EKS. It creates a GitHub issue (example)[https://github.com/ministryofjustice/cloud-platform/issues/4857] to track upgrade progress. | \ No newline at end of file diff --git a/scripts/eks-updates.sh b/scripts/eks-updates.sh new file mode 100644 index 00000000..9e65daac --- /dev/null +++ b/scripts/eks-updates.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# get supported versions +VERSIONS=($(aws eks describe-addon-versions | jq -r ".addons[] | .addonVersions[] | .compatibilities[] | .clusterVersion" | sort | uniq)) + +# list clusters +CLUSTERS=(live live-2 manager) + +for CLUSTER in "${CLUSTERS[@]}"; + +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 +## Background + +EKS supports Kubernetes $VERSION. The $CLUSTER cluster needs upgrading to Kubernetes $VERSION. + +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") + + # 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 + fi + done +done From 80beb3c914043a0ee006d9c6a2d32f98f79e758b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 10 Oct 2023 14:33:15 +0000 Subject: [PATCH 2/2] Commit changes made by code formatters --- scripts/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index d7e2faf9..02ed28ca 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -2,6 +2,6 @@ This directory contains scripts to automatically create GitHub issues based on EKS upgrades. -| Script | Description | -|-|-| -| [eks-updates.sh](./eks-updates.sh) | Fetches current cluster versions and compares them against supported Kubernetes versions in EKS. It creates a GitHub issue (example)[https://github.com/ministryofjustice/cloud-platform/issues/4857] to track upgrade progress. | \ No newline at end of file +| Script | Description | +| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [eks-updates.sh](./eks-updates.sh) | Fetches current cluster versions and compares them against supported Kubernetes versions in EKS. It creates a GitHub issue (example)[https://github.com/ministryofjustice/cloud-platform/issues/4857] to track upgrade progress. |