-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache pause, vpc-cni, and kube-proxy images during build (#938)
- Loading branch information
Showing
8 changed files
with
338 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# More details about the mappings in this file can be found here https://docs.aws.amazon.com/eks/latest/userguide/add-ons-images.html | ||
|
||
region=$1 | ||
aws_domain=$2 | ||
if [[ $# -eq 3 ]] && [[ ! -z $3 ]]; then | ||
acct=$3 | ||
else | ||
case "${region}" in | ||
ap-east-1) | ||
acct="800184023465" | ||
;; | ||
me-south-1) | ||
acct="558608220178" | ||
;; | ||
cn-north-1) | ||
acct="918309763551" | ||
;; | ||
cn-northwest-1) | ||
acct="961992271922" | ||
;; | ||
us-gov-west-1) | ||
acct="013241004608" | ||
;; | ||
us-gov-east-1) | ||
acct="151742754352" | ||
;; | ||
us-iso-east-1) | ||
acct="725322719131" | ||
;; | ||
us-isob-east-1) | ||
acct="187977181151" | ||
;; | ||
af-south-1) | ||
acct="877085696533" | ||
;; | ||
eu-south-1) | ||
acct="590381155156" | ||
;; | ||
ap-southeast-3) | ||
acct="296578399912" | ||
;; | ||
me-central-1) | ||
acct="759879836304" | ||
;; | ||
*) | ||
acct="602401143452" | ||
;; | ||
esac | ||
fi | ||
|
||
echo "${acct}.dkr.ecr.${region}.${aws_domain}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
img=$1 | ||
region=$(echo "${img}" | cut -f4 -d ".") | ||
MAX_RETRIES=3 | ||
|
||
function retry() { | ||
local rc=0 | ||
for attempt in $(seq 0 $MAX_RETRIES); do | ||
rc=0 | ||
[[ $attempt -gt 0 ]] && echo "Attempt $attempt of $MAX_RETRIES" 1>&2 | ||
"$@" | ||
rc=$? | ||
[[ $rc -eq 0 ]] && break | ||
[[ $attempt -eq $MAX_RETRIES ]] && exit $rc | ||
local jitter=$((1 + RANDOM % 10)) | ||
local sleep_sec="$(($((5 << $((1 + $attempt)))) + $jitter))" | ||
sleep $sleep_sec | ||
done | ||
} | ||
|
||
ecr_password=$(retry aws ecr get-login-password --region $region) | ||
if [[ -z ${ecr_password} ]]; then | ||
echo >&2 "Unable to retrieve the ECR password." | ||
exit 1 | ||
fi | ||
retry sudo ctr --namespace k8s.io image pull "${img}" --user AWS:${ecr_password} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
### fetching sandbox image from /etc/containerd/config.toml | ||
sandbox_image=$(awk -F'[ ="]+' '$1 == "sandbox_image" { print $2 }' /etc/containerd/config.toml) | ||
region=$(echo "$sandbox_image" | cut -f4 -d ".") | ||
ecr_password=$(aws ecr get-login-password --region $region) | ||
API_RETRY_ATTEMPTS=5 | ||
|
||
for attempt in $(seq 0 $API_RETRY_ATTEMPTS); do | ||
rc=0 | ||
if [[ $attempt -gt 0 ]]; then | ||
echo "Attempt $attempt of $API_RETRY_ATTEMPTS" | ||
fi | ||
### pull sandbox image from ecr | ||
### username will always be constant i.e; AWS | ||
sudo ctr --namespace k8s.io image pull $sandbox_image --user AWS:$ecr_password | ||
rc=$? | ||
if [[ $rc -eq 0 ]]; then | ||
break | ||
fi | ||
if [[ $attempt -eq $API_RETRY_ATTEMPTS ]]; then | ||
exit $rc | ||
fi | ||
jitter=$((1 + RANDOM % 10)) | ||
sleep_sec="$(($((5 << $((1 + $attempt)))) + $jitter))" | ||
sleep $sleep_sec | ||
done | ||
sandbox_image="$(awk -F'[ ="]+' '$1 == "sandbox_image" { print $2 }' /etc/containerd/config.toml)" | ||
/etc/eks/containerd/pull-image.sh "${sandbox_image}" |
Oops, something went wrong.