In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how to use K8S source code analysis of GenericAPIServer, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.
APIServer provides RESTful interface, and GenericAPIServer structure mainly solves the problem of URI routing, that is, mapping URI to corresponding processing logic. GenericAPIServer can be understood as a miniature mvc framework, which is the skeleton of the entire APIServer.
The GenericAPIServer-related code is under / staging/src/k8s.io/apiserver/pkg (I don't quite understand why it's in the / staging directory, not directly under / pkg).
Core structure
The three most critical structures are simply explained as follows:
Config related-Construction configuration class. Through Config.Complete (...) Method to get an instance of CompletedConfig, and then call the New () method on the latter to get an instance pointer of GenericAPIServer
GenericAPIServer & Handler-GenericAPIServer itself includes all the parameters related to http server, the most important of which is Handler field, which is used to actually handle business logic
Handler is a pointer to APIServerHandler. The APIServerHandler structure provides the ServeHTTP () method, which can be provided directly to the http.Server class to generate http service.
The FullHandlerChain structure in APIServerHandler is the final assembled http.Handler and is the entrance to all handle logic.
The access paths of all internal resources (Pods/Deployments) are registered in the GoRestfulContainer structure, and external access methods (such as accessing node through the proxy function of API Server) are registered in NonGoRestMux
Director is an internal Dispatcher that performs routing between GoRestfulContainer and NonGoRestfulMux
API Group-similar to the RequestMapping structure in spring mvc, it represents a URI resource path. As long as each internal resource (such as Pods/Deployments) implements a series of interfaces such as rest.Storage, it can be exposed on GenericAPIServer by constructing APIGroupInfo.
To sum up, the exposure of the http interface can be achieved by creating and initializing the GenericAPIServer through the Config structure and putting the APIGroupInfo install on the GenericAPIServer.
Initialization process
The DefaultHandlerChain function is called during the APIServerHandler build process to add the default processing handler.
The above is how to use K8S source code to analyze GenericAPIServer, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.