Skip to content

Commit

Permalink
add QPS and Burst to config
Browse files Browse the repository at this point in the history
  • Loading branch information
simonycj committed Nov 15, 2024
1 parent 3fbecd6 commit 3ea28b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
24 changes: 18 additions & 6 deletions cmd/core-api-server/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -74,6 +82,10 @@ func DefaultConfig() *Config {
TokenKeyInRequest: "X-Auth-Token",
},
},
KubeConfig: &KubeConfig{
QPS: 100,
Burst: 200,
},
CoreApiConfig: &CoreApiConfig{
Port: "8080",
LogLevel: "info",
Expand Down
10 changes: 8 additions & 2 deletions cmd/core-api-server/app/option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 3ea28b4

Please sign in to comment.