Skip to content

Commit c8e3849

Browse files
authored
Support K8s RC versions in new-e2e-containers-k8s-latest job (#44859)
### What does this PR do? Updates our e2e tests to include Kubernetes RC versions (e.g. `1.35.0-rc.1`). The scheduled workflow that runs everyday to check for new kind node images has been extended to also check the Kubernetes GitHub releases for new RC versions because RC images aren't published to the official `dockerhub/kindest/node` repository. If there is a new version found this workflow: 1. Builds the image using `kind build node image ...` 2. Pushes the image to our kind image repository 3. Updates the `k8s_versions.json` and `.gitlab/test/e2e/e2e.yml` files as normal ### Motivation Earlier detection of breaking changes. ### Describe how you validated your changes N/A ### Additional Notes N/A Co-authored-by: justin.lesko <[email protected]>
1 parent ddbcd4b commit c8e3849

File tree

4 files changed

+425
-36
lines changed

4 files changed

+425
-36
lines changed

.github/workflows/update-kubernetes-versions.yml

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,33 @@ on:
77

88
# Allow manual trigger
99
workflow_dispatch:
10+
inputs:
11+
disable_dockerhub:
12+
description: 'Disable fetching versions from Docker Hub'
13+
required: false
14+
default: false
15+
type: boolean
16+
disable_github:
17+
description: 'Disable fetching RC versions from GitHub'
18+
required: false
19+
default: false
20+
type: boolean
1021

1122
permissions: {}
1223

1324
jobs:
1425
update-k8s-versions:
26+
timeout-minutes: 30
1527
name: Check for new Kubernetes version
1628
runs-on: ubuntu-latest
1729
permissions:
1830
id-token: write # Required for OIDC token from GitHub
1931
environment:
2032
name: main
33+
env:
34+
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
35+
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
36+
ECR_REGION: ${{ vars.ECR_REGION }}
2137
steps:
2238
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
2339
id: octo-sts
@@ -40,12 +56,79 @@ jobs:
4056
features: legacy-tasks
4157

4258
- name: Install Python dependencies
43-
run: pip install requests pyyaml
59+
run: pip install requests pyyaml semver
60+
61+
- name: Install kind
62+
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab #v1.13.0
63+
with:
64+
install_only: true
4465

4566
- name: Fetch latest Kubernetes version
4667
id: fetch-versions
4768
run: |
48-
dda inv k8s-versions.fetch-versions
69+
args=()
70+
if [ "${{ inputs.disable_dockerhub }}" = "true" ]; then
71+
args+=(--disable-dockerhub)
72+
fi
73+
if [ "${{ inputs.disable_github }}" = "true" ]; then
74+
args+=(--disable-github)
75+
fi
76+
dda inv k8s-versions.fetch-versions "${args[@]}"
77+
78+
- name: Build RC images
79+
if: steps.fetch-versions.outputs.has_new_rc_versions == 'true'
80+
id: build-rc-images
81+
run: |
82+
dda inv kind-node-image.build-rc-images --versions='${{ steps.fetch-versions.outputs.new_versions }}'
83+
84+
- name: Configure AWS credentials
85+
if: steps.fetch-versions.outputs.has_new_rc_versions == 'true' && steps.build-rc-images.outputs.built_count > 0
86+
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
87+
with:
88+
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/datadog-agent-kind-image-publisher-oidc
89+
aws-region: us-east-1
90+
91+
- name: Log in to AWS ECR
92+
if: steps.fetch-versions.outputs.has_new_rc_versions == 'true' && steps.build-rc-images.outputs.built_count > 0
93+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
94+
with:
95+
registry: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
96+
97+
- name: Tag and push RC images to ECR
98+
if: steps.fetch-versions.outputs.has_new_rc_versions == 'true' && steps.build-rc-images.outputs.built_count > 0
99+
id: push-rc-images
100+
env:
101+
ECR_REGISTRY: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
102+
run: |
103+
set -euo pipefail
104+
105+
new_versions='${{ steps.fetch-versions.outputs.new_versions }}'
106+
107+
for image in ${{ steps.build-rc-images.outputs.built_images }}; do
108+
tag="${image##*:}"
109+
ecr_image="$ECR_REGISTRY/$ECR_REPOSITORY:$tag"
110+
111+
docker tag "$image" "$ecr_image"
112+
docker push "$ecr_image"
113+
114+
# Get digest from local image after push
115+
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$ecr_image" | cut -d@ -f2)
116+
117+
[ -n "$digest" ] || { echo "Error: Could not get digest for $tag"; exit 1; }
118+
119+
# Append the digest into the new versions JSON
120+
new_versions=$(jq --arg tag "$tag" --arg digest "$digest" '.[$tag].digest = $digest' <<< "$new_versions")
121+
done
122+
123+
echo "new_versions=$new_versions" >> "$GITHUB_OUTPUT"
124+
125+
- name: Save new versions to file
126+
if: steps.fetch-versions.outputs.has_new_versions == 'true'
127+
run: |
128+
# Use push-rc-images output if RC images were built (includes digests from ECR)
129+
# Otherwise use fetch-versions output (includes digests from Docker Hub for final releases)
130+
VERSIONS='${{ steps.push-rc-images.outputs.new_versions || steps.fetch-versions.outputs.new_versions }}'
131+
dda inv k8s-versions.save-versions --versions="$VERSIONS"
49132
50133
- name: Update e2e.yml with new version
51134
id: update-yaml

tasks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
invoke_unit_tests,
4343
issue,
4444
k8s_versions,
45+
kind_node_image,
4546
kmt,
4647
linter,
4748
loader,
@@ -232,6 +233,7 @@
232233
ns.add_collection(fakeintake)
233234
ns.add_collection(kmt)
234235
ns.add_collection(k8s_versions)
236+
ns.add_collection(kind_node_image)
235237
ns.add_collection(diff)
236238
ns.add_collection(installer)
237239
ns.add_collection(owners)

0 commit comments

Comments
 (0)