Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Gateway refactoring #393

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions cmd/plugins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"time"

"google.golang.org/grpc"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -73,12 +72,6 @@ func main() {

cache.NewCache(config, stopCh, redisClient)

// Connect to K8s cluster
k8sClient, err := kubernetes.NewForConfig(config)
if err != nil {
klog.Fatalf("Error creating kubernetes client: %v", err)
}

// grpc server init
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", grpc_port))
if err != nil {
Expand All @@ -87,7 +80,7 @@ func main() {

s := grpc.NewServer()

extProcPb.RegisterExternalProcessorServer(s, gateway.NewServer(redisClient, k8sClient))
extProcPb.RegisterExternalProcessorServer(s, gateway.NewServer(redisClient))
healthPb.RegisterHealthServer(s, &gateway.HealthServer{})

klog.Info("starting gRPC server on port :50052")
Expand Down
4 changes: 2 additions & 2 deletions docs/development/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
MODEL_NAME = 'llama2-70b'
DEPLOYMENT_NAME = os.getenv('DEPLOYMENT_NAME', 'llama2-70b')
NAMESPACE = os.getenv('NAMESPACE', 'aibrix-system')
DEFAULT_REPLICAS = int(os.getenv('DEFAULT_REPLICAS', '1'))
DEFAULT_REPLICAS = int(os.getenv('DEFAULT_REPLICAS', '3'))

models = [
{
Expand Down Expand Up @@ -193,7 +193,7 @@ def metrics():
resp = apps_v1.read_namespaced_deployment(DEPLOYMENT_NAME, NAMESPACE)
replicas = resp.spec.replicas if resp.spec.replicas is not None else 1
except Exception as e:
print(f"Failed to get deployment information: {DEPLOYMENT_NAME=} {NAMESPACE=} {e=}, set replicas to {DEFAULT_REPLICAS}")
# print(f"Failed to get deployment information: {DEPLOYMENT_NAME=} {NAMESPACE=} {e=}, set replicas to {DEFAULT_REPLICAS}")
replicas = DEFAULT_REPLICAS

# a reasonable mock total value
Expand Down
3 changes: 1 addition & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,12 @@ func NewCache(config *rest.Config, stopCh <-chan struct{}, redisClient *redis.Cl
panic(err)
}

ticker := time.NewTicker(podMetricRefreshIntervalInMilliseconds * time.Millisecond)
ticker := time.NewTicker(podMetricRefreshIntervalInMilliseconds)
go func() {
for {
select {
case <-ticker.C:
instance.updatePodMetrics()
instance.debugInfo()
case <-stopCh:
ticker.Stop()
return
Expand Down
Loading
Loading