Skip to content

Instantly share code, notes, and snippets.

@sumanthkumarc
Created May 12, 2023 11:17
Show Gist options
  • Save sumanthkumarc/2a5fd1c9e05a76e5d622c68e3990b79b to your computer and use it in GitHub Desktop.
Save sumanthkumarc/2a5fd1c9e05a76e5d622c68e3990b79b to your computer and use it in GitHub Desktop.
argocd - custom actions added with upstream actions
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/instance: argocd
app.kubernetes.io/name: argocd-cm
name: argocd-cm
namespace: argocd
data:
resource.customizations.actions.apps_Deployment: |
discovery.lua: |
actions = {}
actions["restart-100%-in-1-batch"] = {}
actions["restart"] = {}
local paused = false
if obj.spec.paused ~= nil then
paused = obj.spec.paused
actions["pause"] = {paused}
end
actions["resume"] = {["disabled"] = not(paused)}
return actions
definitions:
- name: pause
action.lua: |
obj.spec.paused = true
return obj
- name: resume
action.lua: |
obj.spec.paused = nil
return obj
- name: restart
action.lua: |
local os = require("os")
if obj.spec.template.metadata == nil then
obj.spec.template.metadata = {}
end
if obj.spec.template.metadata.annotations == nil then
obj.spec.template.metadata.annotations = {}
end
obj.spec.template.metadata.annotations["kubectl.kubernetes.io/restartedAt"] = os.date("!%Y-%m-%dT%XZ")
return obj
- name: restart-100%-in-1-batch
action.lua: |
local os = require("os")
if obj.spec.template.metadata == nil then
obj.spec.template.metadata = {}
end
if obj.spec.template.metadata.annotations == nil then
obj.spec.template.metadata.annotations = {}
end
if obj.spec.strategy.rollingUpdate == nil then
obj.spec.strategy.rollingUpdate = {}
end
obj.spec.strategy.rollingUpdate.maxSurge = "100%"
obj.spec.template.metadata.annotations["kubectl.kubernetes.io/restartedAt"] = os.date("!%Y-%m-%dT%XZ")
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment