Skip to content

Commit

Permalink
feat: Add custom resource actions for flux resources (#18922)
Browse files Browse the repository at this point in the history
* feat: Add custom resource actions for flux resources
Signed-off-by: Adrian Berger <adrian.berger@bedag.ch>

* chore: Add upgrade docs, change annotation text

Signed-off-by: Adrian Berger <adrian.berger@bedag.ch>

---------

Signed-off-by: Adrian Berger <adrian.berger@bedag.ch>
  • Loading branch information
adberger committed Jul 15, 2024
1 parent dfaacef commit 7fdddbe
Show file tree
Hide file tree
Showing 107 changed files with 1,507 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/operator-manual/upgrading/2.12-2.13.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# v2.12 to 2.13

## Custom Resource Actions for Flux Resources

[`Custom Resource Actions`](../resource_actions.md#Custom-Resource-Actions) have been added for Flux Resources.
The following actions are now available:

| Custom Resource | Supported Actions |
|-----------------------|----------------------------------|
| HelmRelease | `Suspend`, `Resume`, `Reconcile` |
| ImageRepository | `Suspend`, `Resume`, `Reconcile` |
| ImageUpdateAutomation | `Suspend`, `Resume`, `Reconcile` |
| Kustomziation | `Suspend`, `Resume`, `Reconcile` |
| Alert | `Suspend`, `Resume` |
| Provider | `Suspend`, `Resume` |
| Receiver | `Suspend`, `Resume`, `Reconcile` |
| Bucket | `Suspend`, `Resume`, `Reconcile` |
| GitRepository | `Suspend`, `Resume`, `Reconcile` |
| HelmChart | `Suspend`, `Resume`, `Reconcile` |
| HelmRepository | `Suspend`, `Resume`, `Reconcile` |
| OCIRepository | `Suspend`, `Resume`, `Reconcile` |

If you want to use these actions do not forget to update the permissions (RBAC) for your Argo CD instance.
1 change: 1 addition & 0 deletions docs/operator-manual/upgrading/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/<v

<hr/>

* [v2.12 to v2.13](./2.12-2.13.md)
* [v2.11 to v2.12](./2.11-2.12.md)
* [v2.10 to v2.11](./2.10-2.11.md)
* [v2.9 to v2.10](./2.9-2.10.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
discoveryTests:
- inputPath: testdata/initial_helmrelease.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
- inputPath: testdata/suspended_helmrelease.yaml
result:
- name: reconcile
disabled: true
- name: suspend
disabled: true
- name: resume
disabled: false
- inputPath: testdata/resumed_helmrelease.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
actionTests:
- action: reconcile
inputPath: testdata/initial_helmrelease.yaml
expectedOutputPath: testdata/reconciled_helmrelease.yaml
- action: suspend
inputPath: testdata/initial_helmrelease.yaml
expectedOutputPath: testdata/suspended_helmrelease.yaml
- action: resume
inputPath: testdata/suspended_helmrelease.yaml
expectedOutputPath: testdata/resumed_helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local actions = {}

actions["reconcile"] = {["disabled"] = true}
actions["suspend"] = {["disabled"] = true}
actions["resume"] = {["disabled"] = true}

local suspend = false
if obj.spec.suspend ~= nil then
suspend = obj.spec.suspend
end
if suspend then
actions["resume"]["disabled"] = false
else
actions["reconcile"]["disabled"] = false
actions["suspend"]["disabled"] = false
end

return actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local os = require("os")
if obj.metadata.annotations == nil then
obj.metadata.annotations = {}
end
obj.metadata.annotations["reconcile.fluxcd.io/requestedAt"] = "By Argo CD at: " .. os.date("!%Y-%m-%dT%X")

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if obj.spec.suspend ~= nil and obj.spec.suspend then
obj.spec.suspend = false
end

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
obj.spec.suspend = true

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: default
spec:
interval: 10m
timeout: 5m
chart:
spec:
chart: podinfo
version: '6.5.*'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 5m
releaseName: podinfo
install:
remediation:
retries: 3
upgrade:
remediation:
retries: 3
test:
enable: true
driftDetection:
mode: enabled
ignore:
- paths: ["/spec/replicas"]
target:
kind: Deployment
values:
replicaCount: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: default
annotations:
reconcile.fluxcd.io/requestedAt: 'By Argo CD at: 0001-01-01T00:00:00'
spec:
interval: 10m
timeout: 5m
chart:
spec:
chart: podinfo
version: '6.5.*'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 5m
releaseName: podinfo
install:
remediation:
retries: 3
upgrade:
remediation:
retries: 3
test:
enable: true
driftDetection:
mode: enabled
ignore:
- paths: ["/spec/replicas"]
target:
kind: Deployment
values:
replicaCount: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: default
spec:
interval: 10m
timeout: 5m
chart:
spec:
chart: podinfo
version: '6.5.*'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 5m
releaseName: podinfo
install:
remediation:
retries: 3
upgrade:
remediation:
retries: 3
test:
enable: true
suspend: false
driftDetection:
mode: enabled
ignore:
- paths: ["/spec/replicas"]
target:
kind: Deployment
values:
replicaCount: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: default
spec:
interval: 10m
timeout: 5m
chart:
spec:
chart: podinfo
version: '6.5.*'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 5m
releaseName: podinfo
install:
remediation:
retries: 3
upgrade:
remediation:
retries: 3
test:
enable: true
suspend: true
driftDetection:
mode: enabled
ignore:
- paths: ["/spec/replicas"]
target:
kind: Deployment
values:
replicaCount: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
discoveryTests:
- inputPath: testdata/initial_imagerepository.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
- inputPath: testdata/suspended_imagerepository.yaml
result:
- name: reconcile
disabled: true
- name: suspend
disabled: true
- name: resume
disabled: false
- inputPath: testdata/resumed_imagerepository.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
actionTests:
- action: reconcile
inputPath: testdata/initial_imagerepository.yaml
expectedOutputPath: testdata/reconciled_imagerepository.yaml
- action: suspend
inputPath: testdata/initial_imagerepository.yaml
expectedOutputPath: testdata/suspended_imagerepository.yaml
- action: resume
inputPath: testdata/suspended_imagerepository.yaml
expectedOutputPath: testdata/resumed_imagerepository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local actions = {}

actions["reconcile"] = {["disabled"] = true}
actions["suspend"] = {["disabled"] = true}
actions["resume"] = {["disabled"] = true}

local suspend = false
if obj.spec.suspend ~= nil then
suspend = obj.spec.suspend
end
if suspend then
actions["resume"]["disabled"] = false
else
actions["reconcile"]["disabled"] = false
actions["suspend"]["disabled"] = false
end

return actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local os = require("os")
if obj.metadata.annotations == nil then
obj.metadata.annotations = {}
end
obj.metadata.annotations["reconcile.fluxcd.io/requestedAt"] = "By Argo CD at: " .. os.date("!%Y-%m-%dT%X")

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if obj.spec.suspend ~= nil and obj.spec.suspend then
obj.spec.suspend = false
end

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
obj.spec.suspend = true

return obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: podinfo
namespace: default
spec:
image: stefanprodan/podinfo
interval: 1h
provider: generic
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: podinfo
namespace: default
annotations:
reconcile.fluxcd.io/requestedAt: 'By Argo CD at: 0001-01-01T00:00:00'
spec:
image: stefanprodan/podinfo
interval: 1h
provider: generic
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: podinfo
namespace: default
spec:
image: stefanprodan/podinfo
interval: 1h
provider: generic
suspend: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: podinfo
namespace: default
spec:
image: stefanprodan/podinfo
interval: 1h
provider: generic
suspend: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
discoveryTests:
- inputPath: testdata/initial_imageupdateautomation.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
- inputPath: testdata/suspended_imageupdateautomation.yaml
result:
- name: reconcile
disabled: true
- name: suspend
disabled: true
- name: resume
disabled: false
- inputPath: testdata/resumed_imageupdateautomation.yaml
result:
- name: reconcile
disabled: false
- name: suspend
disabled: false
- name: resume
disabled: true
actionTests:
- action: reconcile
inputPath: testdata/initial_imageupdateautomation.yaml
expectedOutputPath: testdata/reconciled_imageupdateautomation.yaml
- action: suspend
inputPath: testdata/initial_imageupdateautomation.yaml
expectedOutputPath: testdata/suspended_imageupdateautomation.yaml
- action: resume
inputPath: testdata/suspended_imageupdateautomation.yaml
expectedOutputPath: testdata/resumed_imageupdateautomation.yaml
Loading

0 comments on commit 7fdddbe

Please sign in to comment.