Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/plumbing/argocd-super-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ $.Values.global.vpArgoNamespace }}-cluster-admin-rolebinding
{{- if ne ($.Values.global.options.clusterRoleBindingSyncWave | toString) "0" }}
annotations:
argocd.argoproj.io/sync-wave: {{ $.Values.global.options.clusterRoleBindingSyncWave | quote }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -29,8 +31,10 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ $.Values.global.pattern }}-{{ .Values.clusterGroup.name }}-cluster-admin-rolebinding
{{- if ne ($.Values.global.options.clusterRoleBindingSyncWave | toString) "0" }}
annotations:
argocd.argoproj.io/sync-wave: {{ $.Values.global.options.clusterRoleBindingSyncWave | quote }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
39 changes: 27 additions & 12 deletions tests/argocd_super_role_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ tests:
path: subjects[1].namespace
value: mypattern-edge

- it: should set default sync-wave annotation to -1 on first ClusterRoleBinding
- it: should not set sync-wave annotation by default on first ClusterRoleBinding
set:
global:
pattern: common
Expand All @@ -106,18 +106,35 @@ tests:
name: hub
asserts:
- documentIndex: 0
equal:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
value: "-1"
isNull:
path: metadata.annotations

- it: should set default sync-wave annotation to -1 on second ClusterRoleBinding
- it: should not set sync-wave annotation by default on second ClusterRoleBinding
set:
global:
pattern: common
vpArgoNamespace: openshift-gitops
clusterGroup:
name: hub
asserts:
- documentIndex: 1
isNull:
path: metadata.annotations

- it: should set sync-wave annotation when clusterRoleBindingSyncWave is non-zero
set:
global:
pattern: common
vpArgoNamespace: openshift-gitops
options:
clusterRoleBindingSyncWave: "-1"
clusterGroup:
name: hub
asserts:
- documentIndex: 0
equal:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
value: "-1"
- documentIndex: 1
equal:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
Expand All @@ -142,7 +159,7 @@ tests:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
value: "-2"

- it: should allow setting sync-wave to zero
- it: should not set sync-wave annotation when explicitly set to zero
set:
global:
pattern: common
Expand All @@ -153,10 +170,8 @@ tests:
name: hub
asserts:
- documentIndex: 0
equal:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
value: "0"
isNull:
path: metadata.annotations
- documentIndex: 1
equal:
path: metadata.annotations["argocd.argoproj.io/sync-wave"]
value: "0"
isNull:
path: metadata.annotations
4 changes: 2 additions & 2 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@
},
"clusterRoleBindingSyncWave": {
"type": "string",
"description": "Sync-wave annotation value for the cluster-admin ClusterRoleBinding. Defaults to -1 so it is applied before wave-0 resources",
"default": "-1"
"description": "Sync-wave annotation value for the cluster-admin ClusterRoleBinding. When set to 0 (default) no annotation is added. Set to -1 to apply before wave-0 resources",
"default": "0"
}
},
"required": [
Expand Down
4 changes: 2 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ global:
syncPolicy: Automatic
installPlanApproval: Automatic
applicationRetryLimit: 20
# -- Sync-wave annotation for the cluster-admin ClusterRoleBinding. Set to "-1" so it is applied before wave-0 resources that need cluster-admin privileges
clusterRoleBindingSyncWave: "-1"
# -- Sync-wave annotation for the cluster-admin ClusterRoleBinding. When set to "0" (default) no sync-wave annotation is added. Set to "-1" to apply before wave-0 resources
clusterRoleBindingSyncWave: "0"

# Note that sometimes changing helm values might require a hard refresh (https://github.com/helm/helm/issues/3486)
clusterGroup:
Expand Down