-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathgke.yaml
More file actions
164 lines (164 loc) · 5.36 KB
/
Copy pathgke.yaml
File metadata and controls
164 lines (164 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{{- if eq (lower .Values.provider.name) "gke" }}
---
kind: HealthCheckPolicy
apiVersion: networking.gke.io/v1
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "llm-d-router.labels" . | nindent 4 }}
spec:
targetRef:
group: inference.networking.k8s.io
kind: InferencePool
name: {{ .Release.Name }}
default:
# Set a more aggressive health check than the default 5s for faster switch
# over during EPP rollout.
timeoutSec: 2
checkIntervalSec: 2
{{- $port := .Values.router.modelServers.targetPortNumber }}
{{- if .Values.router.modelServers.targetPorts }}
{{- $port = (index .Values.router.modelServers.targetPorts 0).number }}
{{- end }}
{{- if eq .Values.router.modelServers.protocol "http" }}
config:
type: HTTP
httpHealthCheck:
requestPath: /health
port: {{ $port }}
{{- else if and (eq (lower .Values.router.modelServers.type) "vllm") (eq .Values.router.modelServers.protocol "grpc") }}
config:
type: GRPC
grpcHealthCheck:
portSpecification: "USE_FIXED_PORT"
port: {{ $port }}
grpcServiceName: "/vllm.grpc.engine.VllmEngine/HealthCheck"
{{- end }}
{{- $eppHealthPort := int (.Values.router.epp.grpcHealthPort | default 9003) }}
{{- /* The GKE gateway controller health-checks the EPP backend on gRPC port
9003 by default, so an explicit HealthCheckPolicy is only needed for other ports. */}}
{{- if ne $eppHealthPort 9003 }}
---
kind: HealthCheckPolicy
apiVersion: networking.gke.io/v1
metadata:
name: {{ .Release.Name }}-epp
namespace: {{ .Release.Namespace }}
labels:
{{- include "llm-d-router.labels" . | nindent 4 }}
spec:
targetRef:
group: ""
kind: Service
name: {{ include "llm-d-router.name" . }}
default:
config:
type: GRPC
grpcHealthCheck:
portSpecification: "USE_FIXED_PORT"
port: {{ $eppHealthPort }}
{{- end }}
{{- $gkePB := include "llm-d-router.gkePreferredBackends" . | fromYaml | default dict }}
{{- if $gkePB.enabled }}
{{- $preferredReplicas := $gkePB.preferredReplicas | default 1 | int }}
{{- $defaultReplicas := $gkePB.defaultReplicas | default 1 | int }}
{{- $totalReplicas := add $preferredReplicas $defaultReplicas }}
{{- range $i := untilStep 1 (int $totalReplicas) 1 }}
{{- $serviceName := printf "%s-preferred-%d" (include "llm-d-router.name" $) (int $i) }}
{{- if ge (int $i) (int $preferredReplicas) }}
{{- if eq (int $i) (int $preferredReplicas) }}
{{- $serviceName = printf "%s-backup" (include "llm-d-router.name" $) }}
{{- else }}
{{- $serviceName = printf "%s-backup-%d" (include "llm-d-router.name" $) (sub (int $i) (int $preferredReplicas)) }}
{{- end }}
{{- end }}
---
kind: HealthCheckPolicy
apiVersion: networking.gke.io/v1
metadata:
name: {{ $serviceName }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "llm-d-router.labels" $ | nindent 4 }}
spec:
targetRef:
group: ""
kind: Service
name: {{ $serviceName }}
default:
config:
type: GRPC
grpcHealthCheck:
portSpecification: "USE_FIXED_PORT"
port: {{ $eppHealthPort }}
{{- end }}
{{- end }}
---
{{- if not $gkePB.enabled }}
apiVersion: networking.gke.io/v1
kind: GCPBackendPolicy
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "llm-d-router.labels" . | nindent 4 }}
spec:
targetRef:
group: inference.networking.k8s.io
kind: InferencePool
name: {{ .Release.Name }}
default:
timeoutSec: 300 # 5-minute timeout (adjust as needed)
logging:
enabled: true # log all requests by default
---
{{- end }}
{{- if $gkePB.enabled }}
{{- $preferredReplicas := $gkePB.preferredReplicas | default 1 | int }}
{{- $defaultReplicas := $gkePB.defaultReplicas | default 1 | int }}
{{- $totalReplicas := add $preferredReplicas $defaultReplicas }}
{{- range $i := untilStep 0 (int $totalReplicas) 1 }}
{{- $serviceName := printf "%s-preferred-%d" (include "llm-d-router.name" $) (int $i) }}
{{- $policyName := printf "%s-preferred-%d" $.Release.Name (int $i) }}
{{- $pref := "PREFERRED" }}
{{- if eq (int $i) 0 }}
{{- $serviceName = include "llm-d-router.name" $ }}
{{- $policyName = $.Release.Name }}
{{- else if ge (int $i) (int $preferredReplicas) }}
{{- $pref = "DEFAULT" }}
{{- if eq (int $i) (int $preferredReplicas) }}
{{- $serviceName = printf "%s-backup" (include "llm-d-router.name" $) }}
{{- $policyName = printf "%s-backup" $.Release.Name }}
{{- else }}
{{- $serviceName = printf "%s-backup-%d" (include "llm-d-router.name" $) (sub (int $i) (int $preferredReplicas)) }}
{{- $policyName = printf "%s-backup-%d" $.Release.Name (sub (int $i) (int $preferredReplicas)) }}
{{- end }}
{{- end }}
apiVersion: networking.gke.io/v1
kind: GCPBackendPolicy
metadata:
name: {{ $policyName }}
namespace: {{ $.Release.Namespace }}
spec:
targetRef:
group: ""
kind: Service
name: {{ $serviceName }}
default:
timeoutSec: 300
backendPreference: {{ $pref }}
{{- if $gkePB.balancingMode }}
balancingMode: {{ $gkePB.balancingMode }}
{{- end }}
{{- if $gkePB.maxRatePerEndpoint }}
maxRatePerEndpoint: {{ $gkePB.maxRatePerEndpoint }}
{{- end }}
{{- if $gkePB.capacityScalerPercent }}
capacityScalerPercent: {{ $gkePB.capacityScalerPercent }}
{{- end }}
---
{{- end }}
{{- end }}
{{- include "llm-d-router.gke" . -}}
{{- end }}