Skip to content

Commit 7f91b9d

Browse files
authored
Add GH workflow for automatically updating nvidia device plugin static manifest (#7898)
* Add GH workflow for automatically updating nvidia device plugin static manifest * update PR body * fix unit tests * updates userdocs
1 parent 02c41d5 commit 7f91b9d

File tree

9 files changed

+120
-43
lines changed

9 files changed

+120
-43
lines changed

.github/workflows/update-generated.yaml

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update generated files
22
on:
33
workflow_dispatch: {}
44
schedule:
5-
- cron: "0 5 * * Thu"
5+
- cron: "0 5 * * Thu"
66

77
permissions:
88
id-token: write
@@ -15,47 +15,53 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
resource: ["coredns", "aws-node"]
18+
resource: ["coredns", "aws-node", "nvidia-device-plugin"]
1919
name: Update ${{ matrix.resource }} and open PR
2020
runs-on: ubuntu-latest
2121
container: public.ecr.aws/eksctl/eksctl-build:833f4464e865a6398788bf6cbc5447967b8974b7
2222
env:
2323
GOPRIVATE: ""
2424
steps:
25-
- name: Checkout
26-
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 #v4.1.2
27-
with:
28-
token: ${{ secrets.EKSCTLBOT_TOKEN }}
29-
fetch-depth: 0
30-
- name: Configure AWS credentials for coredns update
31-
if: ${{ matrix.resource == 'coredns' }}
32-
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
33-
with:
34-
aws-region: us-west-2
35-
role-duration-seconds: 900
36-
role-session-name: eksctl-update-coredns-assets
37-
role-to-assume: ${{ secrets.UPDATE_COREDNS_ROLE_ARN }}
38-
- name: Setup identity as eksctl-bot
39-
uses: ./.github/actions/setup-identity
40-
with:
41-
token: "${{ secrets.EKSCTLBOT_TOKEN }}"
42-
- name: Cache go-build and mod
43-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 #v4.0.2
44-
with:
45-
path: |
46-
~/.cache/go-build/
47-
~/go/pkg/mod/
48-
key: go-${{ hashFiles('go.sum') }}
49-
restore-keys: |
50-
go-
51-
- name: Update ${{ matrix.resource }}
52-
run: make update-${{ matrix.resource }}
53-
- name: Upsert pull request
54-
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e #v6.0.2
55-
with:
56-
token: ${{ secrets.EKSCTLBOT_TOKEN }}
57-
commit-message: update ${{ matrix.resource }}
58-
committer: eksctl-bot <[email protected]>
59-
title: 'Update ${{ matrix.resource }}'
60-
branch: update-${{ matrix.resource }}
61-
labels: area/tech-debt
25+
- name: Checkout
26+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 #v4.1.2
27+
with:
28+
token: ${{ secrets.EKSCTLBOT_TOKEN }}
29+
fetch-depth: 0
30+
- name: Configure AWS credentials for coredns update
31+
if: ${{ matrix.resource == 'coredns' }}
32+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
33+
with:
34+
aws-region: us-west-2
35+
role-duration-seconds: 900
36+
role-session-name: eksctl-update-coredns-assets
37+
role-to-assume: ${{ secrets.UPDATE_COREDNS_ROLE_ARN }}
38+
- name: Setup identity as eksctl-bot
39+
uses: ./.github/actions/setup-identity
40+
with:
41+
token: "${{ secrets.EKSCTLBOT_TOKEN }}"
42+
- name: Cache go-build and mod
43+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 #v4.0.2
44+
with:
45+
path: |
46+
~/.cache/go-build/
47+
~/go/pkg/mod/
48+
key: go-${{ hashFiles('go.sum') }}
49+
restore-keys: |
50+
go-
51+
- name: Update ${{ matrix.resource }}
52+
run: make update-${{ matrix.resource }}
53+
- name: Upsert pull request
54+
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e #v6.0.2
55+
with:
56+
token: ${{ secrets.EKSCTLBOT_TOKEN }}
57+
commit-message: update ${{ matrix.resource }}${{ env.LATEST_RELEASE_TAG }}
58+
committer: eksctl-bot <[email protected]>
59+
title: 'Update ${{ matrix.resource }}${{ env.LATEST_RELEASE_TAG }}'
60+
branch: update-${{ matrix.resource }}
61+
labels: area/tech-debt
62+
body: |
63+
Auto-generated by [eksctl Update Generated Files GitHub workflow][1]
64+
65+
[1]: https://github.com/eksctl-io/eksctl/blob/main/.github/workflows/update-generated.yaml
66+
67+
Please manually test before approving and merging.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ generate-all: generate-always $(conditionally_generated_files) ## Re-generate al
160160
check-all-generated-files-up-to-date: generate-all ## Run the generate all command and verify there is no new diff
161161
git diff --quiet -- $(conditionally_generated_files) || (git --no-pager diff $(conditionally_generated_files); echo "HINT: to fix this, run 'git commit $(conditionally_generated_files) --message \"Update generated files\"'"; exit 1)
162162

163+
.PHONY: update-nvidia-device-plugin
164+
update-nvidia-device-plugin: ## fetch the latest static manifest
165+
pkg/addons/assets/scripts/update_nvidia_device_plugin.sh
163166

164167
.PHONY: update-aws-node
165168
update-aws-node: ## Re-download the aws-node manifests from AWS
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
get_latest_release_tag() {
4+
curl -sL https://api.github.com/repos/NVIDIA/k8s-device-plugin/releases/latest | jq -r '.tag_name'
5+
}
6+
7+
latest_release_tag=$(get_latest_release_tag)
8+
9+
# Check if the latest release tag was found
10+
if [ -z "$latest_release_tag" ]; then
11+
echo "Could not find the latest release tag."
12+
exit 1
13+
fi
14+
15+
# If running in GitHub Actions, export the release tag for use in the workflow
16+
if [ "$GITHUB_ACTIONS" = "true" ]; then
17+
echo "LATEST_RELEASE_TAG= to $latest_release_tag" >> $GITHUB_ENV
18+
else
19+
echo "Found the latest release tag: $latest_release_tag"
20+
fi
21+
22+
assets_addons_dir="pkg/addons/assets"
23+
24+
curl -sL "https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/$latest_release_tag/deployments/static/nvidia-device-plugin.yml" -o "$assets_addons_dir/nvidia-device-plugin.yaml"
25+
26+
27+
# Check if the download was successful
28+
if [ $? -eq 0 ]; then
29+
echo "Downloaded the latest NVIDIA device plugin manifest to $assets_addons_dir/nvidia-device-plugin.yaml"
30+
else
31+
echo "Failed to download the NVIDIA device plugin manifest."
32+
exit 1
33+
fi

pkg/addons/default/scripts/update_aws_node.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,31 @@ get_latest_release_tag() {
99

1010
latest_release_tag=$(get_latest_release_tag)
1111

12+
# Check if the latest release tag was found
13+
if [ -z "$latest_release_tag" ]; then
14+
echo "Could not find the latest release tag."
15+
exit 1
16+
fi
17+
18+
# If running in GitHub Actions, export the release tag for use in the workflow
19+
if [ "$GITHUB_ACTIONS" = "true" ]; then
20+
echo "LATEST_RELEASE_TAG= to $latest_release_tag" >> $GITHUB_ENV
21+
else
22+
echo "Found the latest release tag: $latest_release_tag"
23+
fi
24+
1225
default_addons_dir="pkg/addons/default"
1326

1427
# Download the latest aws-k8s-cni.yaml file
1528
curl -sL "$base_url$latest_release_tag/config/master/aws-k8s-cni.yaml?raw=1" --output "$default_addons_dir/assets/aws-node.yaml"
1629

17-
echo "found latest release tag:" $latest_release_tag
30+
# Check if the download was successful
31+
if [ $? -eq 0 ]; then
32+
echo "Downloaded the latest AWS Node manifest to $default_addons_dir/assets/aws-node.yaml"
33+
else
34+
echo "Failed to download the latest AWS Node manifest."
35+
exit 1
36+
fi
1837

1938
# Update the unit test file
2039
sed -i "s/expectedVersion = \"\(.*\)\"/expectedVersion = \"$latest_release_tag\"/g" "$default_addons_dir/aws_node_test.go"

pkg/printers/testdata/jsontest_2clusters.golden

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"RoleArn": null,
3636
"Status": "ACTIVE",
3737
"Tags": null,
38-
"Version": null
38+
"Version": null,
39+
"UpgradePolicy": null
3940
},
4041
{
4142
"Id": null,
@@ -73,6 +74,7 @@
7374
"RoleArn": null,
7475
"Status": "ACTIVE",
7576
"Tags": null,
76-
"Version": null
77+
"Version": null,
78+
"UpgradePolicy": null
7779
}
7880
]

pkg/printers/testdata/jsontest_single.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"RoleArn": null,
3535
"Status": "ACTIVE",
3636
"Tags": null,
37-
"Version": null
37+
"Version": null,
38+
"UpgradePolicy": null
3839
}
3940
]

pkg/printers/testdata/yamltest_2clusters.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
Status: ACTIVE
3131
Tags: null
3232
Version: null
33+
UpgradePolicy: null
3334
- Id: null
3435
Arn: arn-87654321
3536
CertificateAuthority: null
@@ -62,3 +63,4 @@
6263
Status: ACTIVE
6364
Tags: null
6465
Version: null
66+
UpgradePolicy: null

pkg/printers/testdata/yamltest_single.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
Status: ACTIVE
3131
Tags: null
3232
Version: null
33+
UpgradePolicy: null

userdocs/src/usage/gpu-support.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ use `--install-nvidia-plugin=false` with the create command. For example:
2424

2525
```
2626
eksctl create cluster --node-type=p2.xlarge --install-nvidia-plugin=false
27+
```
28+
29+
and, for versions 0.15.0 and above,
2730

31+
```
32+
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/<VERSION>/deployments/static/nvidia-device-plugin.yml
33+
```
34+
35+
or, for older versions,
36+
37+
```
2838
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/<VERSION>/nvidia-device-plugin.yml
2939
```
3040

0 commit comments

Comments
 (0)