Kubernetes kubefed使用Cluster Selector
Using Cluster Selector
In addition to specifying an explicit list of clusters that a resource should be propagated to via the spec.placement.clusters
field of a federated resource, it is possible to use the spec.placement.clusterSelector
field to provide a label selector that determines a list of clusters at runtime.
If the goal is to select a subset of member clusters, make sure that the KubeFedCluster
binaries from pre-reqs [now covered by Helm installation] resources that are intended to be selected have the appropriate labels applied.
The following command is an example to label a KubeFedCluster
:
1 | kubectl label kubefedclusters -n kube-federation-system cluster1 foo=bar |
Please refer to Kubernetes label command for more information on how kubectl label
works.
The following sections detail how spec.placement.clusters
and spec.placement.clusterSelector
are used in determining the clusters that a federated resource should be propagated to.
Neither spec.placement.clusters
nor spec.placement.clusterSelector
is provided
1 2 | spec: placement: {} |
In this case, you can either set spec: {}
as above or remove spec
field from your placement policy. The resource will not be propagated to member clusters.
在这种情况下,可以如上所述设置spec:{},也可以从放置策略中删除spec字段。资源将不会传播到成员群集。
Both spec.placement.clusters
and spec.placement.clusterSelector
are provided
1 2 3 4 5 6 7 8 | spec: placement: clusters: - name: cluster2 - name: cluster1 clusterSelector: matchLabels: foo: bar |
For this case, spec.placement.clusterSelector
will be ignored as spec.placement.clusters
is provided. This ensures that the results of runtime scheduling have priority over manual definition of a cluster selector.
spec.placement.clusterSelector
will also be ignored if spec.placement.clusters
is provided but empty. In the following example, no clusters will be selected:
1 2 3 4 5 6 | spec: placement: clusters: [] clusterSelector: matchLabels: foo: bar |
只要提供了spec.placement.clusters字段(即使其值为空),spec.placement.clusterSelector配置也会被忽略。
spec.placement.clusters
is not provided, spec.placement.clusterSelector
is provided but empty
1 2 3 | spec: placement: clusterSelector: {} |
In this case, the resource will be propagated to all member clusters.
在这种情况下,资源将传播到所有成员集群。
spec.placement.clusters
is not provided, spec.placement.clusterSelector
is provided and not empty
1 2 3 4 5 | spec: placement: clusterSelector: matchLabels: foo: bar |
In this case, the resource will only be propagated to member clusters that are labeled with foo: bar
.
在这种情况下,资源将只传播到标有foo:bar的成员集群。
摘自:https://github.com/kubernetes-sigs/kubefed/blob/master/docs/userguide.md#using-cluster-selector
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
2019-10-25 Loadrunner11压测过程问题总结
2016-10-25 在centos7上安装docker&&离线安装