Skip to content

Commit c9911bc

Browse files
authored
Merge pull request #53 from mbaldessari/freshup
Update to newer non-deprecated placement api
2 parents ff2c144 + 91922a4 commit c9911bc

8 files changed

Lines changed: 642 additions & 108 deletions

templates/_helpers.tpl

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,57 @@ if this chart gets DeleteSpokeChildApps, it will set deletePattern to DeleteChil
7979
{{- $isMap := kindIs "map" $rawLabels -}}
8080
{{- $hasAny := and $rawLabels (gt (len $rawLabels) 0) -}}
8181
{{- if $cs -}}
82-
clusterSelector: {{ $cs | toPrettyJson }}
82+
predicates:
83+
- requiredClusterSelector:
84+
labelSelector: {{ $cs | toPrettyJson | nindent 8 }}
8385
{{- else if not $hasAny -}}
84-
clusterSelector:
85-
matchExpressions:
86-
- key: local-cluster
87-
operator: NotIn
88-
values:
89-
- 'true'
90-
matchLabels:
91-
clusterGroup: {{ $g.name }}
86+
predicates:
87+
- requiredClusterSelector:
88+
labelSelector:
89+
matchExpressions:
90+
- key: local-cluster
91+
operator: NotIn
92+
values:
93+
- 'true'
94+
matchLabels:
95+
clusterGroup: {{ $g.name }}
9296
{{- else if $isSlice -}}
93-
clusterSelector:
94-
matchExpressions:
95-
- key: local-cluster
96-
operator: NotIn
97-
values:
98-
- 'true'
99-
matchLabels:
97+
predicates:
98+
- requiredClusterSelector:
99+
labelSelector:
100+
matchExpressions:
101+
- key: local-cluster
102+
operator: NotIn
103+
values:
104+
- 'true'
105+
matchLabels:
100106
{{- range $rawLabels }}
101-
{{ .name }}: {{ .value }}
107+
{{ .name }}: {{ .value }}
102108
{{- end }}
103109
{{- else if $isMap -}}
104-
clusterSelector:
105-
matchExpressions:
106-
- key: local-cluster
107-
operator: NotIn
108-
values:
109-
- 'true'
110-
matchLabels:
110+
predicates:
111+
- requiredClusterSelector:
112+
labelSelector:
113+
matchExpressions:
114+
- key: local-cluster
115+
operator: NotIn
116+
values:
117+
- 'true'
118+
matchLabels:
111119
{{- range $k, $v := $rawLabels }}
112-
{{ $k }}: {{ $v }}
120+
{{ $k }}: {{ $v }}
113121
{{- end }}
114122
{{- else -}} {{- /* Fallback: unknown acmlabels shape then default to group */}}
115-
clusterSelector:
116-
matchExpressions:
117-
- key: local-cluster
118-
operator: NotIn
119-
values:
120-
- 'true'
121-
matchLabels:
122-
clusterGroup: {{ $g.name }}
123+
predicates:
124+
- requiredClusterSelector:
125+
labelSelector:
126+
matchExpressions:
127+
- key: local-cluster
128+
operator: NotIn
129+
values:
130+
- 'true'
131+
matchLabels:
132+
clusterGroup: {{ $g.name }}
123133
{{- end -}}
124134
{{- end -}} {{- /*acm.app.clusterSelector */}}
125135

templates/policies/acm-hub-ca-policy.yaml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,21 @@ metadata:
4747
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
4848
placementRef:
4949
name: hub-argo-ca-{{ .name }}-placement
50-
kind: PlacementRule
51-
apiGroup: apps.open-cluster-management.io
50+
kind: Placement
51+
apiGroup: cluster.open-cluster-management.io
5252
subjects:
5353
- name: hub-argo-ca-{{ .name }}-policy
5454
kind: Policy
5555
apiGroup: policy.open-cluster-management.io
5656
---
57-
apiVersion: apps.open-cluster-management.io/v1
58-
kind: PlacementRule
57+
apiVersion: cluster.open-cluster-management.io/v1beta1
58+
kind: Placement
5959
metadata:
6060
name: hub-argo-ca-{{ .name }}-placement
6161
annotations:
6262
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
6363
spec:
64-
clusterConditions:
65-
- status: 'True'
66-
type: ManagedClusterConditionAvailable
67-
{{- include "acm.app.clusterSelector" (dict
64+
{{- include "acm.app.clusterSelector" (dict
6865
"clusterSelector" .clusterSelector
6966
"group" $group
7067
) | nindent 2 }}
@@ -127,24 +124,21 @@ metadata:
127124
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
128125
placementRef:
129126
name: {{ .name }}-acm-hub-ca-policy-placement
130-
kind: PlacementRule
131-
apiGroup: apps.open-cluster-management.io
127+
kind: Placement
128+
apiGroup: cluster.open-cluster-management.io
132129
subjects:
133130
- name: {{ .name }}-acm-hub-ca-policy
134131
kind: Policy
135132
apiGroup: policy.open-cluster-management.io
136133
---
137-
apiVersion: apps.open-cluster-management.io/v1
138-
kind: PlacementRule
134+
apiVersion: cluster.open-cluster-management.io/v1beta1
135+
kind: Placement
139136
metadata:
140137
name: {{ .name }}-acm-hub-ca-policy-placement
141138
annotations:
142139
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
143140
spec:
144-
clusterConditions:
145-
- status: 'True'
146-
type: ManagedClusterConditionAvailable
147-
{{- include "acm.app.clusterSelector" (dict
141+
{{- include "acm.app.clusterSelector" (dict
148142
"clusterSelector" .clusterSelector
149143
"group" $group
150144
) | nindent 2 }}
@@ -193,24 +187,21 @@ metadata:
193187
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
194188
placementRef:
195189
name: {{ .name }}-hub-argo-ca-gitops-policy-placement
196-
kind: PlacementRule
197-
apiGroup: apps.open-cluster-management.io
190+
kind: Placement
191+
apiGroup: cluster.open-cluster-management.io
198192
subjects:
199193
- name: {{ .name }}-hub-argo-ca-gitops-policy
200194
kind: Policy
201195
apiGroup: policy.open-cluster-management.io
202196
---
203-
apiVersion: apps.open-cluster-management.io/v1
204-
kind: PlacementRule
197+
apiVersion: cluster.open-cluster-management.io/v1beta1
198+
kind: Placement
205199
metadata:
206200
name: {{ .name }}-hub-argo-ca-gitops-policy-placement
207201
annotations:
208202
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
209203
spec:
210-
clusterConditions:
211-
- status: 'True'
212-
type: ManagedClusterConditionAvailable
213-
{{- include "acm.app.clusterSelector" (dict
204+
{{- include "acm.app.clusterSelector" (dict
214205
"clusterSelector" .clusterSelector
215206
"group" $group
216207
) | nindent 2 }}

templates/policies/application-policies.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,21 @@ metadata:
177177
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
178178
placementRef:
179179
name: {{ .name }}-placement
180-
kind: PlacementRule
181-
apiGroup: apps.open-cluster-management.io
180+
kind: Placement
181+
apiGroup: cluster.open-cluster-management.io
182182
subjects:
183183
- name: {{ .name }}-clustergroup-policy
184184
kind: Policy
185185
apiGroup: policy.open-cluster-management.io
186186
---
187-
apiVersion: apps.open-cluster-management.io/v1
188-
kind: PlacementRule
187+
apiVersion: cluster.open-cluster-management.io/v1beta1
188+
kind: Placement
189189
metadata:
190190
name: {{ .name }}-placement
191191
annotations:
192192
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
193193
spec:
194-
clusterConditions:
195-
- status: 'True'
196-
type: ManagedClusterConditionAvailable
197-
{{- include "acm.app.clusterSelector" (dict
194+
{{- include "acm.app.clusterSelector" (dict
198195
"clusterSelector" .clusterSelector
199196
"group" $group
200197
) | nindent 2 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ManagedClusterSetBinding is required for the Placement API to schedule
2+
# clusters from the default ManagedClusterSet in this namespace.
3+
{{- if .Values.clusterGroup.managedClusterGroups }}
4+
apiVersion: cluster.open-cluster-management.io/v1beta2
5+
kind: ManagedClusterSetBinding
6+
metadata:
7+
name: default
8+
annotations:
9+
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
10+
spec:
11+
clusterSet: default
12+
{{- end }}

templates/policies/ocp-gitops-policy.yaml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ spec:
4444
env:
4545
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
4646
value: "*"
47-
- complianceType: mustonlyhave
47+
- complianceType: musthave
4848
objectDefinition:
4949
kind: ConfigMap
5050
apiVersion: v1
@@ -78,24 +78,21 @@ metadata:
7878
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
7979
placementRef:
8080
name: {{ .name }}-gitops-placement
81-
kind: PlacementRule
82-
apiGroup: apps.open-cluster-management.io
81+
kind: Placement
82+
apiGroup: cluster.open-cluster-management.io
8383
subjects:
8484
- name: {{ .name }}-gitops-policy
8585
kind: Policy
8686
apiGroup: policy.open-cluster-management.io
8787
---
88-
apiVersion: apps.open-cluster-management.io/v1
89-
kind: PlacementRule
88+
apiVersion: cluster.open-cluster-management.io/v1beta1
89+
kind: Placement
9090
metadata:
9191
name: {{ .name }}-gitops-placement
9292
annotations:
9393
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
9494
spec:
95-
clusterConditions:
96-
- status: 'True'
97-
type: ManagedClusterConditionAvailable
98-
{{- include "acm.app.clusterSelector" (dict
95+
{{- include "acm.app.clusterSelector" (dict
9996
"clusterSelector" .clusterSelector
10097
"group" $group
10198
) | nindent 2 }}
@@ -310,24 +307,21 @@ metadata:
310307
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
311308
placementRef:
312309
name: {{ .name }}-gitops-placement-argocd
313-
kind: PlacementRule
314-
apiGroup: apps.open-cluster-management.io
310+
kind: Placement
311+
apiGroup: cluster.open-cluster-management.io
315312
subjects:
316313
- name: {{ .name }}-gitops-policy-argocd
317314
kind: Policy
318315
apiGroup: policy.open-cluster-management.io
319316
---
320-
apiVersion: apps.open-cluster-management.io/v1
321-
kind: PlacementRule
317+
apiVersion: cluster.open-cluster-management.io/v1beta1
318+
kind: Placement
322319
metadata:
323320
name: {{ .name }}-gitops-placement-argocd
324321
annotations:
325322
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
326323
spec:
327-
clusterConditions:
328-
- status: 'True'
329-
type: ManagedClusterConditionAvailable
330-
{{- include "acm.app.clusterSelector" (dict
324+
{{- include "acm.app.clusterSelector" (dict
331325
"clusterSelector" .clusterSelector
332326
"group" $group
333327
) | nindent 2 }}

templates/policies/private-repo-policies.yaml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,21 @@ metadata:
6262
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
6363
placementRef:
6464
name: private-{{ .name }}-placement
65-
kind: PlacementRule
66-
apiGroup: apps.open-cluster-management.io
65+
kind: Placement
66+
apiGroup: cluster.open-cluster-management.io
6767
subjects:
6868
- name: private-{{ .name }}-policy
6969
kind: Policy
7070
apiGroup: policy.open-cluster-management.io
7171
---
72-
apiVersion: apps.open-cluster-management.io/v1
73-
kind: PlacementRule
72+
apiVersion: cluster.open-cluster-management.io/v1beta1
73+
kind: Placement
7474
metadata:
7575
name: private-{{ .name }}-placement
7676
annotations:
7777
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
7878
spec:
79-
clusterConditions:
80-
- status: 'True'
81-
type: ManagedClusterConditionAvailable
82-
{{- include "acm.app.clusterSelector" (dict
79+
{{- include "acm.app.clusterSelector" (dict
8380
"clusterSelector" .clusterSelector
8481
"group" $group
8582
) | nindent 2 }}
@@ -129,29 +126,28 @@ metadata:
129126
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
130127
placementRef:
131128
name: vp-private-hub-placement
132-
kind: PlacementRule
133-
apiGroup: apps.open-cluster-management.io
129+
kind: Placement
130+
apiGroup: cluster.open-cluster-management.io
134131
subjects:
135132
- name: vp-private-hub-policy
136133
kind: Policy
137134
apiGroup: policy.open-cluster-management.io
138135
---
139-
apiVersion: apps.open-cluster-management.io/v1
140-
kind: PlacementRule
136+
apiVersion: cluster.open-cluster-management.io/v1beta1
137+
kind: Placement
141138
metadata:
142139
name: vp-private-hub-placement
143140
annotations:
144141
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
145142
spec:
146-
clusterConditions:
147-
- status: 'True'
148-
type: ManagedClusterConditionAvailable
149-
clusterSelector:
150-
matchExpressions:
151-
- key: local-cluster
152-
operator: In
153-
values:
154-
- 'true'
143+
predicates:
144+
- requiredClusterSelector:
145+
labelSelector:
146+
matchExpressions:
147+
- key: local-cluster
148+
operator: In
149+
values:
150+
- 'true'
155151
---
156152
{{ end }}{{- /* if ishubcluster */}}
157153
{{- end }}{{- /* if $.Values.global.privateRepo */}}

0 commit comments

Comments
 (0)