Skip to content

Commit b66c80c

Browse files
authored
[Minor Improvements] Vllmruntime Autoscaling in Operator
Signed-off-by: aeon-x <talexcao@gmail.com>
1 parent cbab543 commit b66c80c

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

operator/api/v1alpha1/vllmruntime_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ type VLLMRuntimeStatus struct {
328328
// Current replica count (used by scale subresource)
329329
Replicas int32 `json:"replicas,omitempty"`
330330

331+
// Number of pods that are ready and serving traffic
332+
AvailableReplicas int32 `json:"availableReplicas,omitempty"`
333+
334+
// Number of pods running the latest pod template
335+
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
336+
337+
// Number of pods that are not yet available
338+
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`
339+
331340
// Label selector for pods (used by scale subresource for HPA AverageValue)
332341
Selector string `json:"selector,omitempty"`
333342
}

operator/config/crd/bases/production-stack.vllm.ai_vllmruntimes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ spec:
546546
status:
547547
description: VLLMRuntimeStatus defines the observed state of VLLMRuntime
548548
properties:
549+
availableReplicas:
550+
description: Number of pods that are ready and serving traffic
551+
format: int32
552+
type: integer
549553
lastUpdated:
550554
description: Last updated timestamp
551555
format: date-time
@@ -561,6 +565,14 @@ spec:
561565
description: Label selector for pods (used by scale subresource for
562566
HPA AverageValue)
563567
type: string
568+
unavailableReplicas:
569+
description: Number of pods that are not yet available
570+
format: int32
571+
type: integer
572+
updatedReplicas:
573+
description: Number of pods running the latest pod template
574+
format: int32
575+
type: integer
564576
type: object
565577
type: object
566578
served: true

operator/internal/controller/vllmruntime_controller.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"maps"
2323
"reflect"
24+
"strings"
2425

2526
appsv1 "k8s.io/api/apps/v1"
2627
corev1 "k8s.io/api/core/v1"
@@ -1066,6 +1067,11 @@ func (r *VLLMRuntimeReconciler) updateStatus(
10661067
latestVR.Status.Replicas = dep.Status.Replicas
10671068
latestVR.Status.Selector = metav1.FormatLabelSelector(dep.Spec.Selector)
10681069

1070+
// Expose additional deployment status fields
1071+
latestVR.Status.AvailableReplicas = dep.Status.AvailableReplicas
1072+
latestVR.Status.UpdatedReplicas = dep.Status.UpdatedReplicas
1073+
latestVR.Status.UnavailableReplicas = dep.Status.UnavailableReplicas
1074+
10691075
return r.Status().Update(ctx, latestVR)
10701076
})
10711077
}
@@ -1089,6 +1095,13 @@ func (r *VLLMRuntimeReconciler) reconcileScaledObject(
10891095

10901096
prometheusAddr := cfg.Triggers.PrometheusAddress
10911097
servedModelName := vllmRuntime.Spec.Model.ModelURL
1098+
// Check extraArgs for --served-model-name override
1099+
for _, arg := range vllmRuntime.Spec.VLLMConfig.ExtraArgs {
1100+
if strings.HasPrefix(arg, "--served-model-name=") {
1101+
servedModelName = strings.TrimPrefix(arg, "--served-model-name=")
1102+
break
1103+
}
1104+
}
10921105

10931106
spec := map[string]interface{}{
10941107
"scaleTargetRef": map[string]interface{}{
@@ -1125,7 +1138,7 @@ func (r *VLLMRuntimeReconciler) reconcileScaledObject(
11251138
"metadata": map[string]string{
11261139
"serverAddress": prometheusAddr,
11271140
"metricName": "vllm_incoming_keepalive",
1128-
"query": fmt.Sprintf(`sum(rate(vllm:num_incoming_requests_total{namespace="%s", model="%s"}[1m]) > bool 0)`, vllmRuntime.Namespace, servedModelName),
1141+
"query": fmt.Sprintf(`sum(rate(vllm:num_incoming_requests_total{namespace="%s", model="%s"}[2m]) > bool 0)`, vllmRuntime.Namespace, servedModelName),
11291142
"threshold": "1",
11301143
},
11311144
},

0 commit comments

Comments
 (0)