Kubernetes Scheduling component Kube-scheduler Source analysis

Source: Internet
Author: User
Tags data structures rand
kubernetes Scheduling Component Kube-scheduler Source analysis 1. Dispatch Flow chart
2 Introduction to the default scheduling algorithm
3 Data Structure func Main () {

Runtime. Gomaxprocs (runtime. NUMCPU ())

S:=options. Newschedulerserver ()

S.addflags (Pflag.commandline)

Util. Initflags ()

Util. Initlogs ()

defer util. Flushlogs ()

Verflag. Printandexitifrequested ()

App. Run (s)

}

The main function first constructs and initializes the schedulerserver structure, and the following is a look at the main data structures

Scheduling can be divided into two parts, the first part is the scheduling algorithm part, the second part is the dispatch execution part.


Data structure of Genericscheduler dispatch execution part


type genericscheduler struct{

Cacheschedulercache. Cache

predicates map[String]algorithm. Fitpredicate

Prioritizers []algorithm. Priorityconfig

Extenders []algorithm. Schedulerextender

Pods algorithm. Podlister

Random *rand. Rand

Random Locksync.mutex

Lastnodeindex UInt64

}

The Fitpredicate function is used to determine in node whether the resource requested by the pod satisfies the need.

type Priorityconfig struct{

Function priorityfunction

Weight int

}

Priorityconfig structures include function functions and weight integer variables, function functions are used to represent predictive algorithms, and weight variables are used to indicate the weighting of predictive algorithms.

The schedule in Genericscheduler is the function that is responsible for scheduling, which uses the Findnodesthatfit and prioritizenodes two functions. 4 Execution Process

1, new schedulerserver structure body


2, incoming parameters and initialize


Run


1, through Kubeconfig to create kubeclient for access to Apiserver


2, create htttpserver for performance analysis, performance metrics


3. Create Scheduler.config objects (periodically get a list of the already scheduled pods and remove them from the Modeler assumption queue). Monitor the available node, get the service list,


Create Genericscheduler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.