13.6.2. 放置示例
您需要通过在该命名空间中创建一个 ManagedClusterSetBinding
来最少将一个 ManagedClusterSet
绑定到一个命名空间。注:您需要在 managedclustersets/bind
的虚拟子资源上对 CREATE
进行基于角色的访问权限。请参见以下示例:
您可以使用
labelSelector
选择ManagedClusters
。请参阅以下示例,其中labelSelector
仅与带有标签vendor: OpenShift
的集群匹配:apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement1 namespace: ns1 spec: predicates: - requiredClusterSelector: labelSelector: matchLabels: vendor: OpenShift
您可以使用
claimSelector
选择ManagedClusters
。请参阅以下示例,其中claimSelector
仅与带有us-west-1
的region.open-cluster-management.io
的集群匹配:apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement2 namespace: ns1 spec: predicates: - requiredClusterSelector: claimSelector: matchExpressions: - key: region.open-cluster-management.io operator: In values: - us-west-1
您可以从特定的
clusterSets
中选择ManagedClusters
。请参阅以下示例,其中claimSelector
仅与clusterSets:
clusterset1
clusterset2
匹配:apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement3 namespace: ns1 spec: clusterSets: - clusterset1 - clusterset2 predicates: - requiredClusterSelector: claimSelector: matchExpressions: - key: region.open-cluster-management.io operator: In values: - us-west-1
选择所需的
ManagedClusters
数量。请参阅以下示例,其中numberOfClusters
为3
:apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement4 namespace: ns1 spec: numberOfClusters: 3 predicates: - requiredClusterSelector: labelSelector: matchLabels: vendor: OpenShift claimSelector: matchExpressions: - key: region.open-cluster-management.io operator: In values: - us-west-1