Files
runner-images/images/windows/scripts/build/Install-KubernetesTools.ps1
Vasilii Polikarpov 5ed2615017 [Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely

* Add the Get-ChecksumFromUrl function

* Sort exported functions and add docs

* Remove alias and fix typo

* Fix kind checksum url and syntax

* Fix checksums url for gh cli and msys2

* [Windows] Cleanup various scripts

* Add spaces after type specifications

* Rename the Take-Part function
2023-12-04 10:50:53 +01:00

38 lines
1.3 KiB
PowerShell

################################################################################
## File: Install-KubernetesTools.ps1
## Desc: Install tools for K8s.
## Supply chain security: GitHub Kind - checksum validation, Kubectl, Helm, Minikube - by package manager
################################################################################
Write-Host "Install Kind"
# Choco installation can't be used because it depends on docker-desktop
$targetDir = "C:\ProgramData\kind"
New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
$downloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "kubernetes-sigs/kind" `
-Version "latest" `
-UrlMatchPattern "kind-windows-amd64"
$packagePath = Invoke-DownloadWithRetry -Url $downloadUrl -Path "$targetDir\kind.exe"
#region Supply chain security - Kind
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
-Url "$downloadUrl.sha256sum" `
-FileName (Split-Path $downloadUrl -Leaf)
Test-FileChecksum $packagePath -ExpectedSHA256Sum $externalHash
#endregion
Add-MachinePathItem $targetDir
Write-Host "Install Kubectl"
Install-ChocoPackage kubernetes-cli
Write-Host "Install Helm"
Install-ChocoPackage kubernetes-helm
Write-Host "Install Minikube"
Install-ChocoPackage minikube
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesTools"