forked from cloudnative-pg/cloudnative-pg
-
Notifications
You must be signed in to change notification settings - Fork 3
135 lines (128 loc) · 5.71 KB
/
k8s-versions-check.yml
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# 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/mainline/latest/ug/clusters/kubernetes-versions-standard.adoc"
curl --silent "${DOC_URL}" | sed -e 's/.*`Kubernetes` \([0-9].[0-9][0-9]\).*/\1/;/^[0-9]\./!d' | uniq | \
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