deployment.yaml 6.7 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
        {{ if $serviceSpec.resources }}
70
71
        resources:
          requests:
72
73
            {{ if $serviceSpec.resources.cpu }}
            cpu: "{{ $serviceSpec.resources.cpu }}"
74
            {{ end }}
75
76
            {{ if $serviceSpec.resources.memory }}
            memory: "{{ $serviceSpec.resources.memory }}"
77
            {{ end }}
78
79
            {{ if $serviceSpec.resources.gpu }}
            nvidia.com/gpu: "{{ $serviceSpec.resources.gpu }}"
80
            {{ end }}
81
          limits:
82
83
            {{ if $serviceSpec.resources.cpu }}
            cpu: "{{ $serviceSpec.resources.cpu }}"
84
            {{ end }}
85
86
            {{ if $serviceSpec.resources.memory }}
            memory: "{{ $serviceSpec.resources.memory }}"
87
            {{ end }}
88
89
            {{ if $serviceSpec.resources.gpu }}
            nvidia.com/gpu: "{{ $serviceSpec.resources.gpu }}"
90
            {{ end }}
91
        {{ end }}
92
93
94
95
        {{- if $serviceSpec.envFromSecret }}
        envFrom:
        - secretRef:
            name: {{ $serviceSpec.envFromSecret }}
96
        {{- end }}
97
        env:
98
99
100
101
        {{- if $.Values.dynamoNamespace }}
        - name: DYN_NAMESPACE
          value: {{ $.Values.dynamoNamespace }}
        {{- end }}
102
        {{- if $.Values.etcdAddr }}
103
        - name: ETCD_ENDPOINTS
104
105
106
107
108
          value: "{{ $.Values.etcdAddr }}"
        {{- end }}
        {{- if $.Values.natsAddr }}
        - name: NATS_SERVER
          value: "{{ $.Values.natsAddr }}"
109
        {{- end }}
110
111
112
113
114
115
        {{- 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" }}
116
117
        - name: DYN_SYSTEM_ENABLED
          value: "true"
118
119
120
121
122
123
124
125
126
127
128
        - 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" }}
129
        ports:
130
131
132
133
134
        - name: system
          containerPort: {{ $.Values.dynamoSystemPort | default 9090 }}
          protocol: TCP
        {{- end }}
        {{- if and $serviceSpec.componentType (or (eq $serviceSpec.componentType "frontend") (eq $serviceSpec.componentType "worker")) }}
135
        livenessProbe:
136
137
          {{- if $serviceSpec.livenessProbe }}
          {{ $serviceSpec.livenessProbe | toYaml | nindent 10 }}
138
139
140
141
142
143
          {{- else }}
          initialDelaySeconds: 60
          periodSeconds: 60
          timeoutSeconds: 5
          failureThreshold: 10
          successThreshold: 1
144
145
146
147
148
149
150
151
152
          {{- if $serviceSpec.componentType | eq "frontend" }}
          httpGet:
            path: /health
            port: http
          {{- else if $serviceSpec.componentType | eq "worker" }}
          httpGet:
            path: /live
            port: system
          {{- else }}
153
154
155
156
157
          httpGet:
            path: /healthz
            port: health
            scheme: HTTP
          {{- end }}
158
          {{- end }}
159
        readinessProbe:
160
161
          {{- if $serviceSpec.readinessProbe }}
          {{ $serviceSpec.readinessProbe | toYaml | nindent 10 }}
162
163
164
165
166
167
          {{- else }}
          initialDelaySeconds: 60
          periodSeconds: 60
          timeoutSeconds: 5
          failureThreshold: 10
          successThreshold: 1
168
169
170
171
172
173
174
175
176
177
178
          {{- 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 }}
179
180
181
182
183
          httpGet:
            path: /readyz
            port: health
            scheme: HTTP
          {{- end }}
184
185
          {{- end }}
        {{- end }}
186
{{- end }}
187
{{- end }}