Skip to content

Commit af93830

Browse files
committed
update disable-autosync to support external clusters
1 parent 03e3943 commit af93830

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

workflows/argo-events/workflowtemplates/disable-autosync.yaml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
apiVersion: argoproj.io/v1alpha1
22
kind: WorkflowTemplate
33
metadata:
4-
name: patch-application-automated-sync
4+
name: patch-application-automated-sync-external
5+
annotations:
6+
workflows.argoproj.io/title: Temporarily disable autosync on an Application in production environment
7+
workflows.argoproj.io/description: |
8+
Defined in `workflows/argo-events/workflowtemplates/disable-autosync.yaml`
59
spec:
610
entrypoint: main
711
arguments:
812
parameters:
913
- name: name
10-
description: "Name of the Application resource to modify."
14+
description: "Name of the Application resource to modify in the external cluster."
1115
- name: duration
1216
description: "Duration in minutes to keep automated sync disabled."
1317
value: "30"
18+
- name: kubeconfig-secret-name
19+
description: "Name of the K8s Secret containing the kubeconfig for the external cluster."
20+
- name: kubeconfig-secret-key
21+
description: "Key within the K8s Secret that holds the kubeconfig data."
1422

1523
templates:
1624
- name: main
@@ -24,6 +32,10 @@ spec:
2432
value: "{{workflow.parameters.name}}"
2533
- name: automated-value
2634
value: "false"
35+
- name: kubeconfig-secret-name
36+
value: "{{workflow.parameters.kubeconfig-secret-name}}"
37+
- name: kubeconfig-secret-key
38+
value: "{{workflow.parameters.kubeconfig-secret-key}}"
2739

2840
- name: wait-for-duration
2941
template: wait
@@ -42,18 +54,30 @@ spec:
4254
value: "{{workflow.parameters.name}}"
4355
- name: automated-value
4456
value: "true"
57+
- name: kubeconfig-secret-name
58+
value: "{{workflow.parameters.kubeconfig-secret-name}}"
59+
- name: kubeconfig-secret-key
60+
value: "{{workflow.parameters.kubeconfig-secret-key}}"
4561

4662
- name: patch-automated-sync
4763
inputs:
4864
parameters:
4965
- name: resource-name
5066
- name: automated-value
67+
- name: kubeconfig-secret-name
68+
- name: kubeconfig-secret-key
5169
resource:
5270
action: patch
71+
# The kubeconfig from the secret will dictate the target cluster.
72+
# The group, version, kind, and name refer to the resource on that external cluster.
5373
group: argoproj.io
5474
version: v1alpha1
5575
kind: Application
5676
name: "{{inputs.parameters.resource-name}}"
77+
# Namespace of the Application on the external cluster.
78+
# If not specified, it will use the default namespace from the kubeconfig,
79+
# or you can explicitly set it here if needed.
80+
# namespace: "your-app-namespace-on-external-cluster"
5781
patch: |
5882
[
5983
{
@@ -62,9 +86,15 @@ spec:
6286
"value": {{inputs.parameters.automated-value}}
6387
}
6488
]
89+
# Instruct Argo to use the kubeconfig from the specified secret
90+
kubeconfig:
91+
secretKeyRef:
92+
name: "{{inputs.parameters.kubeconfig-secret-name}}"
93+
key: "{{inputs.parameters.kubeconfig-secret-key}}"
6594
- name: wait
6695
inputs:
6796
parameters:
6897
- name: duration-minutes
6998
suspend:
70-
duration: "{{=sprig.int(inputs.parameters.duration-minutes) * 60}}" # Convert minutes to seconds string for duration
99+
# Here we convert minutes to seconds and ensure it's a string.
100+
duration: "{{=sprig.int(inputs.parameters.duration-minutes) * 60}}"

0 commit comments

Comments
 (0)