1.14.5.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
选择具有最大可分配内存的集群。
注: 与 Kubernetes Node Allocatable 类似,"可分配"这里定义为每个集群中 pod 可用的计算资源数量。
apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement6 namespace: ns1 spec: numberOfClusters: 1 prioritizerPolicy: configurations: - name: ResourceAllocatableMemory
选择具有最大可分配 CPU 和内存的集群,并区分资源更改。
apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement7 namespace: ns1 spec: numberOfClusters: 2 prioritizerPolicy: configurations: - name: ResourceAllocatableCPU weight: 2 - name: ResourceAllocatableMemory weight: 2
选择具有最大可分配内存的集群,并固定放置决定。
apiVersion: cluster.open-cluster-management.io/v1alpha1 kind: Placement metadata: name: placement8 namespace: ns1 spec: numberOfClusters: 4 prioritizerPolicy: mode: Exact configurations: - name: ResourceAllocatableMemory - name: Steady weight: 3