diff --git a/cmd/core-api-server/app/config/config.go b/cmd/core-api-server/app/config/config.go index 4fae562..a03d0f8 100644 --- a/cmd/core-api-server/app/config/config.go +++ b/cmd/core-api-server/app/config/config.go @@ -7,16 +7,24 @@ import ( ) type Config struct { - AuthConfig *AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty"` - KubeConfig *KubeConfig `json:"kube_config,omitempty" yaml:"kubeConfig,omitempty"` - CoreApiConfig *CoreApiConfig `json:"core_api,omitempty" yaml:"coreApi,omitempty"` - RayLLM *RayLLM `json:"ray_llm,omitempty" yaml:"rayLLM,omitempty"` - Rag *Rag `json:"rag,omitempty" yaml:"rag,omitempty"` - XInference *XInference `json:"x_inference,omitempty" yaml:"xInference,omitempty"` + AuthConfig *AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty"` + KubeConfig *KubeConfig `json:"kube_config,omitempty" yaml:"kubeConfig,omitempty"` + KubeClientConfig *KubeClientConfig `json:"kube_client_config,omitempty" yaml:"kubeClientConfig,omitempty"` + CoreApiConfig *CoreApiConfig `json:"core_api,omitempty" yaml:"coreApi,omitempty"` + RayLLM *RayLLM `json:"ray_llm,omitempty" yaml:"rayLLM,omitempty"` + Rag *Rag `json:"rag,omitempty" yaml:"rag,omitempty"` + XInference *XInference `json:"x_inference,omitempty" yaml:"xInference,omitempty"` +} + +type KubeClientConfig struct { + QPS float32 `json:"qps,omitempty" yaml:"qps,omitempty"` + Burst int `json:"burst,omitempty" yaml:"burst,omitempty"` } type KubeConfig struct { RestConfig *rest.Config + QPS float32 `json:"qps,omitempty" yaml:"qps,omitempty"` + Burst int `json:"burst,omitempty" yaml:"burst,omitempty"` } type CoreApiConfig struct { @@ -74,6 +82,10 @@ func DefaultConfig() *Config { TokenKeyInRequest: "X-Auth-Token", }, }, + KubeConfig: &KubeConfig{ + QPS: 100, + Burst: 200, + }, CoreApiConfig: &CoreApiConfig{ Port: "8080", LogLevel: "info", diff --git a/cmd/core-api-server/app/option/option.go b/cmd/core-api-server/app/option/option.go index 39b3ca5..0c48fb2 100644 --- a/cmd/core-api-server/app/option/option.go +++ b/cmd/core-api-server/app/option/option.go @@ -54,7 +54,7 @@ func (opt *Option) GenerateConfig(loadKubeConfig bool) (*config.Config, error) { } if !opt.DoNotInitK8sInClusterConfig { - restConfig, err := BuildKubeConfig() + restConfig, err := BuildKubeConfig(serverConfig.KubeClientConfig) if err != nil { return nil, err } @@ -72,7 +72,7 @@ func CheckCoreApiConfig(config *config.Config) error { return nil } -func BuildKubeConfig() (*rest.Config, error) { +func BuildKubeConfig(clientConfig *config.KubeClientConfig) (*rest.Config, error) { // note for now we only support in-cluster config for following reasons: // 1. we are running in k8s cluster // 2. we are using service account to access k8s api server @@ -83,6 +83,12 @@ func BuildKubeConfig() (*rest.Config, error) { return config, err } + // set QPS and Burst + if clientConfig != nil { + config.QPS = clientConfig.QPS + config.Burst = clientConfig.Burst + } + // now we should read ca.crt for our purpose caCert, err := os.ReadFile(config.CAFile) if err != nil {