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
76 changes: 43 additions & 33 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,47 +79,57 @@ if this chart gets DeleteSpokeChildApps, it will set deletePattern to DeleteChil
{{- $isMap := kindIs "map" $rawLabels -}}
{{- $hasAny := and $rawLabels (gt (len $rawLabels) 0) -}}
{{- if $cs -}}
clusterSelector: {{ $cs | toPrettyJson }}
predicates:
- requiredClusterSelector:
labelSelector: {{ $cs | toPrettyJson | nindent 8 }}
{{- else if not $hasAny -}}
clusterSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
clusterGroup: {{ $g.name }}
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
clusterGroup: {{ $g.name }}
{{- else if $isSlice -}}
clusterSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
{{- range $rawLabels }}
{{ .name }}: {{ .value }}
{{ .name }}: {{ .value }}
{{- end }}
{{- else if $isMap -}}
clusterSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
{{- range $k, $v := $rawLabels }}
{{ $k }}: {{ $v }}
{{ $k }}: {{ $v }}
{{- end }}
{{- else -}} {{- /* Fallback: unknown acmlabels shape then default to group */}}
clusterSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
clusterGroup: {{ $g.name }}
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: local-cluster
operator: NotIn
values:
- 'true'
matchLabels:
clusterGroup: {{ $g.name }}
{{- end -}}
{{- end -}} {{- /*acm.app.clusterSelector */}}

Expand Down
39 changes: 15 additions & 24 deletions templates/policies/acm-hub-ca-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: hub-argo-ca-{{ .name }}-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: hub-argo-ca-{{ .name }}-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: hub-argo-ca-{{ .name }}-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down Expand Up @@ -127,24 +124,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: {{ .name }}-acm-hub-ca-policy-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: {{ .name }}-acm-hub-ca-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .name }}-acm-hub-ca-policy-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down Expand Up @@ -193,24 +187,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: {{ .name }}-hub-argo-ca-gitops-policy-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: {{ .name }}-hub-argo-ca-gitops-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .name }}-hub-argo-ca-gitops-policy-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down
13 changes: 5 additions & 8 deletions templates/policies/application-policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: {{ .name }}-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: {{ .name }}-clustergroup-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .name }}-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down
12 changes: 12 additions & 0 deletions templates/policies/managedclustersetbinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ManagedClusterSetBinding is required for the Placement API to schedule
# clusters from the default ManagedClusterSet in this namespace.
{{- if .Values.clusterGroup.managedClusterGroups }}
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
name: default
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterSet: default
{{- end }}
28 changes: 11 additions & 17 deletions templates/policies/ocp-gitops-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
env:
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
value: "*"
- complianceType: mustonlyhave
- complianceType: musthave
objectDefinition:
kind: ConfigMap
apiVersion: v1
Expand Down Expand Up @@ -78,24 +78,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: {{ .name }}-gitops-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: {{ .name }}-gitops-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .name }}-gitops-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down Expand Up @@ -310,24 +307,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: {{ .name }}-gitops-placement-argocd
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: {{ .name }}-gitops-policy-argocd
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .name }}-gitops-placement-argocd
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down
38 changes: 17 additions & 21 deletions templates/policies/private-repo-policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,21 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: private-{{ .name }}-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: private-{{ .name }}-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: private-{{ .name }}-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
{{- include "acm.app.clusterSelector" (dict
{{- include "acm.app.clusterSelector" (dict
"clusterSelector" .clusterSelector
"group" $group
) | nindent 2 }}
Expand Down Expand Up @@ -129,29 +126,28 @@ metadata:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
placementRef:
name: vp-private-hub-placement
kind: PlacementRule
apiGroup: apps.open-cluster-management.io
kind: Placement
apiGroup: cluster.open-cluster-management.io
subjects:
- name: vp-private-hub-policy
kind: Policy
apiGroup: policy.open-cluster-management.io
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: vp-private-hub-placement
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
clusterConditions:
- status: 'True'
type: ManagedClusterConditionAvailable
clusterSelector:
matchExpressions:
- key: local-cluster
operator: In
values:
- 'true'
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: local-cluster
operator: In
values:
- 'true'
---
{{ end }}{{- /* if ishubcluster */}}
{{- end }}{{- /* if $.Values.global.privateRepo */}}
Loading
Loading