-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pre-fetching sandbox image during bootstrap in containerd runtime (#730)
Co-authored-by: Sinha <[email protected]>
- Loading branch information
1 parent
73693cd
commit 5d109a1
Showing
7 changed files
with
62 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
### 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 --address=/run/dockershim.sock --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 |
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,12 @@ | ||
[Unit] | ||
Description=pull sandbox image defined in containerd config.toml | ||
# pulls sandbox image using ctr tool | ||
After=containerd.service | ||
Requires=containerd.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/etc/eks/containerd/pull-sandbox-image.sh | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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