通过配置 DeschedulerPolicy? 的 strategies?,可以指定 descheduler 的执行策略,这些策略都是可以启用或禁用的,下面我们会详细介绍,这里我们使用默认策略即可,使用如下命令直接安装即可:
? helm upgrade --install descheduler descheduler/descheduler --set image.repository=cnych/descheduler -n kube-system
部署完成后会创建一个 CronJob 资源对象来平衡集群状态:
? kubectl get cronjob -n kube-systemNAMESCHEDULESUSPENDACTIVELAST SCHEDULEAGEdescheduler*/2 * * * *False18s117s? kubectl get job -n kube-systemNAMECOMPLETIONSDURATIONAGEdescheduler-280329821/115s17s? kubectl get pods -n kube-system -l job-name=descheduler-28032982NAMEREADYSTATUSRESTARTSAGEdescheduler-28032982-vxn240/1Completed031s
正常情况下就会创建一个对应的 Job 来执行 descheduler 任务,我们可以通过查看日志可以了解做了哪些平衡操作:
? kubectl logs -f descheduler-28032982-vxn24 -nkube-systemI0420 08:22:10.0199361 named_certificates.go:53] "Loaded SNI cert" index=0 certName="self-signed loopback" certDetail=""apiserver-loopback-client@1681978930" [serving] validServingFor=[apiserver-loopback-client] issuer="apiserver-loopback-client-ca@1681978929" (2023-04-20 07:22:09 +0000 UTC to 2024-04-19 07:22:09 +0000 UTC (now=2023-04-20 08:22:10.019885292 +0000 UTC))"I0420 08:22:10.0201381 secure_serving.go:210] Serving securely on [::]:10258I0420 08:22:10.0203011 tlsconfig.go:240] "Starting DynamicServingCertificateController"I0420 08:22:10.0212371 policyconfig.go:211] converting Deschedule plugin: %sRemovePodsViolatingInterPodAntiAffinityI0420 08:22:10.0212551 policyconfig.go:211] converting Deschedule plugin: %sRemovePodsViolatingNodeAffinityI0420 08:22:10.0212621 policyconfig.go:211] converting Deschedule plugin: %sRemovePodsViolatingNodeTaintsI0420 08:22:10.0212691 policyconfig.go:202] converting Balance plugin: %sRemovePodsViolatingTopologySpreadConstraintI0420 08:22:10.0212801 policyconfig.go:202] converting Balance plugin: %sLowNodeUtilizationI0420 08:22:10.0212961 policyconfig.go:202] converting Balance plugin: %sRemoveDuplicatesI0420 08:22:10.0213121 policyconfig.go:211] converting Deschedule plugin: %sRemovePodsHavingTooManyRestarts# ......I0420 08:22:11.6309801 removeduplicates.go:162] "Duplicate found" pod="kruise-system/kruise-controller-manager-7d78fc5c97-pxsqx"I0420 08:22:11.6309971 removeduplicates.go:103] "Processing node" node="node2"I0420 08:22:11.6310521 removeduplicates.go:103] "Processing node" node="node3"I0420 08:22:11.6311131 removeduplicates.go:103] "Processing node" node="master1"I0420 08:22:11.6311841 removeduplicates.go:194] "Adjusting feasible nodes" owner={namespace:kruise-system kind:ReplicaSet name:kruise-controller-manager-7d78fc5c97 imagesHash:openkruise/kruise-manager:v1.3.0} from=4 to=3I0420 08:22:11.6312001 removeduplicates.go:203] "Average occurrence per node" node="node1" ownerKey={namespace:kruise-system kind:ReplicaSet name:kruise-controller-manager-7d78fc5c97 imagesHash:openkruise/kruise-manager:v1.3.0} avg=1I0420 08:22:11.6474381 evictions.go:162] "Evicted pod" pod="kruise-system/kruise-controller-manager-7d78fc5c97-pxsqx" reasnotallow="" strategy="RemoveDuplicates" node="node1"I0420 08:22:11.6474941 descheduler.go:408] "Number of evicted pods" totalEvicted=1I0420 08:22:11.6475831 reflector.go:227] Stopping reflector *v1.Namespace (0s) from k8s.io/client-go/informers/factory.go:150I0420 08:22:11.6477021 reflector.go:227] Stopping reflector *v1.PriorityClass (0s) from k8s.io/client-go/informers/factory.go:150I0420 08:22:11.6477611 tlsconfig.go:255] "Shutting down DynamicServingCertificateController"I0420 08:22:11.6477641 reflector.go:227] Stopping reflector *v1.Node (0s) from k8s.io/client-go/informers/factory.go:150I0420 08:22:11.6478111 secure_serving.go:255] Stopped listening on [::]:10258......
从日志中我们就可以清晰的知道因为什么策略驱逐了哪些 Pods 。
PDB由于使用 descheduler? 会将 Pod 驱逐进行重调度,但是如果一个服务的所有副本都被驱逐的话,则可能导致该服务不可用 。如果服务本身存在单点故障,驱逐的时候肯定就会造成服务不可用了,这种情况我们强烈建议使用反亲和性和多副本来避免单点故障,但是如果服务本身就被打散在多个节点上,这些 Pod 都被驱逐的话,这个时候也会造成服务不可用了,这种情况下我们可以通过配置 PDB(PodDisruptionBudget) 对象来避免所有副本同时被删除,比如我们可以设置在驱逐的时候某应用最多只有一个副本不可用,则创建如下所示的资源清单即可:
推荐阅读
- |大力马线钓鱼真的挡口吗,为何大师们不用?带你了解真相!
- 带你读 MySQL 源码:Select *
- JavaScript日期处理不再难!Day.js带你飞!
- 5条适合5月出发的自驾路线,带你一路看山看水,五一假期约起来
- 国王游戏动漫未删减在线观看?零基础如何学习游戏动画?
- 大学体育舞蹈学什么!在高校学习体育舞蹈是种怎样的体验?
- 招聘|KTV公主招聘进高校,毕业生们有话说:四年学习,一朝就业KTV?
- ktv|高校春招现“KTV公主”一职,网友怒了:“四年学习一朝就业KTV?”校方、涉事酒店回应…
- 招聘|四年学习一着就业KTV?高校春招现“KTV公主”一职,校方有回应
- |学习紫砂购买哪些泥料的壶