125. 如何调整 RKE2 CoreDNS 的副本数量
也可以作为扩展 CoreDNS Pods 的替代方案,因为 node-local-dns 会在每个节点启动一个 pod,并带来其他好处。要在 RKE2 中对默认的 CoreDNS 部署应用更改,请使用 HelmChartConfig 配置相应的 helm 值。对于独立的 RKE2 集群,可以在 /var/lib/rancher/rke2/server/manifests 目录中。对于 Ranche
You want to adjust the number of CoreDNS replicas in the RKE2 cluster.
你需要调整 RKE2 集群中的 CoreDNS 副本数量。
RKE2 manages the number of CoreDNS Pods automatically through the rke2-coredns-autoscaler. Therefore, manually changing the replica count of the CoreDNS Deployment will be automatically overwritten and reverted to a pre-calculated value.
RKE2 通过 rke2-coredns-autoscaler 自动管理 CoreDNS Pods 的数量。因此,手动更改 CoreDNS 部署的副本数量将被自动覆盖并恢复为预先计算的值。
Steps 步骤
To apply the changes to the default CoreDNS deployment in RKE2, configure the appropriate helm values with a HelmChartConfig.
要在 RKE2 中对默认的 CoreDNS 部署应用更改,请使用 HelmChartConfig 配置相应的 helm 值。
- For standalone RKE2 clusters, add the HelmChartConfig to each rke2-server (control plane) node as a .yaml file in the /var/lib/rancher/rke2/server/manifests directory
对于独立的 RKE2 集群,可以在 /var/lib/rancher/rke2/server/manifests 目录中 ,将 HelmChartConfig 作为 .yaml 文件添加到每个 rke2-server 节点 - For RKE2 clusters provisioned by Rancher, add the HelmChartConfig content when editing the cluster in Cluster Management. Paste/edit the content under Cluster Configuration > Additional Manifest and save
对于 Rancher 配置的 RKE2 集群,编辑集群时在集群管理中添加 HelmChartConfig 内容。在集群配置 > 额外清单下粘贴/编辑内容并保存
Examples 示例
Configure minimum/maximum number of Pods:
配置最小/最大数量的 Pod:
<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>apiVersion: <a data-cke-saved-href="http://helm.cattle.io/v1" href="http://helm.cattle.io/v1">helm.cattle.io/v1</a>
kind: HelmChartConfig
metadata:
name: rke2-coredns
namespace: kube-system
spec:
valuesContent: |
autoscaler:
min: 5
max: 10</code></span></span></span>
Based on the number of nodes (one Pod per node):
根据节点数量(每个节点一个 Pod):
<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>apiVersion: <a data-cke-saved-href="http://helm.cattle.io/v1" href="http://helm.cattle.io/v1">helm.cattle.io/v1</a>
kind: HelmChartConfig
metadata:
name: rke2-coredns
namespace: kube-system
spec:
valuesContent: |
autoscaler:
nodesPerReplica: 1
</code></span></span></span>
Based on CPU cores (one Pod for every 6 cores):
基于 CPU 核心(每 6 个核心一个 Pod):
<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>apiVersion: <a data-cke-saved-href="http://helm.cattle.io/v1" href="http://helm.cattle.io/v1">helm.cattle.io/v1</a>
kind: HelmChartConfig
metadata:
name: rke2-coredns
namespace: kube-system
spec:
valuesContent: |
autoscaler:
coresPerReplica: 6
</code></span></span></span>
Note node-local-dns can also be an alternative to scaling the CoreDNS pods, as node-local-dns will start a pod on each node and provide other benefits
注意, node-local-dns 也可以作为扩展 CoreDNS Pods 的替代方案,因为 node-local-dns 会在每个节点启动一个 pod,并带来其他好处
For more configuration options of RKE2 CoreDNS, please refer to the GitHub: https://github.com/rancher/rke2-charts/tree/main/charts/rke2-coredns/rke2-coredns
有关 RKE2 CoreDNS 的更多配置选项,请参阅 GitHub: https://github.com/rancher/rke2-charts/tree/main/charts/rke2-coredns/rke2-coredns
Related KB articles: 相关知识库文章:
一个由 Rancher 配置或独立的 RKE2 集群。
访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009
更多推荐
所有评论(0)