Skip to content

Commit

Permalink
Add GH workflow for automatically updating nvidia device plugin stati…
Browse files Browse the repository at this point in the history
…c manifest
  • Loading branch information
TiberiuGC committed Jul 26, 2024
1 parent 02c41d5 commit 0da36b5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ generate-all: generate-always $(conditionally_generated_files) ## Re-generate al
check-all-generated-files-up-to-date: generate-all ## Run the generate all command and verify there is no new diff
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)

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

.PHONY: update-aws-node
update-aws-node: ## Re-download the aws-node manifests from AWS
Expand Down
33 changes: 33 additions & 0 deletions pkg/addons/assets/scripts/update_nvidia_device_plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

get_latest_release_tag() {
curl -sL https://api.github.com/repos/NVIDIA/k8s-device-plugin/releases/latest | jq -r '.tag_name'
}

latest_release_tag=$(get_latest_release_tag)

# Check if the latest release tag was found
if [ -z "$latest_release_tag" ]; then
echo "Could not find the latest release tag."
exit 1
fi

# If running in GitHub Actions, export the release tag for use in the workflow
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "LATEST_RELEASE_TAG=$latest_release_tag" >> $GITHUB_ENV
else
echo "Found the latest release tag: $latest_release_tag"
fi

assets_addons_dir="pkg/addons/assets"

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"


# Check if the download was successful
if [ $? -eq 0 ]; then
echo "Downloaded the latest NVIDIA device plugin manifest to $assets_addons_dir/nvidia-device-plugin.yaml"
else
echo "Failed to download the NVIDIA device plugin manifest."
exit 1
fi
23 changes: 21 additions & 2 deletions pkg/addons/default/scripts/update_aws_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,31 @@ get_latest_release_tag() {

latest_release_tag=$(get_latest_release_tag)

# Check if the latest release tag was found
if [ -z "$latest_release_tag" ]; then
echo "Could not find the latest release tag."
exit 1
fi

# If running in GitHub Actions, export the release tag for use in the workflow
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "LATEST_RELEASE_TAG=$latest_release_tag" >> $GITHUB_ENV
else
echo "Found the latest release tag: $latest_release_tag"
fi

default_addons_dir="pkg/addons/default"

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

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

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

0 comments on commit 0da36b5

Please sign in to comment.