@@ -4,14 +4,61 @@ set -o nounset
44set -o errexit
55set -o pipefail
66
7+ ECR_PUBLIC_REGISTRY=" public.ecr.aws"
8+ EKS_CONTAINER_REGISTRY=" 602401143452.dkr.ecr.us-west-2.amazonaws.com"
9+
10+ # get_ecr_image_tags <REGISTRY> <REPOSITORY>
11+ # e.g. get_ecr_image_tags $ECR_PUBLIC_REGISTRY amazonlinux/amazonlinux
12+ get_ecr_image_tags () {
13+ set -e
14+ local REGISTRY=$1
15+ local REPOSITORY=$2
16+ local TOKEN
17+
18+ # Get ECR public token if image is from a public registry, otherwise use a private token
19+ # An authorization token is required for every ECR HTTP request
20+ if [ " $REGISTRY " = " $ECR_PUBLIC_REGISTRY " ]; then
21+ TOKEN=$( aws ecr-public get-authorization-token --region us-east-1 --output=text --query ' authorizationData.authorizationToken' )
22+ local AUTHORIZATION_TYPE=" Bearer"
23+ else
24+ TOKEN=$( aws ecr get-authorization-token --output text --query ' authorizationData[].authorizationToken' )
25+ local AUTHORIZATION_TYPE=" Basic"
26+ fi
27+
28+ curl -s -H " Authorization: ${AUTHORIZATION_TYPE} $TOKEN " " https://$REGISTRY /v2/$REPOSITORY /tags/list" | jq ' .tags'
29+ }
30+
31+ # update_image_uris REPOSITORY IMAGE_TAG
32+ update_image_uris () {
33+ local REPOSITORY=$1
34+ local NEW_TAG=$2
35+ PREFIX=" image: ${REPOSITORY} "
36+ find ./test/manifests -type f -exec sed -i " s#$PREFIX :.*#$PREFIX :$NEW_TAG #g" {} +
37+ }
38+
739# update the nvidia k8s device plugin
40+ echo " Updating Nvidia device plugin image"
41+ NVIDIA_DEVICE_PLUGIN_TAG=$( curl -s ' https://catalog.ngc.nvidia.com/api/containers/images?orgName=nvidia&name=k8s-device-plugin&isPublic=true' | jq -r ' .images | sort_by(.updatedDate) | reverse | map(select(.tag | test("^v[0-9]+.[0-9]+.[0-9]+$"))) | first | .tag' )
42+ update_image_uris nvcr.io/nvidia/k8s-device-plugin $NVIDIA_DEVICE_PLUGIN_TAG
843
9- NVIDIA_DEVICE_PLUGIN= $( curl -s ' https://catalog.ngc.nvidia.com/api/containers/images?orgName=nvidia&name=k8s-device-plugin&isPublic=true ' | jq -r ' .images | sort_by(.updatedDate) | reverse | map(select(.tag | test("^v[0-9]+.[0-9]+.[0-9]+$"))) | first | .tag ' )
10- PREFIX= " image: nvcr.io/nvidia/k8s-device-plugin "
11- find ./test/manifests -type f -exec sed -i " s# $PREFIX :.*# $PREFIX : $NVIDIA_DEVICE_PLUGIN #g " {} +
44+ # below updates require authentication and should not exit early with a failure.
45+ # TODO: remove this once the aws credentials are setup and the paths are expected to succeed.
46+ set +e
1247
1348# update the neuron k8s device plugin
14- # TODO
49+ echo " Updating Neuron device plugin image"
50+ NEURON_DEVICE_PLUGIN_REPOSITORY_NAME=" neuron/neuron-device-plugin"
51+ NEURON_DEVICE_PLUGIN_TAGS=$( get_ecr_image_tags $ECR_PUBLIC_REGISTRY $NEURON_DEVICE_PLUGIN_REPOSITORY_NAME )
52+ if [ $? -eq 0 ]; then
53+ LATEST_NEURON_DEVICE_PLUGIN_TAG=$( echo $NEURON_DEVICE_PLUGIN_TAGS | jq -r ' max_by(split(".") | map(tonumber))' )
54+ update_image_uris " ${ECR_PUBLIC_REGISTRY} /${NEURON_DEVICE_PLUGIN_REPOSITORY_NAME} " $LATEST_NEURON_DEVICE_PLUGIN_TAG
55+ fi
1556
1657# update the efa k8s device plugin
17- # TODO
58+ echo " Updating EFA device plugin image"
59+ EFA_DEVICE_PLUGIN_REPOSITORY_NAME=" eks/aws-efa-k8s-device-plugin"
60+ EFA_DEVICE_PLUGIN_TAGS=$( get_ecr_image_tags $EKS_CONTAINER_REGISTRY $EFA_DEVICE_PLUGIN_REPOSITORY_NAME )
61+ if [ $? -eq 0 ]; then
62+ LATEST_EFA_DEVICE_PLUGIN_TAG=$( echo $EFA_DEVICE_PLUGIN_TAGS | jq -r ' map(split("-") | .[0]) | max_by(sub("^v"; "") | split(".") | map(tonumber))' )
63+ update_image_uris " ${EKS_CONTAINER_REGISTRY} /${EFA_DEVICE_PLUGIN_REPOSITORY_NAME} " $LATEST_EFA_DEVICE_PLUGIN_TAG
64+ fi
0 commit comments