构建API Server的详细步骤


本篇内容介绍了“构建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)iferr != nil {returnnil, err}// extension server的config结构apiExtensionsConfig, err := createAPIExtensionsConfig(*kubeAPIServerConfig.GenericConfig, versionedInformers, runOptions)iferr != nil {returnnil, err}// 1. 创建api extensions serverapiExtensionsServer, err := createAPIExtensionsServer(apiExtensionsConfig, genericapiserver.EmptyDelegate)iferr != nil {returnnil, err}// 2. 创建api server,delegate到extensions server上(注意,第二个参数)kubeAPIServer, err := CreateKubeAPIServer(kubeAPIServerConfig, apiExtensionsServer.GenericAPIServer, sharedInformers, versionedInformers)iferr != nil {returnnil, err}.....// otherwise go down the normal path of standing the aggregator up in front of the API server// this wires up openapikubeAPIServer.GenericAPIServer.PrepareRun()// This will wire up openapi for extension api serverapiExtensionsServer.GenericAPIServer.PrepareRun()....// 3. 创建aggregator server, delegate到api server上aggregatorServer, err := createAggregatorServer(aggregatorConfig, kubeAPIServer.GenericAPIServer, apiExtensionsServer.Informers)iferr != nil {// we don't need special handling for innerStopCh because the aggregator server doesn't create any go routinesreturnnil, err}....returnaggregatorServer.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)iferr != nil {returnnil, err}kubeAPIServer.GenericAPIServer.AddPostStartHook("start-kube-apiserver-informers", func(context genericapiserver.PostStartHookContext) error {sharedInformers.Start(context.Stop开发云主机域名Ch)returnnil})returnkubeAPIServer, 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)iferr != nil {returnnil, 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/42392appsrest.RESTStorageProvider{},admissionregistrationrest.RESTStorageProvider{},}m.InstallAPIs(c.ExtraConfig.APIResourceConfigSource, c.GenericConfig.RESTOptionsGetter, restStorageProviders...)...returnm, nil}经过以上几个步骤,API Server就完成了所有资源的install,可以开始监听并响应请求。“构建API Server的详细步骤”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注开发云网站,小编将为大家输出更多高质量的实用文章!

相关推荐: 云虚拟主机价格是什么

本篇文章为大家展示了云虚拟主机价格是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。云虚拟主机的价格一般是指某一配置包年包月或者按量计费的费用。不同品牌不同配置的云虚拟主机价格相差较大。大家在购买时,要注意做下准备工…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

Like (0)
Donate 微信扫一扫 微信扫一扫
Previous 05/21 11:46
Next 05/21 11:46

相关推荐