k8s Source Analysis-----Kube-scheduler

Source: Internet
Author: User
Tags k8s

This text is transferred from oneself space: http://user.qzone.qq.com/29185807/blog/1459831332

Source code for k8s v1.1.1 stable version one, main flow 1. Main entrance

Source code in K8s.io/kubernetes/plugin/cmd/kube-scheduler

This package is k8s inside the consistent package style, no longer say more

Source code in K8s.io/kubernetes/plugin/cmd/kube-scheduler/app

Keep going down.


The real entrance.

There's a ratelimiter down there.

In factory. Func (S *schedulerserver) was called after Newconfigfactory Createconfig

2, Configfactory

SOURCE K8s.io/kubernetes/plugin/pkg/scheduler/factory

Look at the structure first.


1, client and Apiserver interface

2, Podqueue,scheduledpodlister,scheduledpodpopulator This is the key data, later analysis

3, Podlister, Nodelister,servicelister,controllerlister scheduling time to use the data

4, Bindpodsratelimiter, at the entrance of the initialization of the Ratelimiter

5, modeler,pod Information processing part

We continue to

The following code, do a simple initialization. One of the important initialization is modeler


Continue process

Go on




3, Scheduler process



Second, Modeler analysis

Source code in K8s.io\kubernetes\plugin\pkg\scheduler\modeler.go


In modeler, there are three list

1, Queuedpods:a Podlister that'll return pods that have not been scheduled.

is about to be scheduled, not yet scheduled.

2, Scheduledpods:a Podlister that'll return pods that we know for sure have been.

Already scheduled 3, assumedpods:holds the pods that we we'd ' ve scheduled, but that haven ' t yet shown        Variable. In dispatch, no more than three queues have been confirmed we look at the three queues of past lives and life 1, queuedpods

In K8s.io\kubernetes\plugin\pkg\scheduler\factory\factory.go (already in the above)

It's obvious that podqueue initialized the Modeler


K8s.io\kubernetes\plugin\pkg\scheduler\modeler.go

The Podqueue in Configfactory is the Queuedpods in Modeler


Func (f *configfactory) Createfromkeys function, where a producer is generated to capture the pods that need to be scheduled, stored in Podqueue



Func (f *configfactory) Createfromkeys function at the end of the function, provides an excuse for scheduler to get the pod to be scheduled


In the K8s.io\kubernetes\plugin\pkg\scheduler scheduleone, get the pod that needs to be dispatched and then schedule


2, Assumedpods

In the scheduleone of K8s.io\kubernetes\plugin\pkg\scheduler, dispatch the pod that needs to be dispatched, and then put its dispatch into Assumedpods

In modeler, add to Assumepods queue

And then we'll see when we're going to spend the assumepods.

In the Newconfigfactory function, we see that a producer is generated to get all the scheduled pods and then, in two interfaces, the pod that has been dispatched in the Assumepods is deleted



3, Scheduledpods

This has been scheduled in the Newconfigfactory function, timed to get the already scheduled pod


Summarize

1, in Configfactory, call the interface with the Apiserver, periodically get the pod that needs to be dispatched, save it in the queuedpods of Modeler

2, in configfactory, such as scheduler provide access to the need to dispatch the Pod interface, and then in the scheduler for scheduling processing, (through Genericscheduler to obtain the dispatch required host), and put it in the Assumepods in modeler.

3, in the configfactory, periodically get the scheduled pod information, and then refresh Assumepod and Scheduledpods

third, Genericscheduler analysis

Let's look at the k8s.io\kubernetes\plugin\pkg\scheduler\factory.

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.