前面将kubernetes的API Server注册启动命令创建好了之后回到NewCommandStartAllInOne要领中,此次看下NewCommandStartMaster要领,此要领即为获取启动openshift master的命令
--》openshift/origin/pkg/cmd/server/start/start_allinone.go
--》openshift/origin/pkg/cmd/server/start/start_master.go
NewCommandStartMaster要领中添加命令的逻辑如下,即为添加了controller和API的两个启动命令
这里我们主要看下API相关的即NewCommandStartMasterAPI要领
--》openshift/origin/pkg/cmd/server/start/start_api.go
NewCommandStartMasterAPI要领里面主要逻辑如下,即挪用StartMaster要领来启动master处事
后面在RunMaster要领里面按照配置信息出产一个master布局东西并挪用start要领启动
--》openshift/origin/pkg/cmd/server/start/start_master.go
start要领里面先按照给定选项来创建openshift和kubernetes的配置信息
然后判断此master server是否有api处事,,若有则按照刚刚创建的两个配置文件挪用StartAPI要领来启动master上的api部分组件
StartAPI要领会启动那些在master上被认为是API一部分的组件,好比一开始就会按照配置信息来判断是否启动etcd
后面会挪用openshiftConfig的run要领来加载组件
--》openshift/origin/pkg/cmd/server/origin/master.go
run要领里面会措置惩罚惩罚两种API,一种是访谒受掩护的api(凡是这类挪用是需要验证的),另一种是不受掩护的api,我们这里主要存眷那些受掩护的api,因为大部分api都是这种
InstallProtectedAPI要领即为安置注册受掩护的api,逻辑里首先初始化所有openshift的api
GetRestStorage要领会获取openshift所用到的所有storage,例如projectStorage
然后将所有storage放到一个map中,此map相当于一个openshift的配置文件,记录了所有api路径和此路径所用到的storage
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()), }
拿到了所有storage后便判断是否是v1版本的,若是则安置注册这些api