一、Linear Mode
ConfigMap 配置示例如下:
data: linear: |- { "coresPerReplica": 2, "nodesPerReplica": 1, "min": 1, "max": 100, "preventSinglePointFailure": true }
目标副本计算公式:
replicas = max(ceil(cores × 1/coresPerReplica) , ceil(nodes × 1/nodesPerReplica))
replicas = min(replicas, max)
replicas = max(replicas, min)
二、Ladder Mode
ConfigMap 配置示例如下:
data: ladder: |- { "coresToReplicas": [ [ 1, 1 ], [ 64, 3 ], [ 512, 5 ], [ 1024, 7 ], [ 2048, 10 ], [ 4096, 15 ] ], "nodesToReplicas": [ [ 1, 1 ], [ 2, 2 ] ] }
目标副本计算:
假设 100nodes/400cores 的集群中,按照上述配置,nodesToReplicas 取2(100node 大于 2node,向下取整),coresToReplicas 取3(400core 落在 64core 和 512core 之间,向下取整),二者取较大值3,最终 replica 为3。
三、部署在集群内的 Kubernetes 对象
| Kubernetes 对象名称 | 类型 | 请求资源 | 所属 Namespace |
| tke-dns-autoscaler | Deployment | 每节点20mCPU,10Mi内存 | kube-system |
| dns-autoscaler | ConfigMap | – | kube-system |
| tke-dns-autoscaler | ServiceAccount | – | kube-system |
| tke-dns-autoscaler | ClusterRole | – | – |
| tke-dns-autoscaler | ClusterRoleBinding | – | – |
四、限制条件
·仅在 1.8 版本以上的 Kubernetes 集群支持。
·集群中的 dns server 的工作负载为 deployment/coredns。
五、特别说明
CoreDNS 的水平伸缩可能导致部分副本在一段时间内不可用,强烈建议安装该组件前,进行相关的优化配置,最大程度保证 DNS 服务的可用性,详情可参见 配置 CoreDNS 平滑升级。
六、权限说明
该组件权限是当前功能实现的最小权限依赖。
七、权限场景
| 功能 | 涉及对象 | 涉及操作权限 |
| 需要监听集群内 Node 资源的变化。 | node | list/watch |
| 修改 deployment 部署的 coredns 副本数。 | replicationcontrollers/scale、deployments/scale 和 replicasets/scale | get/update |
| 获取 ConfigMap 中参数配置。在没有配置参数的情况下,会创建默认参数的 configmap。 | configmap | get/create |
八、权限定义
kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1metadata: name: tke-dns-autoscalerrules: – apiGroups: – "" resources: – nodes verbs: – list – watch – apiGroups: – "" resources: – replicationcontrollers/scale verbs: – get – update – apiGroups: – extensions – apps resources: – deployments/scale – replicasets/scale verbs: – get – update – apiGroups: – "" resources: – configmaps verbs: – get – create
九、使用方法
1. 登录 容器服务控制台,在左侧导航栏中选择集群。
2. 在集群列表中,单击目标集群 ID,进入集群详情页。
3. 选择左侧菜单栏中的组件管理,在组件管理页面单击新建。
4. 在新建组件页面中勾选 DNSAutoscaler。该组件默认伸缩配置策略如下:
data: ladder: |- { "coresToReplicas": [ [ 1, 1 ], [ 128, 3 ], [ 512, 4 ] ], "nodesToReplicas": [ [ 1, 1 ], [ 2, 2 ] ] }
扩展组件创建成功后,可以通过修改 kube-system 命名空间下的 configmap/dns-autoscaler 来变更配置。详细配置请参见 产品文档。
5. 单击完成即可创建组件。
十、参数说明
| 参数 | 说明 | 类型 | 默认值 |
| global.image.host | 镜像仓库地址 | string | ccr.ccs.tencentyun.com |
| global.podSpec.tolerations | 额外的容忍配置(追加到默认的 CriticalAddonsOnly 之后) | list | [] |
| global.podSpec.priorityClassName | Pod 优先级类名 | string | system-cluster-critical |
| autoscaler.replicas | autoscaler 自身的副本数 | int | 1 |
| autoscaler.resources.requests.cpu | CPU 请求 | string | 20m |
| autoscaler.resources.requests.memory | 内存请求 | string | 10Mi |
| autoscaler.resources.limits.cpu | CPU 限制,为空表示不设置 | string | "" |
| autoscaler.resources.limits.memory | 内存限制,为空表示不设置 | string | "" |