Hao Liang's Blog

Embrace the World with Cloud Native and Open-source

【Scheduling】Working principle of kube-scheduler: preemption mechanism in Priority algorithm

1. Why is the preemption mechanism needed? When a pod fails to be scheduled, it is temporarily in the pending state. The scheduler will not reschedule the pod until the pod is updated or the cluster status changes. However, in actual business scenarios, there will be a distinction between online and offline services. If the pod of the online service fails to be scheduled due to insufficient resources, it is necessary for the offline service to drop part of the resources to provide resources for the online service.

kube-apiserver code breakdown: component composition and principle

1. Component composition apiserver consists of 3 components (AggregatorServer, APIServer, APIExtensionServer) AggregatorServer: implements proxy forwarding of requests, intercepts and forwards requests from users to other servers, and is responsible for the service discovery function of the entire APIServer APIServer: Responsible for processing some requests for built-in resource objects, including authentication, authentication, etc., as well as processing REST services for each built-in resource APIExtensionServer: mainly handles requests for custom resource objects

Analysis on the relevant principles of resource reservation in Kubernetes

1. How to calculate resources in kubernetes In Kubernetes, allocatableKubelet is used through nodes. Node Allocatable is used to reserve resources for Kube components and System processes, thereby ensuring that Kube and System processes have sufficient resources when the nodes are fully loaded. Calculation method of resources that a node can allocate to a pod: Node Allocatable Resource = Node Capacity(Total resource) - Kube-reserved(reserved by kubelet) - system-reserved(reserved by system) - eviction-threshold(eviction threshold set by user)

Resource oversold based on MutatingAdmissionWebhook in Kubernetes

一、Analysis of Resource Oversold Problem In the production environment, many Pods are running on the computing nodes of the kubernetes cluster, running various business containers. We usually use resource objects such as Deployment, DeamonSet, and StatefulSet to control the addition, deletion, and modification of Pods. Therefore, development or operation and maintenance often need to configure the resource quotas of the CPU

HPA in Kubernetes

一、Introduction to HPA HPA (Horizontal Pod Autoscaler) Pod automatically scales up and down. K8S realizes dynamic addition and reduction of the number of Pod instances by detecting various indicators of the containers running in the Pod (CPU usage, memory usage, network requests). Early Kubernetes versions only supported the detection of CPU indicators because it was implemented through

【Code Breakdown】Kubernetes scheduler--Analysis of Predicates preselection algorithm

Scheduler workflow When we use K8S clusters, we often need to create, modify, and delete Deployment Controllers. K8S will create, destroy, and reschedule Pods on the appropriate nodes. This scheduling process is implemented through the K8S Scheduler scheduler. Schduler’s workflow is shown below: The Informer component has been monitoring changes in Pod information in etcd. To be precise, it is monitoring changes in the Spec.nodeName field in Pod information. Once

【Code Breakdown】Kubernetes scheduler--Analysis of Priority optimization algorithm

Scheduler workflow When we use K8S clusters, we often need to create, modify, and delete Deployment Controllers. K8S will create, destroy, and reschedule Pods on the appropriate nodes. This scheduling process is implemented through the K8S Scheduler scheduler. Schduler’s workflow is shown below: The Informer component has been monitoring changes in Pod information in etcd. To be precise, it is monitoring changes in the Spec.nodeName field in Pod information. Once it detects that this field is empty, it is considered that there are Pods in the cluster that have not been scheduled to Node.