Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local-cluster label #498

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
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ spec:
{{- $volsync_pvcs := "hub-pvc-backup-pvcs" }}
{{- $volsync_restore_cond := eq ( lookup "v1" "ConfigMap" $ns $volsync_pvcs ).metadata.name $volsync_pvcs }}
{{- $has_local_cluster_ns := eq (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "local-cluster").metadata.name "local-cluster" }}
{{- $is_hub := "is-hub" }}
{{- $local_cls := "local-cluster" }}
{{- $local_cls_name := index (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" "local-cluster=true") "items" 0 "metadata" "name" }}

{{- /* Create the volsync addon - if BackupSchedule exists and there are PVCs with volsync label */ -}}
{{ if or (and $pv_claim_cond $volsync_backup_cond) $volsync_restore_cond }}
{{- range $hub_managed_cls := (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" $is_hub).items }}
{{ if not ( eq $hub_managed_cls.metadata.name $local_cls ) }}
{{- range $hub_managed_cls := (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" "is-hub").items }}
{{ if not ( eq $hub_managed_cls.metadata.name $local_cls_name ) }}
- complianceType: musthave
objectDefinition:
apiVersion: addon.open-cluster-management.io/v1alpha1
Expand All @@ -147,14 +146,14 @@ spec:
type: Available
{{- end }}
{{- end }}
{{ if $has_local_cluster_ns }}
{{ if $local_cls_name }}
- complianceType: musthave
objectDefinition:
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ManagedClusterAddOn
metadata:
name: volsync
namespace: {{ $local_cls }}
namespace: {{ $local_cls_name }}
labels:
cluster.open-cluster-management.io/backup: volsync
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: name
- key: local-cluster
operator: In
values:
- local-cluster
- 'true'
- requiredClusterSelector:
labelSelector:
matchExpressions:
Expand Down
5 changes: 3 additions & 2 deletions policygenerator/kustomize/policyGenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ policyDefaults:
namespace: policies
placement:
name: demo-placement-rule
clusterSelectors:
name: local-cluster
labelSelector:
matchExpressions:
- {key: "local-cluster", operator: In, values: ["true"]}
remediationAction: inform
severity: medium
policies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ policySets:
placement:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
- description: The Advanced Cluster Security components distributed to all OpenShift
managed clusters to secure the clusters.
name: acs-sensor-clusters
placement:
labelSelector:
matchExpressions:
- {key: vendor, operator: In, values: ["OpenShift"]}
- {key: name, operator: NotIn, values: ["local-cluster"]}
- {key: "local-cluster", operator: NotIn, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ policyDefaults:
placement:
labelSelector:
matchLabels:
name: local-cluster
local-cluster: 'true'

policies:
- name: acm-policygenerator-downloader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ spec:
labelSelector:
matchExpressions:
- {key: vendor, operator: In, values: ["OpenShift"]}
- {key: name, operator: NotIn, values: ["local-cluster"]}
- {key: "local-cluster", operator: NotIn, values: ["true"]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
- {key: "local-cluster", operator: In, values: ["true"]}