From 38f0b2015923c3a451c852c0431d7e45f4f1b69e Mon Sep 17 00:00:00 2001 From: Drew Sirenko <68304519+AndrewSirenko@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:22:20 -0400 Subject: [PATCH] Automate image dependency upgrades & Migrate to kubekins-e2e-v2 (#2177) * Automate kubekins-e2e-v2 & gcb-docker-build image updates * Migrate to kubekins-e2e-v2 (v1 is deprecated) * Update hack/release-scripts/update-e2e-images Co-authored-by: ConnorJC --------- Co-authored-by: ConnorJC --- Makefile | 4 ++ .../templates/tests/helm-tester.yaml | 2 - charts/aws-ebs-csi-driver/values.yaml | 2 +- docs/makefile.md | 6 +- hack/release-scripts/update-e2e-images | 67 +++++++++++++++++++ 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100755 hack/release-scripts/update-e2e-images diff --git a/Makefile b/Makefile index 7f8ac46f32..25d2ab0f1b 100644 --- a/Makefile +++ b/Makefile @@ -185,6 +185,10 @@ generate-sidecar-tags: update-truth-sidecars charts/aws-ebs-csi-driver/values.ya .PHONY: update-sidecar-dependencies update-sidecar-dependencies: update-truth-sidecars generate-sidecar-tags update/kustomize +.PHONY: update-image-dependencies +update-image-dependencies: update-sidecar-dependencies + ./hack/release-scripts/update-e2e-images + ## CI aliases # Targets intended to be executed mostly or only by CI jobs diff --git a/charts/aws-ebs-csi-driver/templates/tests/helm-tester.yaml b/charts/aws-ebs-csi-driver/templates/tests/helm-tester.yaml index 6c618b0add..34c8e0f93c 100644 --- a/charts/aws-ebs-csi-driver/templates/tests/helm-tester.yaml +++ b/charts/aws-ebs-csi-driver/templates/tests/helm-tester.yaml @@ -225,10 +225,8 @@ spec: volumeMounts: - name: config-vol mountPath: /etc/config - # kubekins-e2e v1 image is linux amd64 only. nodeSelector: kubernetes.io/os: linux - kubernetes.io/arch: amd64 serviceAccountName: ebs-csi-driver-test volumes: - name: config-vol diff --git a/charts/aws-ebs-csi-driver/values.yaml b/charts/aws-ebs-csi-driver/values.yaml index 64740254bc..d609d768de 100644 --- a/charts/aws-ebs-csi-driver/values.yaml +++ b/charts/aws-ebs-csi-driver/values.yaml @@ -490,4 +490,4 @@ nodeComponentOnly: false helmTester: enabled: true # Supply a custom image to the ebs-csi-driver-test pod in helm-tester.yaml - image: "gcr.io/k8s-staging-test-infra/kubekins-e2e:v20240903-6a352c5344-master" + image: "us-central1-docker.pkg.dev/k8s-staging-test-infra/images/kubekins-e2e:v20240903-6a352c5344-master" diff --git a/docs/makefile.md b/docs/makefile.md index deabe01dc8..1ab7b12b2c 100644 --- a/docs/makefile.md +++ b/docs/makefile.md @@ -199,9 +199,13 @@ Test the EBS CSI Driver Helm chart via the [Helm `chart-testing` tool](https://g ## Release Scripts +### 'make update-image-dependencies' + +Convenience target to perform all image updates (including sidecars, kubekins-e2e-v2, and gcb-docker-gcloud). This is the primary target to use unless more granular control is needed. + ### `make update-sidecar-dependencies` -Convenience target to perform all sidecar updates and regenerate the manifests. This is the primary target to use unless more granular control is needed. +Convenience target to perform all sidecar updates and regenerate the manifests. ### `make update-truth-sidecars` diff --git a/hack/release-scripts/update-e2e-images b/hack/release-scripts/update-e2e-images new file mode 100755 index 0000000000..709bcebbed --- /dev/null +++ b/hack/release-scripts/update-e2e-images @@ -0,0 +1,67 @@ +#!/bin/bash +# Copyright 2024 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# --- +# This script updates images used by aws-ebs-csi-driver CI + +set -euo pipefail # Exit on any error + +# --- Environment Variables +export KUBEKINS_IMAGE GCB_IMAGE + +SCRIPT_PATH=$(dirname $(realpath "$0")) +ROOT_DIRECTORY="$SCRIPT_PATH/../.." + +CLOUDBUILD_FILEPATH="$ROOT_DIRECTORY/cloudbuild.yaml" +HELM_VALUES_FILEPATH="$ROOT_DIRECTORY/charts/aws-ebs-csi-driver/values.yaml" + +KUBEKINS_REPO="us-central1-docker.pkg.dev/k8s-staging-test-infra/images/kubekins-e2e" +GCB_REPO="gcr.io/k8s-staging-test-infra/gcb-docker-gcloud" + +# --- Script Tools +log() { + printf "%s [INFO] - %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "${*}" >&2 +} + +check_dependencies() { + local readonly dependencies=("yq" "git" "crane") + + for cmd in "${dependencies[@]}"; do + if ! command -v "${cmd}" &>/dev/null; then + log "${cmd} binary could not be found, please install it." + exit 1 + fi + done +} + +# --- Script + +check_dependencies + +log "Fetching latest kubekins-e2e-v2 image from $KUBEKINS_REPO" +KUBEKINS_TAG=$(crane ls "$KUBEKINS_REPO" | grep -E 'master$' | sort -V | tail -n 1) +export KUBEKINS_IMAGE="$KUBEKINS_REPO:$KUBEKINS_TAG" + +log "Updating kubekins-e2e-v2 image in $HELM_VALUES_FILEPATH to $KUBEKINS_IMAGE" +yq ".helmTester.image = env(KUBEKINS_IMAGE)" -i "$HELM_VALUES_FILEPATH" + +log "Fetching latest gcb-docker-gcloud image from $GCB_REPO" +GCB_TAG=$(crane ls "$GCB_REPO" | sort -V | tail -n 1) +export GCB_IMAGE="$GCB_REPO:$GCB_TAG" + +log "Updating gcb-docker-gcloud image in $CLOUDBUILD_FILEPATH to $GCB_IMAGE" +yq ".steps[0].name = env(GCB_IMAGE)" -i "$CLOUDBUILD_FILEPATH" + +log "Success! Updated kubekins-e2e-v2 and gcb-docker-gcloud images!"