deployment.yaml 7.64 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
15
16
# if deploymentType is empty, or explicitly set to basic, use basic as default
{{- if or (not .Values.deploymentType) (eq .Values.deploymentType "basic") -}}
17
18
{{- range $serviceName, $serviceSpec := .Values.spec.services }}
---
19
20
21
apiVersion: apps/v1
kind: Deployment
metadata:
22
  name: {{ $.Release.Name }}-{{ $serviceName | lower }}
23
  labels:
24
    app: {{ $.Release.Name }}-{{ $serviceName | lower }}
25
spec:
26
  replicas: {{ $serviceSpec.replicas }}
27
28
  selector:
    matchLabels:
29
      app: {{ $.Release.Name }}-{{ $serviceName | lower }}
30
31
32
  template:
    metadata:
      labels:
33
        app: {{ $.Release.Name }}-{{ $serviceName | lower }}
34
    spec:
35
      {{- if $.Values.imagePullSecrets }}
36
      imagePullSecrets:
37
        {{ $.Values.imagePullSecrets | toYaml | nindent 8 }}
38
      {{- end }}
39
      containers:
40
41
      - name: {{ $.Release.Name }}-{{ $serviceName | lower }}
        image: {{ $serviceSpec.extraPodSpec.mainContainer.image }}
42
        {{- if $serviceSpec.extraPodSpec.mainContainer.workingDir }}
43
        workingDir: {{ $serviceSpec.extraPodSpec.mainContainer.workingDir }}
44
        {{- end }}
45
46
47
        {{- if $serviceSpec.extraPodSpec.mainContainer.command }}
        command:
        {{- $serviceSpec.extraPodSpec.mainContainer.command | toYaml | nindent 8 }}
48
49
50
51
52
53
54
55
56
57
58
59
        {{- else }}
          {{- if $serviceSpec.componentType | eq "frontend" }}
        command:
        - python3
          {{- else }}
        command:
        - /bin/sh
        - -c
        {{- if not $serviceSpec.extraPodSpec.mainContainer.args }}
          {{- fail (printf "spec.services[%s].extraPodSpec.mainContainer.args must be set for non-frontend components" $serviceName) }}
        {{- end }}
          {{- end }}
60
61
        {{- end }}
        {{- if $serviceSpec.extraPodSpec.mainContainer.args }}
62
        args:
63
        {{- $serviceSpec.extraPodSpec.mainContainer.args | toYaml | nindent 8 }}
64
65
66
67
        {{- else if $serviceSpec.componentType | eq "frontend" }}
        args:
        - -m
        - dynamo.frontend
68
        {{- end }}
69
70
71
72
73
74
        {{- if $serviceSpec.resources }}
        {{- $hasResources := false }}
        {{- if or $serviceSpec.resources.requests $serviceSpec.resources.limits }}
        {{- $hasResources = true }}
        {{- end }}
        {{- if $hasResources }}
75
        resources:
76
77
78
79
80
          {{- if $serviceSpec.resources.requests }}
          {{- $requestsGpuResourceName := "nvidia.com/gpu" }}
          {{- if $serviceSpec.resources.requests.gpuType }}
          {{- $requestsGpuResourceName = $serviceSpec.resources.requests.gpuType }}
          {{- end }}
81
          requests:
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
            {{- if $serviceSpec.resources.requests.cpu }}
            cpu: "{{ $serviceSpec.resources.requests.cpu }}"
            {{- end }}
            {{- if $serviceSpec.resources.requests.memory }}
            memory: "{{ $serviceSpec.resources.requests.memory }}"
            {{- end }}
            {{- if $serviceSpec.resources.requests.gpu }}
            {{ $requestsGpuResourceName }}: "{{ $serviceSpec.resources.requests.gpu }}"
            {{- end }}
          {{- end }}
          {{- if $serviceSpec.resources.limits }}
          {{- $limitsGpuResourceName := "nvidia.com/gpu" }}
          {{- if $serviceSpec.resources.limits.gpuType }}
          {{- $limitsGpuResourceName = $serviceSpec.resources.limits.gpuType }}
          {{- end }}
97
          limits:
98
99
100
101
102
103
104
105
106
107
108
109
            {{- if $serviceSpec.resources.limits.cpu }}
            cpu: "{{ $serviceSpec.resources.limits.cpu }}"
            {{- end }}
            {{- if $serviceSpec.resources.limits.memory }}
            memory: "{{ $serviceSpec.resources.limits.memory }}"
            {{- end }}
            {{- if $serviceSpec.resources.limits.gpu }}
            {{ $limitsGpuResourceName }}: "{{ $serviceSpec.resources.limits.gpu }}"
            {{- end }}
          {{- end }}
        {{- end }}
        {{- end }}
110
111
112
113
        {{- if $serviceSpec.envFromSecret }}
        envFrom:
        - secretRef:
            name: {{ $serviceSpec.envFromSecret }}
114
        {{- end }}
115
        env:
116
117
118
119
        {{- if $.Values.dynamoNamespace }}
        - name: DYN_NAMESPACE
          value: {{ $.Values.dynamoNamespace }}
        {{- end }}
120
        {{- if $.Values.etcdAddr }}
121
        - name: ETCD_ENDPOINTS
122
123
124
125
126
          value: "{{ $.Values.etcdAddr }}"
        {{- end }}
        {{- if $.Values.natsAddr }}
        - name: NATS_SERVER
          value: "{{ $.Values.natsAddr }}"
127
        {{- end }}
128
129
130
131
132
133
        {{- if $serviceSpec.componentType | eq "frontend" }}
        - name: DYNAMO_PORT
          value: "{{ $.Values.dynamoPort | default 8000 }}"
        - name: DYN_HTTP_PORT
          value: "{{ $.Values.dynamoPort | default 8000 }}"
        {{- else if $serviceSpec.componentType | eq "worker" }}
134
135
        - name: DYN_SYSTEM_ENABLED
          value: "true"
136
137
138
139
140
141
142
143
144
145
146
        - name: DYN_SYSTEM_PORT
          value: "{{ $.Values.dynamoSystemPort | default 9090 }}"
        - name: DYN_SYSTEM_USE_ENDPOINT_HEALTH_STATUS
          value: "[\"generate\"]"
        {{- end }}
        {{- if $serviceSpec.componentType | eq "frontend" }}
        ports:
        - name: http
          containerPort: {{ $.Values.dynamoPort | default 8000 }}
          protocol: TCP
        {{- else if $serviceSpec.componentType | eq "worker" }}
147
        ports:
148
149
150
151
152
        - name: system
          containerPort: {{ $.Values.dynamoSystemPort | default 9090 }}
          protocol: TCP
        {{- end }}
        {{- if and $serviceSpec.componentType (or (eq $serviceSpec.componentType "frontend") (eq $serviceSpec.componentType "worker")) }}
153
        livenessProbe:
154
155
          {{- if $serviceSpec.livenessProbe }}
          {{ $serviceSpec.livenessProbe | toYaml | nindent 10 }}
156
157
158
159
160
161
          {{- else }}
          initialDelaySeconds: 60
          periodSeconds: 60
          timeoutSeconds: 5
          failureThreshold: 10
          successThreshold: 1
162
163
164
165
166
167
168
169
170
          {{- if $serviceSpec.componentType | eq "frontend" }}
          httpGet:
            path: /health
            port: http
          {{- else if $serviceSpec.componentType | eq "worker" }}
          httpGet:
            path: /live
            port: system
          {{- else }}
171
172
173
174
175
          httpGet:
            path: /healthz
            port: health
            scheme: HTTP
          {{- end }}
176
          {{- end }}
177
        readinessProbe:
178
179
          {{- if $serviceSpec.readinessProbe }}
          {{ $serviceSpec.readinessProbe | toYaml | nindent 10 }}
180
181
182
183
184
185
          {{- else }}
          initialDelaySeconds: 60
          periodSeconds: 60
          timeoutSeconds: 5
          failureThreshold: 10
          successThreshold: 1
186
187
188
189
190
191
192
193
194
195
196
          {{- if $serviceSpec.componentType | eq "frontend" }}
          exec:
            command:
              - /bin/sh
              - -c
              - curl -s http://localhost:${DYNAMO_PORT}/health | jq -e ".status == \"healthy\""
          {{- else if $serviceSpec.componentType | eq "worker" }}
          httpGet:
            path: /health
            port: system
          {{- else }}
197
198
199
200
201
          httpGet:
            path: /readyz
            port: health
            scheme: HTTP
          {{- end }}
202
203
          {{- end }}
        {{- end }}
204
{{- end }}
205
{{- end }}