Skip to content

Commit

Permalink
Merge pull request #1518 from OctopusDeploy/add-argo-rollout-steps
Browse files Browse the repository at this point in the history
Adding argo rollout step templates
  • Loading branch information
twerthi authored Jun 7, 2024
2 parents 7bccb40 + ae71c4c commit 96becf2
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ function humanize(categoryId) {
return "ApexSQL";
case "apollo":
return "Apollo GraphQL";
case "argo":
return "Argo";
case "aspnet":
return "ASP.NET";
case "aws":
Expand Down
45 changes: 45 additions & 0 deletions step-templates/argo-rollouts-pause.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"Id": "a757705d-2551-42bf-8cef-8dd99bd6b4f9",
"Name": "Argo - Rollouts Pause",
"Description": "Set the rollout paused state to 'true'",
"ActionType": "Octopus.KubernetesRunScript",
"Version": 1,
"CommunityActionTemplateId": null,
"Packages": [],
"GitDependencies": [],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "# Installs the Argo Rollouts plugin\nfunction Install-Plugin\n{\n# Define parameters\n\tparam ($PluginUri,\n $PluginFilename\n )\n \n # Check for plugin folder\n if ((Test-Path -Path \"$PWD/plugins\") -eq $false)\n {\n\t\t# Create new plugins folder\n New-Item -Path \"$PWD/plugins\" -ItemType \"Directory\"\n \n # Add to path\n $env:PATH = \"$($PWD)/plugins$([IO.Path]::PathSeparator)\" + $env:PATH\n }\n\n\t# Download plugin\n\tInvoke-WebRequest -Uri \"$PluginUri\" -OutFile \"$PWD/plugins/$PluginFilename\"\n\n\t# Make file executable\n if ($IsLinux)\n {\n\t\t# Make it executable\n \tchmod +x ./plugins/$PluginFilename\n }\n \n if ($IsWindows)\n {\n \t# Update filename to include .exe extension\n Rename-Item -Path \"$PWD/plugins/$PluginFilename\" -NewName \"$PWD/plugins/$($PluginFilename).exe\"\n }\n}\n\n# When listing plugins, kubectl looks in all paths defined in $env:PATH and will fail if the path does not exist\nfunction Verify-Path-Variable\n{\n\t# Get current path and split into array\n $paths = $env:PATH.Split([IO.Path]::PathSeparator)\n $verifiedPaths = @()\n \n # Loop through paths\n foreach ($path in $paths)\n {\n \t# Check for existence\n if ((Test-Path -Path $path) -eq $true)\n {\n \t# Add to verified\n $verifiedPaths += $path\n }\n }\n \n # Return verified paths\n return ($verifiedPaths -join [IO.Path]::PathSeparator)\n}\n\nfunction Get-Plugin-Installed\n{\n\t# Define parameters\n param (\n \t$PluginName,\n $InstalledPlugins\n )\n \n \t$isInstalled = $false\n \n\tforeach ($plugin in $installedPlugins)\n \t{\n\t\tif ($plugin -like \"$($PluginName)*\")\n {\n \t$isInstalled = $true\n \tbreak\n }\n\t}\n \n return $isInstalled\n}\n\n# Check to see if $IsWindows is available\nif ($null -eq $IsWindows) {\n Write-Host \"Determining Operating System...\"\n $IsWindows = ([System.Environment]::OSVersion.Platform -eq \"Win32NT\")\n $IsLinux = ([System.Environment]::OSVersion.Platform -eq \"Unix\")\n}\n\n# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Check to see if it's running on Windows\nif ($IsWindows) {\n # Disable the progress bar so downloading files via Invoke-WebRequest are faster\n $ProgressPreference = 'SilentlyContinue'\n}\n\n# Set TLS\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12\n\n# Verify all PATH variables are avaialable\n$env:PATH = Verify-Path-Variable\nif ($IsLinux)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64\"\n}\n\nif ($IsWindows)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-windows-amd64\"\n}\n\ntry \n{\n # Check to see if plugins are installed\n $pluginList = (kubectl plugin list 2>&1)\n\n # This is the path that Linux will take\n if ($lastExitCode -ne 0 -and $pluginList.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\") \n {\n Install-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n # Parse list\n \t$pluginList = $pluginList.Split(\"`n\", [System.StringSplitOptions]::RemoveEmptyEntries)\n \n if ((Get-Plugin-Installed -PluginName \"kubectl-argo-rollouts\" -InstalledPlugins $pluginList) -eq $false)\n {\n \tInstall-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n \tWrite-Host \"Argo Rollout kubectl plugin found ...\"\n }\n } \n}\ncatch\n{\n\t# On Windows, the executable will cause an error if no plugins found so this the path Windows will take\n if ($_.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\")\n {\n Install-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\" \n }\n else\n {\n \t# Something else happened, we need to surface the error\n throw\n }\n}\n\n# Get parameters\n$rolloutsName = $OctopusParameters['Argo.Rollout.Name']\n$rolloutsNamespace = $OctopusParameters['Argo.Rollout.Namespace']\n\n# Create arguments array\n$kubectlArguments = @(\"argo\", \"rollouts\", \"pause\", $rolloutsName, \"--namespace\", $rolloutsNamespace)\n\n# Pause rollout\nkubectl $kubectlArguments"
},
"Parameters": [
{
"Id": "d7665ee0-08b1-4c3a-b7f9-bf9ccfa63219",
"Name": "Argo.Rollout.Name",
"Label": "Rollout Name",
"HelpText": "Name of the Argo Rollout to pause.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "8a9ed999-5c3f-4652-abbb-07f592205bfc",
"Name": "Argo.Rollout.Namespace",
"Label": "Namespace",
"HelpText": "The namespace where the rollout exists.",
"DefaultValue": "default",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"StepPackageId": "Octopus.KubernetesRunScript",
"$Meta": {
"ExportedAt": "2024-06-06T19:54:47.156Z",
"OctopusVersion": "2024.1.12815",
"Type": "ActionTemplate"
},
"LastModifiedBy": "twerthi",
"Category": "argo"
}
55 changes: 55 additions & 0 deletions step-templates/argo-rollouts-promote.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Id": "cccd7fe9-b3b5-4f56-84bd-2986d5e68e06",
"Name": "Argo - Rollouts Promote",
"Description": "Promotes an Argo Rollout.",
"ActionType": "Octopus.KubernetesRunScript",
"Version": 1,
"CommunityActionTemplateId": null,
"Packages": [],
"GitDependencies": [],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "# Installs the Argo Rollouts plugin\nfunction Install-Plugin\n{\n# Define parameters\n\tparam ($PluginUri,\n $PluginFilename\n )\n \n # Check for plugin folder\n if ((Test-Path -Path \"$PWD/plugins\") -eq $false)\n {\n\t\t# Create new plugins folder\n New-Item -Path \"$PWD/plugins\" -ItemType \"Directory\"\n \n # Add to path\n $env:PATH = \"$($PWD)/plugins$([IO.Path]::PathSeparator)\" + $env:PATH\n }\n\n\t# Download plugin\n\tInvoke-WebRequest -Uri \"$PluginUri\" -OutFile \"$PWD/plugins/$PluginFilename\"\n\n\t# Make file executable\n if ($IsLinux)\n {\n\t\t# Make it executable\n \tchmod +x ./plugins/$PluginFilename\n }\n \n if ($IsWindows)\n {\n \t# Update filename to include .exe extension\n Rename-Item -Path \"$PWD/plugins/$PluginFilename\" -NewName \"$PWD/plugins/$($PluginFilename).exe\"\n }\n}\n\n# When listing plugins, kubectl looks in all paths defined in $env:PATH and will fail if the path does not exist\nfunction Verify-Path-Variable\n{\n\t# Get current path and split into array\n $paths = $env:PATH.Split([IO.Path]::PathSeparator)\n $verifiedPaths = @()\n \n # Loop through paths\n foreach ($path in $paths)\n {\n \t# Check for existence\n if ((Test-Path -Path $path) -eq $true)\n {\n \t# Add to verified\n $verifiedPaths += $path\n }\n }\n \n # Return verified paths\n return ($verifiedPaths -join [IO.Path]::PathSeparator)\n}\n\nfunction Get-Plugin-Installed\n{\n\t# Define parameters\n param (\n \t$PluginName,\n $InstalledPlugins\n )\n \n \t$isInstalled = $false\n \n\tforeach ($plugin in $installedPlugins)\n \t{\n\t\tif ($plugin -like \"$($PluginName)*\")\n {\n \t$isInstalled = $true\n \tbreak\n }\n\t}\n \n return $isInstalled\n}\n\n# Check to see if $IsWindows is available\nif ($null -eq $IsWindows) {\n Write-Host \"Determining Operating System...\"\n $IsWindows = ([System.Environment]::OSVersion.Platform -eq \"Win32NT\")\n $IsLinux = ([System.Environment]::OSVersion.Platform -eq \"Unix\")\n}\n\n# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Check to see if it's running on Windows\nif ($IsWindows) {\n # Disable the progress bar so downloading files via Invoke-WebRequest are faster\n $ProgressPreference = 'SilentlyContinue'\n}\n\n# Set TLS\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12\n\n# Verify all PATH variables are avaialable\n$env:PATH = Verify-Path-Variable\nif ($IsLinux)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64\"\n}\n\nif ($IsWindows)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-windows-amd64\"\n}\n\ntry \n{\n # Check to see if plugins are installed\n $pluginList = (kubectl plugin list 2>&1)\n\n # This is the path that Linux will take\n if ($lastExitCode -ne 0 -and $pluginList.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\") \n {\n Install-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n # Parse list\n \t$pluginList = $pluginList.Split(\"`n\", [System.StringSplitOptions]::RemoveEmptyEntries)\n \n if ((Get-Plugin-Installed -PluginName \"kubectl-argo-rollouts\" -InstalledPlugins $pluginList) -eq $false)\n {\n \tInstall-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n \tWrite-Host \"Argo Rollout kubectl plugin found ...\"\n }\n } \n}\ncatch\n{\n\t# On Windows, the executable will cause an error if no plugins found so this the path Windows will take\n if ($_.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\")\n {\n\t\tInstall-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\" \n }\n else\n {\n \t# Something else happened, we need to surface the error\n throw\n }\n}\n\n# Get parameters\n$rolloutsName = $OctopusParameters['Argo.Rollout.Name']\n$rolloutsNamespace = $OctopusParameters['Argo.Rollout.Namespace']\n$rolloutsFullPromotion = [System.Convert]::ToBoolean($OctopusParameters['Argo.Rollout.FullPromotion'])\n\n# Create arguments array\n$kubectlArguments = @(\"argo\", \"rollouts\", \"promote\", $rolloutsName, \"--namespace\", $rolloutsNamespace)\n\n# Check for additional argument\nif ($rolloutsFullPromotion)\n{\n\t$kubectlArguments += \"--full\"\n}\n\n# Promote rollout\nkubectl $kubectlArguments"
},
"Parameters": [
{
"Id": "d1dbd00e-facb-494d-bf10-27ba68334f30",
"Name": "Argo.Rollout.Name",
"Label": "Rollout Name",
"HelpText": "Name of the Argo Rollout to promote.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "c9c4937a-e833-4df0-8f31-b53722b881c3",
"Name": "Argo.Rollout.Namespace",
"Label": "Namespace",
"HelpText": "The namespace to execute the promotion of the rollout against.",
"DefaultValue": "default",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "efaf2401-e059-4724-b2b3-30ac8864e450",
"Name": "Argo.Rollout.FullPromotion",
"Label": "Full Promotion",
"HelpText": "Fully promote a rollout to desired version, skipping analysis, pauses, and steps",
"DefaultValue": "False",
"DisplaySettings": {
"Octopus.ControlType": "Checkbox"
}
}
],
"StepPackageId": "Octopus.KubernetesRunScript",
"$Meta": {
"ExportedAt": "2024-06-06T19:55:28.116Z",
"OctopusVersion": "2024.1.12815",
"Type": "ActionTemplate"
},
"LastModifiedBy": "twerthi",
"Category": "argo"
}
79 changes: 79 additions & 0 deletions step-templates/argo-rollouts-set-image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"Id": "5449ea73-7f77-45d7-a4d7-e56286d679f5",
"Name": "Argo - Rollouts Set Image",
"Description": "Sets a new image tag on an Argo Rollout.",
"ActionType": "Octopus.KubernetesRunScript",
"Version": 1,
"CommunityActionTemplateId": null,
"Packages": [
{
"Id": "67a06773-8f2b-49a7-95bb-1e087a38b3b9",
"Name": "Argo.Rollout.Image",
"PackageId": null,
"FeedId": "feeds-builtin",
"AcquisitionLocation": "NotAcquired",
"Properties": {
"Extract": "True",
"SelectionMode": "deferred",
"PackageParameterName": "Argo.Rollout.Image",
"Purpose": ""
}
}
],
"GitDependencies": [],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "function Install-Plugin\n{\n# Define parameters\n\tparam ($PluginUri,\n $PluginFilename\n )\n \n # Check for plugin folder\n if ((Test-Path -Path \"$PWD/plugins\") -eq $false)\n {\n\t\t# Create new plugins folder\n New-Item -Path \"$PWD/plugins\" -ItemType \"Directory\"\n \n # Add to path\n $env:PATH = \"$($PWD)/plugins$([IO.Path]::PathSeparator)\" + $env:PATH\n }\n\n\t# Download plugin\n\tInvoke-WebRequest -Uri \"$PluginUri\" -OutFile \"$PWD/plugins/$PluginFilename\"\n\n\t# Check for Linux\n if ($IsLinux)\n {\n\t\t# Make it executable\n \tchmod +x ./plugins/$PluginFilename\n }\n \n if ($IsWindows)\n {\n \t# Update filename to include .exe extension\n Rename-Item -Path \"$PWD/plugins/$PluginFilename\" -NewName \"$PWD/plugins/$($PluginFilename).exe\"\n } \n}\n\n# When listing plugins, kubectl looks in all paths defined in $env:PATH and will fail if the path does not exist\nfunction Verify-Path-Variable\n{\n\t# Get current path and split into array\n $paths = $env:PATH.Split([IO.Path]::PathSeparator)\n $verifiedPaths = @()\n \n # Loop through paths\n foreach ($path in $paths)\n {\n \t# Check for existence\n if ((Test-Path -Path $path) -eq $true)\n {\n \t# Add to verified\n $verifiedPaths += $path\n }\n }\n \n # Return verified paths\n return ($verifiedPaths -join [IO.Path]::PathSeparator)\n}\n\nfunction Get-Plugin-Installed\n{\n\t# Define parameters\n param (\n \t$PluginName,\n $InstalledPlugins\n )\n \n \t$isInstalled = $false\n \n\tforeach ($plugin in $installedPlugins)\n \t{\n\t\tif ($plugin -like \"$($PluginName)*\")\n {\n \t$isInstalled = $true\n \tbreak\n }\n\t}\n \n return $isInstalled\n}\n\n# Check to see if $IsWindows is available\nif ($null -eq $IsWindows) {\n Write-Host \"Determining Operating System...\"\n $IsWindows = ([System.Environment]::OSVersion.Platform -eq \"Win32NT\")\n $IsLinux = ([System.Environment]::OSVersion.Platform -eq \"Unix\")\n}\n\n# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Check to see if it's running on Windows\nif ($IsWindows) {\n # Disable the progress bar so downloading files via Invoke-WebRequest are faster\n $ProgressPreference = 'SilentlyContinue'\n}\n\n# Set TLS\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12\n\n# Verify all PATH variables are avaialable\n$env:PATH = Verify-Path-Variable\nif ($IsLinux)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64\"\n}\n\nif ($IsWindows)\n{\n\t$pluginUri = \"https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-windows-amd64\"\n}\n\n\ntry \n{\n # Check to see if plugins are installed\n $pluginList = (kubectl plugin list --name-only=true 2>&1)\n\n # This is the path that Linux will take\n if ($lastExitCode -ne 0 -and $pluginList.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\") \n {\n # Install the plugin\n Install-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n # Parse list\n \t$pluginList = $pluginList.Split(\"`n\", [System.StringSplitOptions]::RemoveEmptyEntries)\n \n if ((Get-Plugin-Installed -PluginName \"kubectl-argo-rollouts\" -InstalledPlugins $pluginList) -eq $false)\n {\n \tInstall-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\"\n }\n else\n {\n \tWrite-Host \"Argo Rollout kubectl plugin found ...\"\n }\n }\n}\ncatch\n{\n\t# On Windows, the executable will cause an error if no plugins found so this the path Windows will take\n if ($_.Exception.Message -eq \"error: unable to find any kubectl plugins in your PATH\")\n {\n Install-Plugin -PluginUri $pluginUri -PluginFilename \"kubectl-argo-rollouts\" \n }\n else\n {\n \t# Something else happened, we need to surface the error\n throw\n }\n}\n\n# Get variables\n$rolloutName = $OctopusParameters['Argo.Rollout.Name']\n$rolloutNamespace = $OctopusParameters['Argo.Rollout.Namespace']\n$containerName = $OctopusParameters[\"Argo.Rollout.Container.Name\"]\n$imageName = $OctopusParameters[\"Octopus.Action.Package[Argo.Rollout.Image].PackageId\"]\n$imageTag = $OctopusParameters[\"Octopus.Action.Package[Argo.Rollout.Image].PackageVersion\"]\n\n# Create arguments array\n$kubectlArguments = @(\"argo\", \"rollouts\", \"set\", \"image\", $rolloutName, \"$containerName=`\"$($imageName):$($imageTag)`\"\", \"--namespace\", $rolloutNamespace)\n\n# Set image\nkubectl $kubectlArguments"
},
"Parameters": [
{
"Id": "892ac50a-e53c-47e5-997d-0ce1935b7303",
"Name": "Argo.Rollout.Name",
"Label": "Rollout Name",
"HelpText": "Name of the Argo Rollout to set the image on.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "a08c104a-3877-4989-9436-bf582b3a8505",
"Name": "Argo.Rollout.Namespace",
"Label": "Namespace",
"HelpText": "The namespace to execute the command against.",
"DefaultValue": "default",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "05bf80a9-0419-4d8d-b9ca-457d66a2edb0",
"Name": "Argo.Rollout.Image",
"Label": "Image",
"HelpText": "Select the image to update the rollout to.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Package"
}
},
{
"Id": "115ebf6d-5613-4131-83f5-03d74fbc0f14",
"Name": "Argo.Rollout.Container.Name",
"Label": "Container Name",
"HelpText": "Name of the container to update the image tag on.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"StepPackageId": "Octopus.KubernetesRunScript",
"$Meta": {
"ExportedAt": "2024-06-06T19:56:12.397Z",
"OctopusVersion": "2024.1.12815",
"Type": "ActionTemplate"
},
"LastModifiedBy": "twerthi",
"Category": "argo"
}
Loading

0 comments on commit 96becf2

Please sign in to comment.