kubernetes apiserver源码: 配置结构

86 阅读1分钟
  • APIExtensionServer
type Config struct {
        // GenericConfig 包含 APIServer 和 APIExtensionServer 公用的一些配置
	GenericConfig *genericapiserver.RecommendedConfig 
        // APIExtensionServer 特殊的配置
	ExtraConfig   ExtraConfig
}

  • APIServer
// Config defines configuration for the master
type Config struct {
        // GenericConfig 包含 APIServer 和 APIExtensionServer 公用的一些配置
	GenericConfig *genericapiserver.Config
        //  APIServer 特殊的配置
	ExtraConfig   ExtraConfig
}

注意,ExtraConfig在各自的包里有不同的定义,GenericConfig用的都是apiserver包里的定义。

GenericConfig

通用的配置里有哪些东西呢?

认证,授权这些配置,很明显是都需要的。

// Config is a structure used to configure a GenericAPIServer.
// Its members are sorted roughly in order of importance for composers.
type Config struct {
	// SecureServing is required to serve https
	SecureServing *SecureServingInfo

	// Authentication is the configuration for authentication
	Authentication AuthenticationInfo

	// Authorization is the configuration for authorization
	Authorization AuthorizationInfo
        
        // ...
}        

ExtraConfig

APIServer


// ExtraConfig defines extra configuration for the master
type ExtraConfig struct {
	ClusterAuthenticationInfo clusterauthenticationtrust.ClusterAuthenticationInfo
        
        // etcd 配置
	APIResourceConfigSource  serverstorage.APIResourceConfigSource
	StorageFactory           serverstorage.StorageFactory

	// Values to build the IP addresses used by discovery
	// The range of IPs to be assigned to services with type=ClusterIP or greater
	ServiceIPRange net.IPNet
            
        // NodePort的端口范围
	// The range of ports to be assigned to services with type=NodePort or greater
	ServiceNodePortRange utilnet.PortRange
        
        // ...

}

APIExtensionServer

这些配置好像不太重要,之后再细作研究

type ExtraConfig struct {
        // etcd 相关配置
	CRDRESTOptionsGetter genericregistry.RESTOptionsGetter

	// MasterCount is used to detect whether cluster is HA, and if it is
	// the CRD Establishing will be hold by 5 seconds.
	MasterCount int

	// ServiceResolver is used in CR webhook converters to resolve webhook's service names
	ServiceResolver webhook.ServiceResolver
	// AuthResolverWrapper is used in CR webhook converters
	AuthResolverWrapper webhook.AuthenticationInfoResolverWrapper
}