Openshift API part of the source learning notes (ii)

Source: Internet
Author: User

The previous article will openshift inside the start Kubernetes component part of the resolution, this article will OpenShift start the master service code to parse

Previous post link: http://www.cnblogs.com/zard/p/7767112.html

SOURCE Analysis

Before the Kubernetes API Server Registration Start command is created, go back to the Newcommandstartallinone method, this time looking at the Newcommandstartmaster method, this method is to get the boot OpenShift Commands for Master

--"openshift/origin/pkg/cmd/server /start/start_allinone.go

--"openshift/origin/pkg/cmd/server /start/start_master.go

The logic for adding commands to the Newcommandstartmaster method is as follows: Two start commands for adding controllers and APIs

Here we mainly look at the API-related Newcommandstartmasterapi method

--"OpenShift/origin/pkg/cmd/server /start/start_api.go

The main logic in the Newcommandstartmasterapi method is as follows, calling the Startmaster method to start the master service

Behind the Runmaster method, a master structure object is produced based on the configuration information and the Start method is called

--"openshift/origin/pkg/cmd/server /start/start_master.go

The Start method first creates OpenShift and Kubernetes configuration information based on the given options.

Then determine if this master server has an API service, and if so, invoke the Startapi method to start the API component on master based on the two configuration files just created

The Startapi method launches components that are considered part of the API on master, such as starting with configuration information to determine whether to start ETCD

The Openshiftconfig Run method is called later to load the component

--"OpenShift/origin/pkg/cmd/server /origin/master.go

The Run method handles two APIs, one that accesses the protected API (which is usually required to be validated), and an unprotected API, where we focus primarily on protected APIs, because most APIs are

The Installprotectedapi method is to register the protected API for installation, and the logic initializes all OpenShift APIs first.

The Getreststorage method obtains all storage used by OpenShift, such as Projectstorage

Then put all the storage into a map, which is equivalent to a openshift configuration file that records all the API paths and the storage used for this path

Storage: = map[string]rest. storage{"Images": Imagestorage,"Imagesignatures": Imagesignaturestorage,"imagestreams/secrets": Imagestreamsecretsstorage,"Imagestreams": Imagestreamstorage,"Imagestreams/status": Imagestreamstatusstorage,"Imagestreamimports": Imagestreamimportstorage,"imagestreamimages": Imagestreamimagestorage,"imagestreammappings": Imagestreammappingstorage,"Imagestreamtags": Imagestreamtagstorage,"Deploymentconfigs": Deployconfigstorage,"Deploymentconfigs/scale": Deployconfigscalestorage,"Deploymentconfigs/status": Deployconfigstatusstorage,"Deploymentconfigs/rollback": Deployconfigrollbackstorage,"Deploymentconfigs/log": Deploylogregistry. Newrest (Configclient, Kclient, C.deploymentlogclient (), kubeletclient),//Todo:deprecate These        "Generatedeploymentconfigs": Deployconfiggenerator. Newrest (Deployconfiggenerator, C.etcdhelper.codec ()),"Deploymentconfigrollbacks": Deployrollback. Newdeprecatedrest (Deployrollbackclient, C.etcdhelper.codec ()),"processedtemplates": Templateregistry. Newrest (),"Templates": Templatestorage,"Routes": Routestorage,"Routes/status": Routestatusstorage,"Projects": Projectstorage,"projectrequests": Projectrequeststorage,"hostsubnets": Hostsubnetstorage,"netnamespaces": Netnamespacestorage,"Clusternetworks": Clusternetworkstorage,"egressnetworkpolicies": Egressnetworkpolicystorage,"Users": Userstorage,"groups": Groupstorage,"Identities": Identitystorage,"useridentitymappings": Useridentitymappingstorage,"Oauthauthorizetokens": Authorizetokenstorage,"Oauthaccesstokens": Accesstokenstorage,"oauthclients": Clientstorage,"oauthclientauthorizations": Clientauthorizationstorage,"resourceaccessreviews": Resourceaccessreviewstorage,"subjectaccessreviews": Subjectaccessreviewstorage,"localsubjectaccessreviews": Localsubjectaccessreviewstorage,"localresourceaccessreviews": Localresourceaccessreviewstorage,"selfsubjectrulesreviews": Selfsubjectrulesreviewstorage,"Policies": Policystorage,"policybindings": Policybindingstorage,"Roles": Rolestorage,"rolebindings": Rolebindingstorage,"clusterpolicies": Clusterpolicystorage,"clusterpolicybindings": Clusterpolicybindingstorage,"clusterrolebindings": Clusterrolebindingstorage,"Clusterroles": Clusterrolestorage,"Clusterresourcequotas": Restinpeace (clusterresourcequotaregistry. Newstorage (C.restoptionsgetter)),"Clusterresourcequotas/status": Updateinpeace (clusterresourcequotaregistry. Newstatusstorage (C.restoptionsgetter)),"Appliedclusterresourcequotas": Appliedclusterresourcequotaregistry. Newrest (C.clusterquotamappingcontroller.getclusterquotamapper (), C.informers.clusterresourcequotas (). Lister (), C.informers.namespaces (). Lister ()),}

When you get all the storage, you can determine if it is a V1 version, and if it is installed, register these APIs

This first calls the ApiLegacyV1 method to get a Apigroupversion structure object from the storage map you just obtained, which is the structure object of the kubernetes. Then call Apigroupversion's Installrest method to install the API

Installrest method Logic is the same as in the previous article Kubernetes, here is no longer repeated analysis, this method code is as follows:

So the API component on OpenShift Master started successfully.

Openshift API part of the source learning notes (ii)

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.