In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to configure Kubernetes PodGC Controller". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
PodGC Controller configuration
There are only two configurations related to PodGC Controller (kube-controller-manager configuration):
Flagdefault valuecomments--controllers stringSlice* is configured with the controlllers list of enable. Of course, podgc can also be set here to enable or disable. The default podgc is in the enable list. -- terminated-pod-gc-threshold int3212500Number of terminated pods that can exist before the terminated pod garbage collector starts deleting terminated pods. If 0 {glog.Infof ("garbage collecting% v pods", deleteCount)} var wait sync.WaitGroup for I: = 0; I
< deleteCount; i++ { wait.Add(1) go func(namespace string, name string) { defer wait.Done() if err := gcc.deletePod(namespace, name); err != nil { // ignore not founds defer utilruntime.HandleError(err) } }(terminatedPods[i].Namespace, terminatedPods[i].Name) } wait.Wait()} 遍历所有pods,过滤出所有Terminated Pods(Pod.Status.Phase不为Pending, Running, Unknow的Pods). 计算terminated pods数与terminatedPodThreshold的(超出)差值deleteCount。 启动deleteCount数量的goruntine协程,并行调用gcc.deletePod(invoke apiserver's api)方法立刻删除对应的pod。 回收那些Binded的Nodes已经不存在的pods// gcOrphaned deletes pods that are bound to nodes that don't exist.func (gcc *PodGCController) gcOrphaned(pods []*v1.Pod) { glog.V(4).Infof("GC'ing orphaned") // We want to get list of Nodes from the etcd, to make sure that it's as fresh as possible. nodes, err := gcc.kubeClient.Core().Nodes().List(metav1.ListOptions{}) if err != nil { return } nodeNames := sets.NewString() for i := range nodes.Items { nodeNames.Insert(nodes.Items[i].Name) } for _, pod := range pods { if pod.Spec.NodeName == "" { continue } if nodeNames.Has(pod.Spec.NodeName) { continue } glog.V(2).Infof("Found orphaned Pod %v assigned to the Node %v. Deleting.", pod.Name, pod.Spec.NodeName) if err := gcc.deletePod(pod.Namespace, pod.Name); err != nil { utilruntime.HandleError(err) } else { glog.V(0).Infof("Forced deletion of orphaned Pod %s succeeded", pod.Name) } }} gcOrphaned用来删除那些bind的node已经不存在的pods。 调用apiserver接口,获取所有的Nodes。 遍历所有pods,如果pod bind的NodeName不为空且不包含在刚刚获取的所有Nodes中,则串行逐个调用gcc.deletePod删除对应的pod。 回收Unscheduled并且Terminating的podspkg/controller/podgc/gc_controller.go:167// gcUnscheduledTerminating deletes pods that are terminating and haven't been scheduled to a particular node.func (gcc *PodGCController) gcUnscheduledTerminating(pods []*v1.Pod) { glog.V(4).Infof("GC'ing unscheduled pods which are terminating.") for _, pod := range pods { if pod.DeletionTimestamp == nil || len(pod.Spec.NodeName) >0 {continue} glog.V (2). Infof ("Found unscheduled terminating Pod% v not assigned to any Node. Deleting. ", pod.Name) if err: = gcc.deletePod (pod.Namespace, pod.Name); err! = nil {utilruntime.HandleError (err)} else {glog.V (0) .Infof (" Forced deletion of unscheduled terminating Pod% s succeeded ", pod.Name)}
GcUnscheduledTerminating deletes those terminating and has not dispatched to the pods of a certain node.
Iterate through all the pods, filtering those pods that are terminating (pod.DeletionTimestamp! = nil) and are not scheduled successfully (pod.Spec.NodeName is empty).
Serial calls to gcc.deletePod one by one to delete the corresponding pod.
This is the end of "how to configure Kubernetes PodGC Controller". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 259
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.