sourceCode
阅读源码
-
make generated_files
或者使用make generated_files --debug=all
进行debug cd /Users/jomenxiao/go/src/k8s.io/kubernetes/cmd/kube-apiserver
go-callvis .
入口函数
- main函数
cmd/kube-apiserver/apiserver.go
,使用的时候cobra的命令管理 - Run函数位于
cmd/kube-apiserver/app/server.go
-
Run
-
CreateServerChain
启动的服务链 - 启动准备
PrepareRun
Run
-
-
CreateServerChain
-
CreateNodeDialer
CreateNodeDialer creates the dialer infrastructure to connect to the nodes. -
CreateKubeAPIServerConfig
CreateKubeAPIServerConfig creates all the resources for running the API server, but runs none of them -
createAPIExtensionsConfig
If additional API servers are added, they should be gated. -
createAPIExtensionsServer
CustomResourceDefinitions -
CreateKubeAPIServer
CreateKubeAPIServer creates and wires a workable kube-apiserver -
createAggregatorConfig
aggregator comes last in the chain createAggregatorServer
-
-
CreateKubeAPIServerConfig
-
buildGenericConfig
BuildGenericConfig takes the master server options and produces the genericapiserver.Config associated with it-
genericConfig = genericapiserver.NewConfig(legacyscheme.Codecs)
NewConfig returns a Config struct with the default value -
genericConfig.MergedResourceConfig = controlplane.DefaultAPIResourceConfigSource()
DefaultAPIResourceConfigSource returns default configuration for an APIResource -
s.GenericServerRunOptions.ApplyTo(genericConfig)
ApplyTo applies the run options to the method receiver and returns self -
s.SecureServing.ApplyTo(&genericConfig.SecureServing, &genericConfig.LoopbackClientConfig)
ApplyTo fills up serving information in the server configuration. s.Features.ApplyTo(genericConfig)
-
s.APIEnablement.ApplyTo(genericConfig, controlplane.DefaultAPIResourceConfigSource(), legacyscheme.Scheme
ApplyTo override MergedResourceConfig with defaults and registry -
s.EgressSelector.ApplyTo(genericConfig)
ApplyTo adds the egress selector settings to the server configuration. -
storageFactoryConfig := kubeapiserver.NewStorageFactoryConfig()
NewStorageFactoryConfig returns a new StorageFactoryConfig set up with necessary resource overrides. -
completedStorageFactoryConfig, err := storageFactoryConfig.Complete(s.Etcd)
Complete completes the StorageFactoryConfig with provided etcdOptions returning completedStorageFactoryConfig. -
storageFactory, lastErr = completedStorageFactoryConfig.New()
New returns a new storage factory created from the completed storage factory configuration. -
s.Etcd.ApplyWithStorageFactoryTo(storageFactory, genericConfig)
初始化缓存工程函数 -
clientgoExternalClient, err := clientgoclientset.NewForConfig(kubeClientConfig)
NewForConfig creates a new Clientset for the given config. -
versionedInformers = clientgoinformers.NewSharedInformerFactory(clientgoExternalClient, 10*time.Minute)
NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
-
-
capabilities.Initialize
Initialize the capability set. This can only be done once per binary, subsequent calls are ignored. -
controlplane.Config
控制面板定义
-
-
CreateKubeAPIServer
Complete
New
returns a new instance of MasterGenericAPIServer
from the given config.s, err := c.GenericConfig.New("kube-apiserver", delegationTarget)
installAPI(s, c.Config)
-
delegationTarget DelegationTarget
vendor/k8s.io/apiserver/pkg/server/genericapiserver.go
的入参 -
c.ExtraConfig.APIResourceConfigSource.VersionEnabled(apiv1.SchemeGroupVersion)
install legacy rest storage -
m.InstallLegacyAPI(&c, c.GenericConfig.RESTOptionsGetter, legacyRESTStorageProvider)
InstallLegacyAPI will install the legacy APIs for the restStorageProviders if they are enabled.legacyRESTStorage, apiGroupInfo, err := legacyRESTStorageProvider.NewLegacyRESTStorage(restOptionsGetter)
-
cacher, err := cacherstorage.NewCacherFromConfig(cacherConfig)
watch缓存
-
网友评论