k8s-versions-check #79
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Retrieves a list of supported image versions for the cloud providers and | |
# creates a PR to update each relative JSON file: | |
# - Kind (Kubernetes in Docker): kind_versions.json | |
# - GKE (Google Kubernetes Engine): gke_versions.json | |
# - AKS (Azure Kubernetes Service): aks_versions.json | |
# - EKS (Amazon Elastic Kubernetes Service): eks_versions.json | |
# - OCP (OpenShift): openshift_versions.json | |
name: k8s-versions-check | |
on: | |
schedule: | |
- cron: "30 0 * * *" | |
workflow_dispatch: | |
inputs: | |
limit: | |
description: 'Limit to the specified engines list (eks, aks, gke, kind, ocp)' | |
required: false | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: read | |
defaults: | |
run: | |
shell: 'bash -Eeuo pipefail -x {0}' | |
env: | |
# The minimal k8s version supported, k8s version smaller than this one will be removed from vendor | |
MINIMAL_K8S: "1.27" | |
MINIMAL_OCP: "4.12" | |
jobs: | |
check-public-clouds-k8s-versions: | |
runs-on: ubuntu-24.04 | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v4 | |
- | |
# There is no command to get EKS k8s versions, we have to parse the documentation | |
name: Get updated EKS versions | |
run: | | |
DOC_URL="https://raw.githubusercontent.com/awsdocs/amazon-eks-user-guide/main/doc_source/kubernetes-versions.md" | |
curl --silent "${DOC_URL}" | grep -E '^\+ `[0-9]\.[0-9]{2}`$' | sed -e 's/[\ +`]//g' | \ | |
awk -vv=$MINIMAL_K8S '$0>=v {print $0}' | \ | |
jq -Rn '[inputs]' | tee .github/eks_versions.json | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'eks' | |
- | |
name: Azure Login | |
uses: azure/[email protected] | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'aks' | |
- | |
name: Get updated AKS versions | |
run: | | |
az aks get-versions --location westeurope \ | |
--query "reverse(sort(values[? isPreview != 'true' && contains(capabilities.supportPlan, 'KubernetesOfficial')].patchVersions.keys(@)[]))" -o tsv | \ | |
sort -urk 1,1.5 | \ | |
awk -vv=$MINIMAL_K8S '$0>=v {print $0}' | \ | |
jq -Rn '[inputs]' | tee .github/aks_versions.json | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'aks' | |
- | |
name: 'Auth GKE' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT }}' | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'gke' | |
- | |
name: Set up Cloud SDK for GKE | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'gke' | |
- | |
name: Install YQ | |
uses: frenck/action-setup-yq@v1 | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'gke' | |
- | |
name: Get updated GKE versions | |
run: | | |
# Get the valid major versions from all the channels, convert them | |
# to json and write them to file. | |
YQEXPR=".validMasterVersions" #wokeignore:rule=master | |
gcloud container get-server-config --zone europe-west3-a --quiet | \ | |
yq e ${YQEXPR} - | \ | |
cut -d'.' -f '1-2' | \ | |
uniq | \ | |
sed 's/\([[:digit:]]\+\.[[:digit:]]\+\)/"\1"/' | \ | |
yq '.[] | select( . >= strenv(MINIMAL_K8S) )' | \ | |
jq -Rn '[inputs]' | tee .github/gke_versions.json | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'gke' | |
- | |
name: Get updated kind node version | |
run : | | |
# Get the latest valid kind node version, convert them to json | |
# and write them to a file, starting from the MINIMAL_K8S | |
for baseversion in $(seq $MINIMAL_K8S 0.01 99); do | |
URL="https://registry.hub.docker.com/v2/repositories/kindest/node/tags?name=${baseversion}&ordering=last_updated" | |
v=$(curl -SsL "${URL}" | jq -rc '.results[].name' | grep -v "alpha" | sort -Vr | head -n1) || RC=$? | |
if [[ -z "${v}" ]]; then | |
break | |
fi | |
echo "${v}" | |
done | jq -Rs 'split("\n") | map(select(length>0)) | sort | reverse' | tee .github/kind_versions.json | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'kind' | |
- | |
name: Get updated OpenShift versions | |
run: | | |
curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/ | \ | |
grep -e 'href.*"4\.1[2-9]\.[0-9].*"' | \ | |
sed -e 's/\(.*\)href="\(4\.1[2-9]\)\(.*\)/\2/' | \ | |
sort -Vru | \ | |
awk -vv="$MINIMAL_OCP" '$0>=v {print $0}' | \ | |
jq -Rn '[inputs]' | tee .github/openshift_versions.json | |
OCP_VERSIONS=`cat .github/openshift_versions.json | jq -r '"v"+.[-1]+"-v"+.[0]'` | |
sed -i -e 's/\(OPENSHIFT_VERSIONS ?= \)\(.*\)/\1'${OCP_VERSIONS}'/g' Makefile | |
if: github.event.inputs.limit == null || github.event.inputs.limit == 'ocp' | |
- | |
name: Create Pull Request if versions have been updated | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.REPO_GHA_PAT }} | |
title: "feat: Public Cloud K8S versions update" | |
body: "Update the versions used to test the operator on public cloud providers" | |
branch: "k8s-cloud-versions-update" | |
author: "public-cloud-k8s-versions-check <[email protected]>" | |
add-paths: | | |
.github/** | |
Makefile | |
commit-message: "feat: Updated public cloud k8s tested versions" | |
signoff: true |