本篇内容介绍了“构建API Server的详细步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!API Server利用GenericAPIServer框架依次创建了api_extension_serverapi_serveraggregator_server来处理所有请求,server构建的核心逻辑如下:func CreateServerChain(runOptions *options.ServerRunOptions, stopCh
// api server的config结构
kubeAPIServerConfig, sharedInformers, versionedInformers, insecureServingOptions, serviceResolver, err := CreateKubeAPIServerConfig(runOptions, nodeTunneler, proxyTransport)
if
err != nil {
return
nil, err
}
// extension server的config结构
apiExtensionsConfig, err := createAPIExtensionsConfig(*kubeAPIServerConfig.GenericConfig, versionedInformers, runOptions)
if
err != nil {
return
nil, err
}
// 1. 创建api extensions server
apiExtensionsServer, err := createAPIExtensionsServer(apiExtensionsConfig, genericapiserver.EmptyDelegate)
if
err != nil {
return
nil, err
}
// 2. 创建api server,delegate到extensions server上(注意,第二个参数)
kubeAPIServer, err := CreateKubeAPIServer(kubeAPIServerConfig, apiExtensionsServer.GenericAPIServer, sharedInformers, versionedInformers)
if
err != nil {
return
nil, err
}
.....
// otherwise go down the normal path of standing the aggregator up in front of the API server
// this wires up openapi
kubeAPIServer.GenericAPIServer.PrepareRun()
// This will wire up openapi for extension api server
apiExtensionsServer.GenericAPIServer.PrepareRun()
....
// 3. 创建aggregator server, delegate到api server上
aggregatorServer, err := createAggregatorServer(aggregatorConfig, kubeAPIServer.GenericAPIServer, apiExtensionsServer.Informers)
if
err != nil {
// we don't need special handling for innerStopCh because the aggregator server doesn't create any go routines
return
nil, err
}
....
return
aggregatorServer.GenericAPIServer, nil
}
当中,三个server创建的过程大体类似。以下是API Server创建方法CreateKubeAPIServer的核心逻辑:func CreateKubeAPIServer(kubeAPIServerConfig *master.Config, delegateAPIServer genericapiserver.DelegationTarget, sharedInformers informers.SharedInformerFactory, versionedInformers clientgoinformers.SharedInformerFactory) (*master.Master, error) {
kubeAPIServer, err := kubeAPIServerConfig.Complete(versionedInformers).New(delegateAPIServer)
if
err != nil {
return
nil, err
}
kubeAPIServer.GenericAPIServer.AddPostStartHook(
"start-kube-apiserver-informers"
, func(context genericapiserver.PostStartHookContext) error {
sharedInformers.Start(context.Stop开发云主机域名Ch)
return
nil
})
return
kubeAPIServer, nil
}
// kubeAPIServerConfig.Complete(versionedInformers).New(delegateAPIServer)中的New方法如下所示:
func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget) (*Master, error) {
...
// 通过Config创建APIServer对应的GenericAPIServer对象
s, err := c.GenericConfig.New(
"kube-apiserver"
, delegationTarget)
if
err != nil {
return
nil, err
}
....
m := &Master{
GenericAPIServer: s,
}
// 将所有REST资源(Pods/Deployments)的Storage接口实现类都install到master内含的GenericAPIServer上
restStorageProviders := []RESTStorageProvider{
authenticationrest.RESTStorageProvider{Authenticator: c.GenericConfig.Authenticator},
authorizationrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorizer, RuleResolver: c.GenericConfig.RuleResolver},
autoscalingrest.RESTStorageProvider{},
batchrest.RESTStorageProvider{},
certificatesrest.RESTStorageProvider{},
extensionsrest.RESTStorageProvider{},
networkingrest.RESTStorageProvider{},
policyrest.RESTStorageProvider{},
rbacrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorizer},
schedulingrest.RESTStorageProvider{},
settingsrest.RESTStorageProvider{},
storagerest.RESTStorageProvider{},
// keep apps after extensions so legacy clients resolve the extensions versions of shared resource names.
// Seehttps://github.com/kubernetes/kubernetes/issues/42392
appsrest.RESTStorageProvider{},
admissionregistrationrest.RESTStorageProvider{},
}
m.InstallAPIs(c.ExtraConfig.APIResourceConfigSource, c.GenericConfig.RESTOptionsGetter, restStorageProviders...)
...
return
m, nil
}
经过以上几个步骤,API Server就完成了所有资源的install,可以开始监听并响应请求。“构建API Server的详细步骤”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注开发云网站,小编将为大家输出更多高质量的实用文章!
本篇文章为大家展示了云虚拟主机价格是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。云虚拟主机的价格一般是指某一配置包年包月或者按量计费的费用。不同品牌不同配置的云虚拟主机价格相差较大。大家在购买时,要注意做下准备工…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。