-
Notifications
You must be signed in to change notification settings - Fork 1.5k
149 lines (120 loc) · 5.79 KB
/
Copy pathupdate-kubernetes-versions.yml
File metadata and controls
149 lines (120 loc) · 5.79 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Update Kubernetes Versions
on:
schedule:
# Run once daily at 6am UTC
- cron: "0 6 * * *"
workflow_dispatch: # Leaving this empty allows manual triggering without fields
permissions: {}
jobs:
update-k8s-versions:
timeout-minutes: 30
name: Check for new Kubernetes version
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC token from GitHub
environment:
name: main
env:
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
ECR_REGION: ${{ vars.ECR_REGION }}
steps:
- uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
id: octo-sts
with:
scope: DataDog/datadog-agent
policy: self.update-kubernetes-versions.create-pr
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: true
token: ${{ steps.octo-sts.outputs.token }}
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.14'
- name: Install dda
uses: ./.github/actions/install-dda
with:
features: legacy-tasks
- name: Install Python dependencies
run: pip install requests==2.33.1 pyyaml==6.0.3 semver==3.0.4
- name: Install kind
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
with:
install_only: true
- name: Fetch latest Kubernetes version
id: fetch-versions
run: |
dda inv k8s-versions.fetch-versions
- name: Build new Kubernetes images
if: steps.fetch-versions.outputs.has_new_versions == 'true'
id: build-images
run: |
dda inv kind-node-image.build-images --versions='${{ steps.fetch-versions.outputs.new_versions }}'
- name: Configure AWS credentials
if: steps.fetch-versions.outputs.has_new_versions == 'true' && steps.build-images.outputs.built_count > 0
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/datadog-agent-kind-image-publisher-oidc
aws-region: us-east-1
- name: Log in to AWS ECR
if: steps.fetch-versions.outputs.has_new_versions == 'true' && steps.build-images.outputs.built_count > 0
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
- name: Tag and push new Kubernetes images to ECR
if: steps.fetch-versions.outputs.has_new_versions == 'true' && steps.build-images.outputs.built_count > 0
id: push-images
env:
ECR_REGISTRY: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
run: |
set -euo pipefail
new_versions='${{ steps.fetch-versions.outputs.new_versions }}'
# Capture the kind version used to build these images
kind_version=$(kind version | awk '{print $2}')
for image in ${{ steps.build-images.outputs.built_images }}; do
tag="${image##*:}"
ecr_image="$ECR_REGISTRY/$ECR_REPOSITORY:$tag"
docker tag "$image" "$ecr_image"
docker push "$ecr_image"
# Get digest from local image after push
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$ecr_image" | cut -d@ -f2)
[ -n "$digest" ] || { echo "Error: Could not get digest for $tag"; exit 1; }
# Append digest and kind_version into the new versions JSON
# Must use the -c option (compact) to keep the jq output to a single-line
new_versions=$(jq -c --arg tag "$tag" --arg digest "$digest" --arg kind_version "$kind_version" \
'.[$tag].digest = $digest | .[$tag].kind_version = $kind_version' <<< "$new_versions")
done
echo "new_versions=$new_versions" >> "$GITHUB_OUTPUT"
- name: Save new versions to file
if: steps.push-images.conclusion == 'success'
run: |
VERSIONS='${{ steps.push-images.outputs.new_versions }}'
dda inv k8s-versions.save-versions --versions="$VERSIONS"
- name: Update kind_versions.json
if: steps.push-images.conclusion == 'success'
run: dda inv k8s-versions.update-kind-versions-file
- name: Update e2e.yml with new version
id: update-yaml
if: steps.push-images.conclusion == 'success'
run: |
dda inv k8s-versions.update-e2e-yaml
- uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
name: Create pull request
if: steps.update-yaml.outputs.updated == 'true'
with:
commit-message: "chore(e2e): add new Kubernetes version to e2e tests"
branch: update-k8s-versions-automated
token: ${{ steps.octo-sts.outputs.token }}
sign-commits: true
title: "[automated] Update Kubernetes latest version in e2e tests"
body: |
### What does this PR do?
Updates the Kubernetes version used by the `new-e2e-containers-k8s-latest` job in `.gitlab/test/e2e/e2e.yml` to the latest stable release from `kindest/node`.
### Motivation
Keep e2e tests running against the latest Kubernetes version to ensure compatibility.
### New version added:
${{ steps.update-yaml.outputs.new_versions }}
### Describe how you validated your changes
CI will validate the new versions work correctly.
team-reviewers: container-integrations
labels: team/container-integrations,qa/done,changelog/no-changelog,ask-review