-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy path_deployment.yaml
More file actions
323 lines (323 loc) · 12.6 KB
/
Copy path_deployment.yaml
File metadata and controls
323 lines (323 loc) · 12.6 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
{{- define "llm-d-epp.deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "llm-d-router.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "llm-d-router.labels" . | nindent 4 }}
{{- include "llm-d-router.modeLabels" . | nindent 4 }}
spec:
replicas: {{ .Values.router.epp.replicas | default 1 }}
strategy:
# The current recommended EPP deployment pattern is to have a single active replica. This ensures
# optimal performance of the stateful operations such prefix cache aware scorer.
# The Recreate strategy the old replica is killed immediately, and allow the new replica(s) to
# quickly take over. This is particularly important in the high availability set up with leader
# election, as the rolling update strategy would prevent the old leader being killed because
# otherwise the maxUnavailable would be 100%.
type: Recreate
selector:
matchLabels:
{{- include "llm-d-router.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "llm-d-router.selectorLabels" . | nindent 8 }}
{{- include "llm-d-router.modeLabels" . | nindent 8 }}
{{- with .Values.router.epp.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- $proxy := include "llm-d-router.proxy" . | fromYaml | default dict }}
{{- $proxyType := include "llm-d-router.proxyType" . | trim }}
{{- $proxyMode := include "llm-d-router.proxyMode" . | trim }}
{{- $proxySidecar := and $proxy.enabled (eq $proxyMode "sidecar") }}
{{- $proxyConfigMap := index $proxy "configMap" | default dict }}
{{- $proxyConfigMapName := index $proxyConfigMap "name" | default "" }}
{{- $eppFlags := deepCopy (.Values.router.epp.flags | default dict) }}
{{- if and (eq $proxyType "agentgateway") (not (hasKey $eppFlags "secure-serving")) }}
{{- $_ := set $eppFlags "secure-serving" false }}
{{- end }}
serviceAccountName: {{ include "llm-d-router.name" . }}
# Conservatively, this timeout should mirror the longest grace period of the pods within the pool
terminationGracePeriodSeconds: 130
{{- if and .Values.router.tokenizer.enabled .Values.router.tokenizer.initContainers }}
initContainers:
{{- toYaml .Values.router.tokenizer.initContainers | nindent 8 }}
{{- end }}
containers:
{{- if $proxySidecar }}
- name: {{ $proxy.name }}
image: {{ $proxy.image }}
imagePullPolicy: {{ $proxy.imagePullPolicy | default "IfNotPresent" }}
{{- with $proxy.command }}
command:
- {{ . | quote }}
{{- end }}
{{- with $proxy.args }}
args:
{{- range . }}
- {{ . | quote }}
{{- end }}
{{- end }}
{{- with $proxy.env }}
env:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with $proxy.ports }}
ports:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with $proxy.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $proxy.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $proxy.startupProbe }}
startupProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $proxy.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $proxy.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or (and (eq $proxyType "agentgateway") $proxyConfigMapName) $proxy.volumeMounts }}
volumeMounts:
{{- if and (eq $proxyType "agentgateway") $proxyConfigMapName }}
- name: agentgateway-config-template
mountPath: /config
readOnly: true
{{- end }}
{{- with $proxy.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
- name: epp
image: {{ .Values.router.epp.image.registry }}/{{ .Values.router.epp.image.repository }}:{{ .Values.router.epp.image.tag }}
imagePullPolicy: {{ .Values.router.epp.image.pullPolicy | default "IfNotPresent" }}
args:
{{- /* 1. Determine Mode Logic */ -}}
{{- $useInferencePool := ne .Values.router.inferencePool.create false }}
{{- /* 2. Determine Model Server Type */ -}}
{{- $modelServerType := .Values.router.modelServers.type | default "vllm" }}
{{- /* 3. Mode Specific Flags */ -}}
{{- if not $useInferencePool }}
- --endpoint-selector
{{- $selector := "" }}
{{- if and .Values.router.modelServers .Values.router.modelServers.matchLabels }}
{{- $labels := list }}
{{- range $k, $v := .Values.router.modelServers.matchLabels }}
{{- $labels = append $labels (printf "%s=%s" $k $v) }}
{{- end }}
{{- $selector = join "," $labels }}
{{- end }}
- {{ $selector | quote }}
- --endpoint-target-ports
- {{ include "llm-d-router.standaloneEndpointTargetPorts" . | quote }}
{{- else }}
- --pool-name
- {{ .Release.Name }}
# The pool namespace is optional because EPP can default to the NAMESPACE env var.
- --pool-namespace
- {{ .Release.Namespace }}
- --pool-group
- "inference.networking.k8s.io"
{{- end }}
- --zap-encoder
- "json"
- --config-file
- "/config/{{ .Values.router.epp.pluginsConfigFile }}"
{{- if gt (.Values.router.epp.replicas | int) 1 }}
- --ha-enable-leader-election
{{- end }}
{{- $grpcHealthPort := .Values.router.epp.grpcHealthPort | default 9003 }}
- --grpc-health-port
- "{{ $grpcHealthPort }}"
# Pass additional flags via the router.epp.flags field in values.yaml.
# Render them as --flag=value so boolean values are parsed correctly.
{{- range $key, $value := $eppFlags }}
- {{ printf "--%s=%v" $key $value | quote }}
{{- end }}
{{- if .Values.router.tracing.enabled }}
- --tracing=true
{{- else }}
- --tracing=false
{{- end }}
{{- if not .Values.router.monitoring.prometheus.auth.enabled }}
- --metrics-endpoint-auth=false
{{- end }}
{{- with .Values.router.epp.resources }}
resources:
{{ toYaml . | nindent 12 }}
{{- end }}
ports:
- name: grpc
containerPort: 9002
- name: grpc-health
containerPort: {{ $grpcHealthPort }}
- name: metrics
containerPort: 9090
{{- if .Values.router.epp.extraContainerPorts }}
{{- toYaml .Values.router.epp.extraContainerPorts | nindent 12 }}
{{- end }}
livenessProbe:
{{- if gt (.Values.router.epp.replicas | int) 1 }}
grpc:
port: {{ $grpcHealthPort }}
service: liveness
{{- else }}
grpc:
port: {{ $grpcHealthPort }}
service: inference-extension
{{- end }}
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
{{- if gt (.Values.router.epp.replicas | int) 1 }}
grpc:
port: {{ $grpcHealthPort }}
service: readiness
{{- else }}
grpc:
port: {{ $grpcHealthPort }}
service: inference-extension
{{- end }}
periodSeconds: 2
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- include "llm-d-router.latencyPredictor.env" . | nindent 12 }}
{{- if .Values.router.tracing.enabled }}
- name: OTEL_SERVICE_NAME
value: "llm-d-router/epp"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: {{ .Values.router.tracing.otelExporterEndpoint | quote }}
- name: OTEL_TRACES_EXPORTER
value: "otlp"
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: OTEL_RESOURCE_ATTRIBUTES
value: 'k8s.namespace.name=$(NAMESPACE),k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)'
- name: OTEL_TRACES_SAMPLER
value: {{ .Values.router.tracing.sampling.sampler | quote }}
- name: OTEL_TRACES_SAMPLER_ARG
value: {{ .Values.router.tracing.sampling.samplerArg | quote }}
{{- end }}
{{- if .Values.router.epp.env }}
{{- toYaml .Values.router.epp.env | nindent 12 }}
{{- end }}
volumeMounts:
- name: plugins-config-volume
mountPath: "/config"
{{- if .Values.router.epp.volumeMounts }}
{{- toYaml .Values.router.epp.volumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.router.tokenizer.enabled }}
{{- $tokenizer := .Values.router.tokenizer }}
{{- $renderPort := $tokenizer.port | default 8000 | int }}
- name: vllm-render
image: {{ $tokenizer.image.registry }}/{{ $tokenizer.image.repository }}:{{ $tokenizer.image.tag }}
imagePullPolicy: {{ $tokenizer.image.pullPolicy | default "IfNotPresent" }}
command:
{{- if $tokenizer.command }}
{{- toYaml $tokenizer.command | nindent 12 }}
{{- else }}
- vllm
- launch
- render
{{- end }}
args:
{{- if $tokenizer.args }}
{{- toYaml $tokenizer.args | nindent 12 }}
{{- else }}
- {{ $tokenizer.modelName | quote }}
- {{ printf "--port=%d" $renderPort | quote }}
{{- end }}
{{- with $tokenizer.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: render-http
containerPort: {{ $renderPort }}
{{- with $tokenizer.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $tokenizer.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $tokenizer.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /root/.cache/huggingface
name: model-cache
{{- with $tokenizer.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- include "llm-d-router.latencyPredictor.containers" . | nindent 8 }}
volumes:
{{- if .Values.router.epp.volumes }}
{{- toYaml .Values.router.epp.volumes | nindent 8 }}
{{- end }}
{{- if .Values.router.tokenizer.enabled }}
- name: model-cache
emptyDir: {}
{{- with .Values.router.tokenizer.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if and $proxySidecar (eq $proxyType "agentgateway") $proxyConfigMapName }}
- name: agentgateway-config-template
configMap:
name: {{ $proxyConfigMapName }}
items:
- key: config.yaml
path: config.yaml
{{- end }}
{{- if $proxySidecar }}
{{- with $proxy.volumes }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
- name: plugins-config-volume
configMap:
name: {{ include "llm-d-router.name" . }}
{{- include "llm-d-router.latencyPredictor.volumes" . | nindent 8 }}
{{- if .Values.router.epp.affinity }}
affinity:
{{- toYaml .Values.router.epp.affinity | nindent 8 }}
{{- end }}
{{- if .Values.router.epp.tolerations }}
tolerations:
{{- toYaml .Values.router.epp.tolerations | nindent 8 }}
{{- end }}
---
{{- end }}