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

Source: Internet
Author: User
Tags etcd k8s

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

Source version for v1.1.1 stable version

Start file K8s.io/kubernetes/cmd/kube-apiserver/apiserver.go from function main


We enter the Server.go in the K8s.io/kubernetes/cmd/kube-apiserver/app catalogue.



We see a lot of parameters in apiserver and we don't care about it for a while. Newapiserver also just do some parameter assignment.


Let's look at the run function specifically

There is a place for



The resolution of NEWETCD is:



A ETCD client is generated and encapsulated by Etcdhelper.

And then register it in the Apigroup.

Storagedestinations.addapigroup ("", Etcdstorage)

In the following master initialization, Apigroup is assigned to config


Followed by



Let's keep looking at the code in master K8s.io\kubernetes\pkg\master\master.go

The new function mainly makes some parameter assignment, then defines the RESTful container.

About restful this follow-up analysis.


We just need to see master.init.



Init in the storagedestinations from the previous registered in the Apigroup, which is the variable etcdstorage etcdhelper structure body

A podstorage is generated here.

Continue tracking K8s.io\kubernetes\pkg\registry\pod\etcd\etcd.go

In Newstorage This function is actually a encapsulation of the ETCDGENERIC.ETCD. And the most important parameter etcdhelper passed to Etcdgeneric. Storage member variable for ETCD




We'll keep tracking.

K8s.io\kubernetes\pkg\registry\generic\etcd



In this case, there are some function object variables, and one of the most important is storage

Let's take the CREATE function for example

Hao Haohua

QQ Crescent moon Lonely Road length 29185807

March 17, 2016

(Copyright statement: This article for the author original, 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.