Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
ffd47bca
Commit
ffd47bca
authored
Mar 14, 2025
by
julienmancuso
Committed by
GitHub
Mar 14, 2025
Browse files
fix: fix helm chart deployment (#172)
parent
2cca070c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
42 deletions
+88
-42
container/deps/requirements.txt
container/deps/requirements.txt
+1
-0
deploy/Kubernetes/pipeline/README.md
deploy/Kubernetes/pipeline/README.md
+5
-2
deploy/Kubernetes/pipeline/chart/templates/deployment.yaml
deploy/Kubernetes/pipeline/chart/templates/deployment.yaml
+21
-15
deploy/Kubernetes/pipeline/chart/templates/service.yaml
deploy/Kubernetes/pipeline/chart/templates/service.yaml
+2
-2
deploy/Kubernetes/pipeline/chart/values.yaml
deploy/Kubernetes/pipeline/chart/values.yaml
+22
-0
deploy/Kubernetes/pipeline/deploy.sh
deploy/Kubernetes/pipeline/deploy.sh
+24
-20
deploy/dynamo/sdk/src/dynamo/sdk/lib/service.py
deploy/dynamo/sdk/src/dynamo/sdk/lib/service.py
+5
-1
deploy/examples/hello_world/hello_world.py
deploy/examples/hello_world/hello_world.py
+8
-2
No files found.
container/deps/requirements.txt
View file @
ffd47bca
...
...
@@ -22,6 +22,7 @@ mypy
numpy
opentelemetry-api
opentelemetry-sdk
pip==25.0.1
pre-commit
protobuf==5.27.3
pydantic==2.7.1
...
...
deploy/Kubernetes/pipeline/README.md
View file @
ffd47bca
...
...
@@ -7,10 +7,13 @@ This is a proof of concept for a Helm chart to deploy services defined in a bent
### Prerequisites
-
make sure dynamo cli is installed
-
make sure you have a docker image registry to which you can push and pull from k8s cluster
-
set the imagePullSecrets in the values.yaml file
### Install the Helm chart
```
bash
./deploy.sh <docker_registry> <k8s_namespace> <bento_name> <path_to_bento_directory>
# example./deploy.sh nvcr.io/nvidian/nim-llm-dev my-namespace my-helm-poc ../deploy/compoundai/sdk/examples/basic_service
export
DYNAMO_IMAGE
=
<dynamo_docker_image_name>
./deploy.sh <docker_registry> <k8s_namespace> <path_to_dynamo_directory> <dynamo_identifier>
# example : ./deploy.sh nvcr.io/nvidian/nim-llm-dev my-namespace ../deploy/dynamo/sdk/examples/hello_world/ hello_world:Frontend
```
\ No newline at end of file
deploy/Kubernetes/pipeline/chart/templates/deployment.yaml
View file @
ffd47bca
...
...
@@ -16,29 +16,31 @@
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
poc
-{{ .name | lower }}
name
:
{{
$.Release.Name
}}
-{{ .name | lower }}
labels
:
app
:
{{
.name | lower
}}
app
:
{{
$.Release.Name
}}
-{{
.name | lower }}
spec
:
replicas
:
1
replicas
:
{{
.config.workers | default 1
}}
selector
:
matchLabels
:
app
:
poc
-{{ .name | lower }}
app
:
{{
$.Release.Name
}}
-{{ .name | lower }}
template
:
metadata
:
labels
:
app
:
poc
-{{ .name | lower }}
app
:
{{
$.Release.Name
}}
-{{ .name | lower }}
spec
:
# pull secrets
imagePullSecrets
:
-
name
:
yatai-regcred
{{
- range $.Values.imagePullSecrets
}}
-
name
:
{{
.name
}}
{{
- end
}}
securityContext
:
runAsUser
:
0
containers
:
-
name
:
poc
-{{ .name | lower }}
-
name
:
{{
$.Release.Name
}}
-{{ .name | lower }}
image
:
{{
$.Values.image
}}
args
:
-
uv run
compoundai
start --service-name {{ .name }}
-
uv run
dynamo
start --service-name {{ .name }}
src.{{ $.Values.dynamoIdentifier }}
command
:
-
sh
-
-c
...
...
@@ -50,11 +52,11 @@ spec:
env
:
-
name
:
TRAFFIC_TIMEOUT
value
:
"
{{
.config.traffic.timeout
}}"
{{
- if and .config.
nova
.config.
nova
.enabled
}}
-
name
:
NOVA
_NAMESPACE
value
:
"
{{
.config.
nova
.namespace
}}"
-
name
:
NOVA
_NAME
value
:
"
{{
.config.
nova
.name
}}"
{{
- if and .config.
dynamo
.config.
dynamo
.enabled
}}
-
name
:
DYNAMO
_NAMESPACE
value
:
"
{{
.config.
dynamo
.namespace
}}"
-
name
:
DYNAMO
_NAME
value
:
"
{{
.config.
dynamo
.name
}}"
{{
- end
}}
{{
- if .config.workers
}}
-
name
:
WORKERS
...
...
@@ -62,9 +64,13 @@ spec:
{{
- end
}}
-
name
:
PORT
value
:
"
3000"
{{
- if $.Values.natsAddr
}}
-
name
:
NATS_SERVER
value
:
nats://my-nats:4222
value
:
{{
$.Values.natsAddr
}}
{{
- end
}}
{{
- if $.Values.etcdAddr
}}
-
name
:
ETCD_ENDPOINTS
value
:
etcd:2379
value
:
{{
$.Values.etcdAddr
}}
{{
- end
}}
---
{{
- end
}}
deploy/Kubernetes/pipeline/chart/templates/service.yaml
View file @
ffd47bca
...
...
@@ -16,10 +16,10 @@
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
{{
.name | lower
}}
name
:
{{
$.Release.Name
}}
-{{
.name | lower }}
spec
:
selector
:
app
:
{{
.name | lower
}}
app
:
{{
$.Release.Name
}}
-{{
.name | lower }}
ports
:
-
protocol
:
TCP
port
:
80
...
...
deploy/Kubernetes/pipeline/chart/values.yaml
0 → 100644
View file @
ffd47bca
# 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.
imagePullSecrets
:
-
name
:
yatai-regcred
-
name
:
nvcrimagepullsecret
-
name
:
gitlab-imagepull
natsAddr
:
nats://dynamo-platform-nats:4222
etcdAddr
:
dynamo-platform-etcd:2379
deploy/Kubernetes/pipeline/deploy.sh
View file @
ffd47bca
...
...
@@ -18,26 +18,28 @@
set
-euo
pipefail
# Validate input parameters
if
[
"$#"
-ne
4
]
;
then
echo
"Usage:
$0
<DOCKER_REGISTRY> <NAMESPACE> <
BENTO_NAME> <BENTO_DIRECTORY
>"
echo
"Usage:
$0
<DOCKER_REGISTRY> <NAMESPACE> <
DYNAMO_DIRECTORY> <DYNAMO_IDENTIFIER
>"
exit
1
fi
DOCKER_REGISTRY
=
$1
NAMESPACE
=
$2
BENTO_NAME
=
$3
BENTO_DIRECTORY
=
$4
DYNAMO_DIRECTORY
=
$3
DYNAMO_IDENTIFIER
=
$4
# Check if any of the inputs are empty
if
[[
-z
"
$DOCKER_REGISTRY
"
||
-z
"
$NAMESPACE
"
||
-z
"
$
BENTO_NAME
"
||
-z
"
$
BENT
O_DIRECTORY
"
]]
;
then
echo
"Error: All input parameters (DOCKER_REGISTRY, NAMESPACE,
BENTO_NAME, BENT
O_DIRECTORY) must be non-empty."
if
[[
-z
"
$DOCKER_REGISTRY
"
||
-z
"
$NAMESPACE
"
||
-z
"
$
DYNAMO_IDENTIFIER
"
||
-z
"
$
DYNAM
O_DIRECTORY
"
]]
;
then
echo
"Error: All input parameters (DOCKER_REGISTRY, NAMESPACE,
DYNAMO_IDENTIFIER, DYNAM
O_DIRECTORY) must be non-empty."
exit
1
fi
# Check if the specified directory exists
if
[
!
-d
"
$
BENT
O_DIRECTORY
"
]
;
then
echo
"Error: Directory
$
BENT
O_DIRECTORY
does not exist."
if
[
!
-d
"
$
DYNAM
O_DIRECTORY
"
]
;
then
echo
"Error: Directory
$
DYNAM
O_DIRECTORY
does not exist."
exit
1
fi
...
...
@@ -45,20 +47,21 @@ echo "Logging into Docker registry: $DOCKER_REGISTRY"
docker login
"
$DOCKER_REGISTRY
"
# Change to the specified directory
cd
"
$BENTO_DIRECTORY
"
# Update the bentofile.yaml with the new BENTO_NAME
echo
"Updating bentofile.yaml with name:
$BENTO_NAME
"
yq
eval
".name =
\"
$BENTO_NAME
\"
"
-i
bentofile.yaml
cd
"
$DYNAMO_DIRECTORY
"
# Build the Bento container
echo
"Building Bento image for
$BENTO_NAME
..."
DOCKER_DEFAULT_PLATFORM
=
linux/amd64 uv run dynamo build
--containerize
echo
"Building Bento image for
$DYNAMO_IDENTIFIER
..."
DOCKER_DEFAULT_PLATFORM
=
linux/amd64 uv run dynamo build
--containerize
$DYNAMO_IDENTIFIER
# Extract the module and the bento name
DYNAMO_MODULE
=
$(
echo
"
$DYNAMO_IDENTIFIER
"
|
awk
-F
':'
'{print $1}'
|
tr
'[:upper:]'
'[:lower:]'
)
DYNAMO_NAME
=
$(
echo
"
$DYNAMO_IDENTIFIER
"
|
awk
-F
':'
'{print $2}'
|
tr
'[:upper:]'
'[:lower:]'
)
# Find the built image
docker_image
=
$(
docker images
--format
"{{.Repository}}:{{.Tag}} {{.CreatedAt}}"
|
grep
"^
$
BENT
O_NAME
:"
|
sort
-r
|
head
-n
1 |
awk
'{print $1}'
)
docker_image
=
$(
docker images
--format
"{{.Repository}}:{{.Tag}} {{.CreatedAt}}"
|
grep
"^
$
DYNAM
O_NAME
:"
|
sort
-r
-k2
,3
|
head
-n
1 |
awk
'{print $1}'
)
if
[[
-z
"
$docker_image
"
]]
;
then
echo
"Failed to find the built image for
$
BENT
O_NAME
"
echo
"Failed to find the built image for
$
DYNAM
O_NAME
"
exit
1
fi
...
...
@@ -66,7 +69,7 @@ fi
docker_sha
=
$(
echo
"
$docker_image
"
|
awk
-F
':'
'{print $2}'
)
echo
"Found Docker image:
$docker_image
"
echo
"Docker SHA
(bento-version)
:
$docker_sha
"
echo
"Docker SHA:
$docker_sha
"
# Tag the image for the registry
docker_tag_for_registry
=
"
$DOCKER_REGISTRY
/
$docker_image
"
...
...
@@ -79,6 +82,7 @@ docker push "$docker_tag_for_registry"
cd
-
# Install the Helm chart with the correct bento-version (SHA)
echo
"Installing Helm chart with image:
$docker_tag_for_registry
and bento-version:
$docker_sha
"
helm
install
"
$BENTO_NAME
"
./poc
-f
~/bentoml/bentos/
"
$BENTO_NAME
"
/
"
$docker_sha
"
/bento.yaml
--set
image
=
"
$docker_tag_for_registry
"
-n
"
$NAMESPACE
"
# Install the Helm chart with the correct tag (SHA)
echo
"Installing Helm chart with image:
$docker_tag_for_registry
"
HELM_RELEASE
=
"
${
DYNAMO_MODULE
//_/\-
}
"
helm upgrade
-i
"
$HELM_RELEASE
"
./chart
-f
~/bentoml/bentos/
"
$DYNAMO_NAME
"
/
"
$docker_sha
"
/bento.yaml
--set
image
=
"
$docker_tag_for_registry
"
--set
dynamoIdentifier
=
"
$DYNAMO_IDENTIFIER
"
-n
"
$NAMESPACE
"
deploy/dynamo/sdk/src/dynamo/sdk/lib/service.py
View file @
ffd47bca
...
...
@@ -17,7 +17,7 @@ from __future__ import annotations
import
json
import
os
from
collections
import
defaultdict
from
dataclasses
import
dataclass
from
dataclasses
import
asdict
,
dataclass
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Set
,
Tuple
,
TypeVar
,
Union
from
_bentoml_sdk
import
Service
,
ServiceConfig
...
...
@@ -95,6 +95,10 @@ class DynamoService(Service[T]):
if
self
.
_dynamo_config
.
name
is
None
:
self
.
_dynamo_config
.
name
=
inner
.
__name__
# Add dynamo configuration to the service config
# this allows for the config to be part of the service in bento.yaml
self
.
config
[
"dynamo"
]
=
asdict
(
self
.
_dynamo_config
)
# Register Dynamo endpoints
self
.
_dynamo_endpoints
:
Dict
[
str
,
DynamoEndpoint
]
=
{}
for
field
in
dir
(
inner
):
...
...
deploy/examples/hello_world/hello_world.py
View file @
ffd47bca
...
...
@@ -15,7 +15,7 @@
from
pydantic
import
BaseModel
from
dynamo.sdk
import
api
,
depends
,
dynamo_endpoint
,
service
from
dynamo.sdk
import
DYNAMO_IMAGE
,
api
,
depends
,
dynamo_endpoint
,
service
"""
Pipeline Architecture:
...
...
@@ -55,6 +55,7 @@ class ResponseType(BaseModel):
"namespace"
:
"inference"
,
},
workers
=
3
,
image
=
DYNAMO_IMAGE
,
)
class
Backend
:
def
__init__
(
self
)
->
None
:
...
...
@@ -74,6 +75,7 @@ class Backend:
resources
=
{
"cpu"
:
"2"
},
traffic
=
{
"timeout"
:
30
},
dynamo
=
{
"enabled"
:
True
,
"namespace"
:
"inference"
},
image
=
DYNAMO_IMAGE
,
)
class
Middle
:
backend
=
depends
(
Backend
)
...
...
@@ -93,7 +95,11 @@ class Middle:
yield
f
"Middle:
{
response
}
"
@
service
(
resources
=
{
"cpu"
:
"1"
},
traffic
=
{
"timeout"
:
60
})
# Regular HTTP API
@
service
(
resources
=
{
"cpu"
:
"1"
},
traffic
=
{
"timeout"
:
60
},
image
=
DYNAMO_IMAGE
,
)
# Regular HTTP API
class
Frontend
:
middle
=
depends
(
Middle
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment