install-kubectl.ps1
<#PSScriptInfo
.VERSION 1.2 .GUID 32a11a36-f91c-4241-a11f-af0cf3e90f38 .AUTHOR Karsten.Bott@labbuildr.com .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .DESCRIPTION This script is used during unsattended installs or to download kubectl on windows #> param( $Downloadlocation = $env:TEMP ) if (!(Test-Path $Downloadlocation)) { New-Item -ItemType Directory $Downloadlocation -ErrorAction SilentlyContinue | out-null } $uri = "https://kubernetes.io/docs/tasks/tools/install-kubectl/" $req = Invoke-WebRequest -UseBasicParsing -Uri $uri try { $downloadlink = ($req.Links | where href -Match "kubectl.exe").href } catch { Write-Warning "Error Parsing Link" } Start-BitsTransfer $downloadlink -DisplayName "Getting KubeCTL from $downloadlink" -Destination $Downloadlocation $Downloadfile = Join-Path $Downloadlocation "kubectl.exe" Unblock-File $Downloadfile Start-Process -FilePath $Downloadfile -ArgumentList "version" -Wait $Kube_Local = New-Item -ItemType directory "$HOME/.kube" -force Write-Host "You can now start kubectl from $Downloadfile copy your remote kubernetes cluster information to $($Kube_Local.Directory)/config " |