Skip to content

Commit a553e9b

Browse files
authored
Merge pull request #507 from zylxjtu/containerd
Dynamically download the latest containerd image when specified
2 parents 458825d + 823818a commit a553e9b

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed

capz/templates/gmsa-ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

capz/templates/gmsa-pr.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

capz/templates/shared-image-gallery-ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

capz/templates/windows-base.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

capz/templates/windows-ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

capz/templates/windows-pr.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ spec:
3232
Stop-Service kubelet -Force -ErrorAction SilentlyContinue
3333
Stop-Service containerd -Force
3434
echo "downloading containerd: $$CONTAINERD_URL"
35+
# If the URL is set to "latest", we will query the GitHub API for the latest containerd release
36+
if ($$CONTAINERD_URL.ToLower() -eq "latest") {
37+
# Query GitHub API for latest containerd release for Windows
38+
$githubApiUrl = "https://api.github.com/repos/containerd/containerd/releases/latest"
39+
Write-Output "Fetching latest containerd release from GitHub..."
40+
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl -UseBasicParsing
41+
$asset = $releaseInfo.assets | Where-Object { $_.name -like "*windows-amd64.tar.gz" } | Select-Object -First 1
42+
if ($null -eq $asset) {
43+
Write-Output "Could not find a Windows containerd release asset in the latest GitHub release."
44+
exit 1
45+
}
46+
$$CONTAINERD_URL = $asset.browser_download_url
47+
}
3548
curl.exe --retry 10 --retry-delay 5 -L "$$CONTAINERD_URL" --output "c:/k/containerd.tar.gz"
3649
# Log service state and if any files under containerd director are locked
3750
Get-Service -Name containerd, kubelet

0 commit comments

Comments
 (0)