k8s Source Analysis------Kube-apiserver Analysis (2)

Source: Internet
Author: User
Tags k8s

From my space turn over, space address http://user.qzone.qq.com/29185807/blog/1458270203

And then an article.

We're back in k8s.io\kubernetes\pkg\master\master.go.

Func (M *master) init (c *config) {

From the code, it generates a lot of storage,podstorage,eventstorage,nodestorage.



These storage are then registered in master's storage variable, which is the restful route, but not the restful routing format.



So where are these routes registered?

Let's keep looking down the code.

or the Init function, we see the API_V1 (). Installrest. This is where the storage route is converted to a restful route and registered in the Handlercontainer



Besides, there's a extensions installrest.



We're going to look back now, there are two important variables Mux,handlercontainer

These two variables are assigned when master initializes (the function is new)


and hook the MUX to the container.



We go back to init.

We see that after the API has been registered, it is the initialization of handler (HTTP handler), in fact handler is mentioned above MUX



Master's initialization is over, and now we're going to go back to K8s.io\kubernetes\cmd\kube-apiserver\app\server.go's run function.

At the end of the run function, you can see clearly that the handle in master is tied to the httpserver. And then a httpserver started.


Hao Haohua

QQ Crescent moon Lonely Road length 29185807

March 18, 2016 (Copyright: This article is original for the author, if you need to reprint, please notify me, and indicate the source and author. Reproduced without authorization, reserve the right to pursue its infringement. )

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.