mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
This commit is contained in:
5
docs/operator-manual/resource_actions_builtin.md
generated
5
docs/operator-manual/resource_actions_builtin.md
generated
@@ -32,6 +32,11 @@
|
||||
- [image.toolkit.fluxcd.io/ImageUpdateAutomation/reconcile](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/image.toolkit.fluxcd.io/ImageUpdateAutomation/actions/reconcile/action.lua)
|
||||
- [image.toolkit.fluxcd.io/ImageUpdateAutomation/resume](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/image.toolkit.fluxcd.io/ImageUpdateAutomation/actions/resume/action.lua)
|
||||
- [image.toolkit.fluxcd.io/ImageUpdateAutomation/suspend](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/image.toolkit.fluxcd.io/ImageUpdateAutomation/actions/suspend/action.lua)
|
||||
- [keda.sh/ScaledJob/pause](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/keda.sh/ScaledJob/actions/pause/action.lua)
|
||||
- [keda.sh/ScaledJob/resume](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/keda.sh/ScaledJob/actions/resume/action.lua)
|
||||
- [keda.sh/ScaledObject/pause](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/keda.sh/ScaledObject/actions/pause/action.lua)
|
||||
- [keda.sh/ScaledObject/paused-replicas](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/keda.sh/ScaledObject/actions/paused-replicas/action.lua)
|
||||
- [keda.sh/ScaledObject/resume](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/keda.sh/ScaledObject/actions/resume/action.lua)
|
||||
- [kustomize.toolkit.fluxcd.io/Kustomization/reconcile](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/kustomize.toolkit.fluxcd.io/Kustomization/actions/reconcile/action.lua)
|
||||
- [kustomize.toolkit.fluxcd.io/Kustomization/resume](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/kustomize.toolkit.fluxcd.io/Kustomization/actions/resume/action.lua)
|
||||
- [kustomize.toolkit.fluxcd.io/Kustomization/suspend](https://github.com/argoproj/argo-cd/blob/master/resource_customizations/kustomize.toolkit.fluxcd.io/Kustomization/actions/suspend/action.lua)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
discoveryTests:
|
||||
- inputPath: testdata/scaledjob.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: resume
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
- inputPath: testdata/scaledjob-pause.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: resume
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
- inputPath: testdata/scaledjob-resume.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: resume
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
actionTests:
|
||||
- action: pause
|
||||
inputPath: testdata/scaledjob.yaml
|
||||
expectedOutputPath: testdata/scaledjob-pause.yaml
|
||||
|
||||
- action: resume
|
||||
inputPath: testdata/scaledjob-pause.yaml
|
||||
expectedOutputPath: testdata/scaledjob-resume.yaml
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
local actions = {}
|
||||
local paused = false
|
||||
|
||||
if obj.metadata and obj.metadata.annotations then
|
||||
paused = obj.metadata.annotations["autoscaling.keda.sh/paused"] == "true"
|
||||
end
|
||||
|
||||
actions["pause"] = {
|
||||
["disabled"] = paused,
|
||||
["iconClass"] = "fa fa-fw fa-pause-circle"
|
||||
}
|
||||
|
||||
actions["resume"] = {
|
||||
["disabled"] = not paused,
|
||||
["iconClass"] = "fa fa-fw fa-play-circle"
|
||||
}
|
||||
|
||||
return actions
|
||||
@@ -0,0 +1,7 @@
|
||||
local obj = obj or {}
|
||||
if obj.metadata == nil then obj.metadata = {} end
|
||||
if obj.metadata.annotations == nil then obj.metadata.annotations = {} end
|
||||
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused"] = "true"
|
||||
|
||||
return obj
|
||||
@@ -0,0 +1,6 @@
|
||||
local obj = obj or {}
|
||||
if obj.metadata and obj.metadata.annotations then
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused"] = nil
|
||||
end
|
||||
|
||||
return obj
|
||||
20
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob-pause.yaml
vendored
Normal file
20
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob-pause.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledJob
|
||||
metadata:
|
||||
name: test-scaledjob
|
||||
annotations:
|
||||
autoscaling.keda.sh/paused: "true"
|
||||
spec:
|
||||
jobTargetRef:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: test:latest
|
||||
triggers:
|
||||
- metadata:
|
||||
host: amqp://localhost:5672/vhost
|
||||
mode: QueueLength
|
||||
queueName: hello
|
||||
value: '1'
|
||||
type: rabbitmq
|
||||
18
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob-resume.yaml
vendored
Normal file
18
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob-resume.yaml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledJob
|
||||
metadata:
|
||||
name: test-scaledjob
|
||||
spec:
|
||||
jobTargetRef:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: test:latest
|
||||
triggers:
|
||||
- metadata:
|
||||
host: amqp://localhost:5672/vhost
|
||||
mode: QueueLength
|
||||
queueName: hello
|
||||
value: '1'
|
||||
type: rabbitmq
|
||||
18
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob.yaml
vendored
Normal file
18
resource_customizations/keda.sh/ScaledJob/actions/testdata/scaledjob.yaml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledJob
|
||||
metadata:
|
||||
name: test-scaledjob
|
||||
spec:
|
||||
jobTargetRef:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: test:latest
|
||||
triggers:
|
||||
- metadata:
|
||||
host: amqp://localhost:5672/vhost
|
||||
mode: QueueLength
|
||||
queueName: hello
|
||||
value: '1'
|
||||
type: rabbitmq
|
||||
@@ -0,0 +1,86 @@
|
||||
discoveryTests:
|
||||
- inputPath: testdata/scaledobject.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: paused-replicas
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
params:
|
||||
- name: replicas
|
||||
default: "0"
|
||||
- name: resume
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
- inputPath: testdata/scaledobject-pause.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: paused-replicas
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
params:
|
||||
- name: replicas
|
||||
default: "0"
|
||||
- name: resume
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
- inputPath: testdata/scaledobject-paused-replicas.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: paused-replicas
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
params:
|
||||
- name: replicas
|
||||
default: "0"
|
||||
- name: resume
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
- inputPath: testdata/scaledobject-resume.yaml
|
||||
result:
|
||||
- name: pause
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
- name: paused-replicas
|
||||
disabled: false
|
||||
iconClass: fa fa-fw fa-pause-circle
|
||||
params:
|
||||
- name: replicas
|
||||
default: "0"
|
||||
- name: resume
|
||||
disabled: true
|
||||
iconClass: fa fa-fw fa-play-circle
|
||||
|
||||
actionTests:
|
||||
- action: pause
|
||||
inputPath: testdata/scaledobject.yaml
|
||||
expectedOutputPath: testdata/scaledobject-pause.yaml
|
||||
|
||||
- action: resume
|
||||
inputPath: testdata/scaledobject-pause.yaml
|
||||
expectedOutputPath: testdata/scaledobject-resume.yaml
|
||||
|
||||
- action: paused-replicas
|
||||
inputPath: testdata/scaledobject.yaml
|
||||
expectedOutputPath: testdata/scaledobject-paused-replicas.yaml
|
||||
parameters:
|
||||
replicas: "6"
|
||||
|
||||
- action: paused-replicas
|
||||
inputPath: testdata/scaledobject.yaml
|
||||
expectedErrorMessage: "invalid number: not_a_number (must be >= 0)"
|
||||
parameters:
|
||||
replicas: "not_a_number"
|
||||
|
||||
- action: resume
|
||||
inputPath: testdata/scaledobject-paused-replicas.yaml
|
||||
expectedOutputPath: testdata/scaledobject-resume.yaml
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
local actions = {}
|
||||
local paused = false
|
||||
local hasPausedReplicas = false
|
||||
local currentPausedReplicas = nil
|
||||
|
||||
if obj.metadata and obj.metadata.annotations then
|
||||
paused = obj.metadata.annotations["autoscaling.keda.sh/paused"] == "true"
|
||||
currentPausedReplicas = obj.metadata.annotations["autoscaling.keda.sh/paused-replicas"]
|
||||
hasPausedReplicas = currentPausedReplicas ~= nil
|
||||
end
|
||||
|
||||
local isPaused = paused or hasPausedReplicas
|
||||
|
||||
actions["pause"] = {
|
||||
["disabled"] = isPaused,
|
||||
["iconClass"] = "fa fa-fw fa-pause-circle"
|
||||
}
|
||||
|
||||
actions["paused-replicas"] = {
|
||||
["disabled"] = paused,
|
||||
["iconClass"] = "fa fa-fw fa-pause-circle",
|
||||
["params"] = {
|
||||
{
|
||||
["name"] = "replicas",
|
||||
["default"] = currentPausedReplicas or "0"
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
actions["resume"] = {
|
||||
["disabled"] = not isPaused,
|
||||
["iconClass"] = "fa fa-fw fa-play-circle"
|
||||
}
|
||||
|
||||
return actions
|
||||
@@ -0,0 +1,7 @@
|
||||
local obj = obj or {}
|
||||
if obj.metadata == nil then obj.metadata = {} end
|
||||
if obj.metadata.annotations == nil then obj.metadata.annotations = {} end
|
||||
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused"] = "true"
|
||||
|
||||
return obj
|
||||
@@ -0,0 +1,17 @@
|
||||
local obj = obj or {}
|
||||
if obj.metadata == nil then obj.metadata = {} end
|
||||
if obj.metadata.annotations == nil then obj.metadata.annotations = {} end
|
||||
|
||||
local replicas = actionParams["replicas"]
|
||||
if not replicas then
|
||||
error("replicas parameter is required", 0)
|
||||
end
|
||||
|
||||
local replicasNum = tonumber(replicas)
|
||||
if not replicasNum or replicasNum < 0 then
|
||||
error("invalid number: " .. replicas .. " (must be >= 0)", 0)
|
||||
end
|
||||
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused-replicas"] = tostring(replicasNum)
|
||||
|
||||
return obj
|
||||
@@ -0,0 +1,7 @@
|
||||
local obj = obj or {}
|
||||
if obj.metadata and obj.metadata.annotations then
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused"] = nil
|
||||
obj.metadata.annotations["autoscaling.keda.sh/paused-replicas"] = nil
|
||||
end
|
||||
|
||||
return obj
|
||||
14
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-pause.yaml
vendored
Normal file
14
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-pause.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledObject
|
||||
metadata:
|
||||
name: test-scaledobject
|
||||
annotations:
|
||||
autoscaling.keda.sh/paused: "true"
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
name: test-deployment
|
||||
triggers:
|
||||
- type: cpu
|
||||
metadata:
|
||||
type: Utilization
|
||||
value: "50"
|
||||
14
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-paused-replicas.yaml
vendored
Normal file
14
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-paused-replicas.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledObject
|
||||
metadata:
|
||||
name: test-scaledobject
|
||||
annotations:
|
||||
autoscaling.keda.sh/paused-replicas: "6"
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
name: test-deployment
|
||||
triggers:
|
||||
- type: cpu
|
||||
metadata:
|
||||
type: Utilization
|
||||
value: "50"
|
||||
12
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-resume.yaml
vendored
Normal file
12
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject-resume.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledObject
|
||||
metadata:
|
||||
name: test-scaledobject
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
name: test-deployment
|
||||
triggers:
|
||||
- type: cpu
|
||||
metadata:
|
||||
type: Utilization
|
||||
value: "50"
|
||||
12
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject.yaml
vendored
Normal file
12
resource_customizations/keda.sh/ScaledObject/actions/testdata/scaledobject.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledObject
|
||||
metadata:
|
||||
name: test-scaledobject
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
name: test-deployment
|
||||
triggers:
|
||||
- type: cpu
|
||||
metadata:
|
||||
type: Utilization
|
||||
value: "50"
|
||||
Reference in New Issue
Block a user