forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add custom resource actions for flux resources (argoproj#18922)
* 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
Showing
107 changed files
with
1,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/action_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
18 changes: 18 additions & 0 deletions
18
resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/discovery.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
7 changes: 7 additions & 0 deletions
7
resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/reconcile/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
5 changes: 5 additions & 0 deletions
5
resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/resume/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/suspend/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
obj.spec.suspend = true | ||
|
||
return obj |
33 changes: 33 additions & 0 deletions
33
...stomizations/helm.toolkit.fluxcd.io/HelmRelease/actions/testdata/initial_helmrelease.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
35 changes: 35 additions & 0 deletions
35
...mizations/helm.toolkit.fluxcd.io/HelmRelease/actions/testdata/reconciled_helmrelease.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
34 changes: 34 additions & 0 deletions
34
...stomizations/helm.toolkit.fluxcd.io/HelmRelease/actions/testdata/resumed_helmrelease.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
34 changes: 34 additions & 0 deletions
34
...omizations/helm.toolkit.fluxcd.io/HelmRelease/actions/testdata/suspended_helmrelease.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
35 changes: 35 additions & 0 deletions
35
resource_customizations/image.toolkit.fluxcd.io/ImageRepository/actions/action_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
18 changes: 18 additions & 0 deletions
18
resource_customizations/image.toolkit.fluxcd.io/ImageRepository/actions/discovery.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
7 changes: 7 additions & 0 deletions
7
resource_customizations/image.toolkit.fluxcd.io/ImageRepository/actions/reconcile/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
5 changes: 5 additions & 0 deletions
5
resource_customizations/image.toolkit.fluxcd.io/ImageRepository/actions/resume/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
resource_customizations/image.toolkit.fluxcd.io/ImageRepository/actions/suspend/action.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
obj.spec.suspend = true | ||
|
||
return obj |
9 changes: 9 additions & 0 deletions
9
...ons/image.toolkit.fluxcd.io/ImageRepository/actions/testdata/initial_imagerepository.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
11 changes: 11 additions & 0 deletions
11
.../image.toolkit.fluxcd.io/ImageRepository/actions/testdata/reconciled_imagerepository.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
10 changes: 10 additions & 0 deletions
10
...ons/image.toolkit.fluxcd.io/ImageRepository/actions/testdata/resumed_imagerepository.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
10 changes: 10 additions & 0 deletions
10
...s/image.toolkit.fluxcd.io/ImageRepository/actions/testdata/suspended_imagerepository.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
35 changes: 35 additions & 0 deletions
35
...rce_customizations/image.toolkit.fluxcd.io/ImageUpdateAutomation/actions/action_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.