From bc8d68bdbd40ccc2b1a8c964b71486a9a791354c Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:17:52 +0100 Subject: [PATCH] Add kubernetes kubectl --- Evergreen/Apps/Get-KubernetesKubectl.ps1 | 31 +++++++++++++++++++ Evergreen/Manifests/KubernetesKubectl.json | 36 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 Evergreen/Apps/Get-KubernetesKubectl.ps1 create mode 100644 Evergreen/Manifests/KubernetesKubectl.json diff --git a/Evergreen/Apps/Get-KubernetesKubectl.ps1 b/Evergreen/Apps/Get-KubernetesKubectl.ps1 new file mode 100644 index 00000000..8d14e5ac --- /dev/null +++ b/Evergreen/Apps/Get-KubernetesKubectl.ps1 @@ -0,0 +1,31 @@ +Function Get-KubernetesKubectl { + <# + .SYNOPSIS + Returns the available Kubernetes Kubectl versions. + + .NOTES + Author: BornToBeRoot + Twitter: @_BornToBeRoot + #> + [OutputType([System.Management.Automation.PSObject])] + [CmdletBinding(SupportsShouldProcess = $False)] + param ( + [Parameter(Mandatory = $False, Position = 0)] + [ValidateNotNull()] + [System.Management.Automation.PSObject] + $res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1]) + ) + + # Get the latest version for kubectl + $Version = Invoke-RestMethod -Uri $res.Get.Update.Uri + + # Build the download links for each platform & architecture + foreach ($DownloadUri in $res.Get.Download.Uri.GetEnumerator()) { + [pscustomobject] @{ + Version = $Version + Architecture = $DownloadUri.Name.Split("_")[1] + Platform = $DownloadUri.Name.Split("_")[0] + URI = $DownloadUri.Value -replace $res.Get.Download.ReplaceVersionText, $Version + } + } +} diff --git a/Evergreen/Manifests/KubernetesKubectl.json b/Evergreen/Manifests/KubernetesKubectl.json new file mode 100644 index 00000000..05436fc2 --- /dev/null +++ b/Evergreen/Manifests/KubernetesKubectl.json @@ -0,0 +1,36 @@ +{ + "Name": "Kubernetes Kubectl", + "Source": "https://kubernetes.io/", + "Get": { + "Update": { + "Uri": "https://cdn.dl.k8s.io/release/stable.txt" + }, + "Download": { + "Uri": { + "Windows_x64": "https://dl.k8s.io/release/#version/bin/windows/amd64/kubectl.exe", + "Windows_x86": "https://dl.k8s.io/release/#version/bin/windows/386/kubectl.exe", + "Windows_arm64": "https://dl.k8s.io/release/#version/bin/windows/arm64/kubectl.exe", + "Linux_x64": "https://dl.k8s.io/release/#version/bin/linux/amd64/kubectl", + "Linux_arm64": "https://dl.k8s.io/release/#version/bin/linux/arm64/kubectl", + "Darwin_x64": "https://dl.k8s.io/release/#version/bin/darwin/amd64/kubectl", + "Darwin_arm64": "https://dl.k8s.io/release/#version/bin/darwin/arm64/kubectl" + }, + "ReplaceVersionText": "#version" + } + }, + "Install": { + "Setup": { + "Windows": "kubectl.exe", + "Linux" : "kubectl", + "Darwin" : "kubectl" + }, + "Physical": { + "Arguments": "", + "PostInstall": [] + }, + "Virtual": { + "Arguments": "", + "PostInstall": [] + } + } +}