背景
当 TKE 集群配置了节点池并启用了弹性伸缩,在节点资源不够时可以触发节点的自动扩容 (自动买机器并加入集群),但这个扩容流程需要一定的时间才能完成,在一些流量突高的场景,这个扩容速度可能会显得太慢,影响业务。 tke-autoscaling-placeholder
可以用于在 TKE 上实现秒级伸缩,应对这种流量突高的场景。
原理是什么"挤走",状态变成 Pending,如果配置了节点池并启用弹性伸缩,就会触发节点的扩容。这样,由于有了一些资源作为缓冲,即使节点扩容慢,也能保证一些 Pod 能够快速扩容并调度上,实现秒级伸缩。要调整预留的缓冲资源多少,可根据实际需求调整 tke-autoscaling-placeholder
的 request 或副本数。
有什么使用限制"text-align: center">
选择要部署的集群 id 与 namespace,应用的配置参数中最重要的是 replicaCount
与 resources.request
,分别表示 tke-autoscaling-placeholder
的副本数与每个副本占位的资源大小,它们共同决定缓冲资源的大小,可以根据流量突高需要的额外资源量来估算进行设置。
最后点击创建,你可以查看这些进行资源占位的 Pod 是否启动成功:
$ kubectl get pod -n default tke-autoscaling-placeholder-b58fd9d5d-2p6ww 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-55jw7 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-6rq9r 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-7c95t 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-bfg8r 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-cfqt6 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-gmfmr 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-grwlh 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-ph7vl 1/1 Running 0 8s tke-autoscaling-placeholder-b58fd9d5d-xmrmv 1/1 Running 0 8s
tke-autoscaling-placeholder
的完整配置参考下面的表格:
参数
描述
默认值
replicaCount
placeholder 的副本数
10
image
placeholder 的镜像地址
ccr.ccs.tencentyun.com/library/pause:latest
resources.requests.cpu
单个 placeholder 副本占位的 cpu 资源大小
300m
resources.requests.memory
单个 placeholder 副本占位的内存大小
600Mi
lowPriorityClass.create
是否创建低优先级的 PriorityClass (用于被 placeholder 引用)
true
lowPriorityClass.name
低优先级的 PriorityClass 的名称
low-priority
nodeSelector
指定 placeholder 被调度到带有特定 label 的节点
{}
tolerations
指定 placeholder 要容忍的污点
[]
affinity
指定 placeholder 的亲和性配置
{}
部署高优先级 Pod
tke-autoscaling-placeholder
的优先级很低,我们的业务 Pod 可以指定一个高优先的 PriorityClass,方便抢占资源实现快速扩容,如果没有可以先创建一个:
apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: 1000000 globalDefault: false description: "high priority class"
在我们的业务 Pod 中指定 priorityClassName
为高优先的 PriorityClass:
apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: replicas: 8 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: priorityClassName: high-priority # 这里指定高优先的 PriorityClass containers: - name: nginx image: nginx resources: requests: cpu: 400m memory: 800Mi
当集群节点资源不够,扩容出来的高优先级业务 Pod 就可以将低优先级的 tke-autoscaling-placeholder
的 Pod 资源抢占过来并调度上,然后 tke-autoscaling-placeholder
的 Pod 再 Pending:
$ kubectl get pod -n default NAME READY STATUS RESTARTS AGE nginx-bf79bbc8b-5kxcw 1/1 Running 0 23s
更新日志
- 罗斯特洛波维奇、布里顿《舒伯特-阿佩乔尼奏鸣曲》1995[WAV+CUE]
- 群星《超高品质流行女声大碟 静听女人心 2CD》[WAV+CUE][1.3GB]
- BEYOND《无悔这一生 2023》 [WAV+CUE][690MB]
- 群星《30首最发烧经典老歌 情牵男人心 2CD》[WAV+CUE][1.4GB]
- 群星《不老的情歌-至尊版2CD》WAV分轨
- 岁月留声机群星《七十年代人金曲回顾》(黑胶)2CD[WAV分轨]
- 群星-世纪难忘金曲(迪安唱片)5CD[WAV]
- HenrietteFaure-DebussyEstampesPrludes,LivreI(MonoVersion)[FLAC]
- 吕方1992-弯弯十八首[香港][WAV+CUE]
- 经典歌曲珍藏专辑《民歌30年·真情依旧》3CD[WAV+CUE]
- 群星《时尚流行发烧极品 非同凡响 第一辑 2CD》[WAV/分轨][1.3GB]
- 陈曦《多年以后》HQⅡ头版限量编号[WAV+CUE][520MB]
- 孙露《用情 HQⅡ 2023》[WAV+CUE][380MB]
- 电影原声《速度与激情9电影原声大碟》2021[WAV+CUE]
- 【瑞鸣音乐】群星《伶歌》[XRCD2][WAV+CUE]