Unverified Commit f11ea8f7 authored by julienmancuso's avatar julienmancuso Committed by GitHub
Browse files

feat: remove bento/yatai references (#782)

parent ea84ab11
...@@ -48,14 +48,6 @@ Create chart name and version as used by the chart label. ...@@ -48,14 +48,6 @@ Create chart name and version as used by the chart label.
{{ include "dynamo-operator.fullname" . }}-dynamo-env {{ include "dynamo-operator.fullname" . }}-dynamo-env
{{- end }} {{- end }}
{{/*
Generate k8s robot token
*/}}
{{- define "dynamo-operator.yataiApiToken" -}}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace (include "dynamo-operator.dynamo.envname" .)) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
{{- (get $secretData "YATAI_API_TOKEN") | default (randAlphaNum 16 | nospace | b64enc) | b64dec }}
{{- end -}}
{{/* {{/*
Common labels Common labels
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
{{- if .Values.dynamo.bentoImageBuildEngine | eq "buildkit" }} {{- if .Values.dynamo.imageBuildEngine | eq "buildkit" }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: StatefulSet kind: StatefulSet
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: yatai-regcred name: dynamo-regcred
labels: labels:
{{- include "dynamo-operator.labels" . | nindent 4 }} {{- include "dynamo-operator.labels" . | nindent 4 }}
type: kubernetes.io/dockerconfigjson type: kubernetes.io/dockerconfigjson
......
...@@ -21,23 +21,17 @@ metadata: ...@@ -21,23 +21,17 @@ metadata:
{{- include "dynamo-operator.labels" . | nindent 4 }} {{- include "dynamo-operator.labels" . | nindent 4 }}
type: Opaque type: Opaque
stringData: stringData:
YATAI_ENDPOINT: {{ .Values.dynamo.yatai.endpoint | quote }} API_STORE_ENDPOINT : {{ .Values.dynamo.apiStore.endpoint | quote }}
YATAI_CLUSTER_NAME: {{ .Values.dynamo.yatai.clusterName | quote }} API_STORE_CLUSTER_NAME: {{ .Values.dynamo.apiStore.clusterName | quote }}
YATAI_SYSTEM_NAMESPACE: {{ default .Release.Namespace .Values.dynamo.yataiSystem.namespace }} DYNAMO_SYSTEM_NAMESPACE: {{ .Release.Namespace }}
YATAI_DEPLOYMENT_NAMESPACE: {{ .Release.Namespace }} DYNAMO_DEPLOYMENT_NAMESPACE: {{ .Release.Namespace }}
YATAI_IMAGE_BUILDER_NAMESPACE: {{ .Release.Namespace }} DYNAMO_IMAGE_BUILDER_NAMESPACE: {{ .Release.Namespace }}
YATAI_API_TOKEN: {{ include "dynamo-operator.yataiApiToken" . | quote }}
INTERNAL_IMAGES_METRICS_TRANSFORMER: {{ .Values.dynamo.internalImages.metricsTransformer | quote }} INTERNAL_IMAGES_METRICS_TRANSFORMER: {{ .Values.dynamo.internalImages.metricsTransformer | quote }}
INTERNAL_IMAGES_DEBUGGER: {{ .Values.dynamo.internalImages.debugger | quote }} INTERNAL_IMAGES_DEBUGGER: {{ .Values.dynamo.internalImages.debugger | quote }}
INTERNAL_IMAGES_MONITOR_EXPORTER: {{ .Values.dynamo.internalImages.monitorExporter | quote }} INTERNAL_IMAGES_MONITOR_EXPORTER: {{ .Values.dynamo.internalImages.monitorExporter | quote }}
INTERNAL_IMAGES_PROXY: {{ .Values.dynamo.internalImages.proxy | quote }} INTERNAL_IMAGES_PROXY: {{ .Values.dynamo.internalImages.proxy | quote }}
{{- if .Values.dynamo.disableAutomateBentoImageBuilder }}
DISABLE_AUTOMATE_BENTO_IMAGE_BUILDER: "true"
{{- end }}
{{- if .Values.dynamo.enableRestrictedSecurityContext }} {{- if .Values.dynamo.enableRestrictedSecurityContext }}
ENABLE_RESTRICTED_SECURITY_CONTEXT: "true" ENABLE_RESTRICTED_SECURITY_CONTEXT: "true"
{{- end }} {{- end }}
...@@ -53,17 +47,15 @@ stringData: ...@@ -53,17 +47,15 @@ stringData:
DOCKER_REGISTRY_PASSWORD: {{ .password | quote }} DOCKER_REGISTRY_PASSWORD: {{ .password | quote }}
{{- end }} {{- end }}
DOCKER_REGISTRY_SECURE: {{ .Values.dynamo.dockerRegistry.secure | quote }} DOCKER_REGISTRY_SECURE: {{ .Values.dynamo.dockerRegistry.secure | quote }}
DOCKER_REGISTRY_BENTO_REPOSITORY_NAME: {{ .Values.dynamo.dockerRegistry.bentoRepositoryName | quote }} DOCKER_REGISTRY_DYNAMO_COMPONENTS_REPOSITORY_NAME: {{ .Values.dynamo.dockerRegistry.dynamoComponentsRepositoryName | quote }}
INTERNAL_IMAGES_BENTO_DOWNLOADER: {{ .Values.dynamo.internalImages.bentoDownloader | quote }} INTERNAL_IMAGES_DYNAMO_COMPONENTS_DOWNLOADER: {{ .Values.dynamo.internalImages.dynamoComponentsDownloader | quote }}
INTERNAL_IMAGES_KANIKO: {{ .Values.dynamo.internalImages.kaniko | quote }} INTERNAL_IMAGES_KANIKO: {{ .Values.dynamo.internalImages.kaniko | quote }}
INTERNAL_IMAGES_BUILDKIT: {{ .Values.dynamo.internalImages.buildkit | quote }} INTERNAL_IMAGES_BUILDKIT: {{ .Values.dynamo.internalImages.buildkit | quote }}
INTERNAL_IMAGES_BUILDKIT_ROOTLESS: {{ .Values.dynamo.internalImages.buildkitRootless | quote }} INTERNAL_IMAGES_BUILDKIT_ROOTLESS: {{ .Values.dynamo.internalImages.buildkitRootless | quote }}
BUILDKIT_URL: tcp://{{ include "dynamo-operator.fullname" . }}-buildkitd:1234 BUILDKIT_URL: tcp://{{ include "dynamo-operator.fullname" . }}-buildkitd:1234
BENTO_IMAGE_BUILD_ENGINE: {{ .Values.dynamo.bentoImageBuildEngine | quote }} DYNAMO_IMAGE_BUILD_ENGINE: {{ .Values.dynamo.imageBuildEngine | quote }}
DISABLE_YATAI_COMPONENT_REGISTRATION: {{ .Values.dynamo.disableYataiComponentRegistration | quote }}
ADD_NAMESPACE_PREFIX_TO_IMAGE_NAME: {{ .Values.dynamo.addNamespacePrefixToImageName | quote }} ADD_NAMESPACE_PREFIX_TO_IMAGE_NAME: {{ .Values.dynamo.addNamespacePrefixToImageName | quote }}
......
# 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.
apiVersion: v1
kind: Secret
metadata:
name: dynamo-deployment-shared-env
namespace: {{ .Release.Namespace }}
labels:
{{- include "dynamo-operator.labels" . | nindent 4 }}
type: Opaque
stringData:
BENTO_DEPLOYMENT_ALL_NAMESPACES: "false"
BENTO_DEPLOYMENT_NAMESPACES: {{ default .Release.Namespace .Values.dynamo.yataiSystem.namespace }}
YATAI_DEPLOYMENT_NAMESPACE: {{ default .Release.Namespace .Values.dynamo.yataiSystem.namespace }}
\ No newline at end of file
...@@ -73,27 +73,21 @@ controllerManager: ...@@ -73,27 +73,21 @@ controllerManager:
annotations: {} annotations: {}
dynamo: dynamo:
yatai: apiStore:
endpoint: http://dynamo-server.dynamo-system.svc.cluster.local endpoint: http://dynamo-server.dynamo-system.svc.cluster.local
clusterName: default clusterName: default
yataiSystem:
# If left blank, will default to the installation namespace
namespace: ""
internalImages: internalImages:
bentoDownloader: quay.io/bentoml/bento-downloader:0.0.5 dynamoComponentsDownloader: quay.io/bentoml/bento-downloader:0.0.5
kaniko: quay.io/bentoml/kaniko:debug kaniko: gcr.io/kaniko-project/executor:debug
buildkit: moby/buildkit:latest buildkit: moby/buildkit:v0.20.2
buildkitRootless: quay.io/bentoml/buildkit:master-rootless buildkitRootless: moby/buildkit:v0.20.2-rootless
metricsTransformer: quay.io/bentoml/yatai-bento-metrics-transformer:0.0.4 metricsTransformer: quay.io/bentoml/yatai-bento-metrics-transformer:0.0.4
debugger: quay.io/bentoml/bento-debugger:0.0.8 debugger: quay.io/bentoml/bento-debugger:0.0.8
monitorExporter: quay.io/bentoml/bentoml-monitor-exporter:0.0.3 monitorExporter: quay.io/bentoml/bentoml-monitor-exporter:0.0.3
proxy: quay.io/bentoml/bentoml-proxy:0.0.1 proxy: quay.io/bentoml/bentoml-proxy:0.0.1
disableAutomateBentoImageBuilder: false
enableRestrictedSecurityContext: false enableRestrictedSecurityContext: false
disableYataiComponentRegistration: false
dockerRegistry: dockerRegistry:
server: 'nvcr.io/nvidian/nim-llm-dev' server: 'nvcr.io/nvidian/nim-llm-dev'
...@@ -103,9 +97,9 @@ dynamo: ...@@ -103,9 +97,9 @@ dynamo:
passwordExistingSecretName: '' passwordExistingSecretName: ''
passwordExistingSecretKey: '' passwordExistingSecretKey: ''
secure: true secure: true
bentoRepositoryName: dynamo-pipelines dynamoComponentsRepositoryName: dynamo-pipelines
bentoImageBuildEngine: buildkit # options: kaniko, buildkit, buildkit-rootless imageBuildEngine: buildkit # options: kaniko, buildkit, buildkit-rootless
addNamespacePrefixToImageName: false addNamespacePrefixToImageName: false
estargz: estargz:
......
...@@ -37,31 +37,27 @@ dynamo-operator: ...@@ -37,31 +37,27 @@ dynamo-operator:
- --health-probe-bind-address=:8081 - --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080 - --metrics-bind-address=127.0.0.1:8080
dynamo: dynamo:
yatai: apiStore:
endpoint: http://dynamo-store endpoint: http://dynamo-store
clusterName: default clusterName: default
yataiSystem:
namespace: ""
internalImages: internalImages:
bentoDownloader: quay.io/bentoml/bento-downloader:0.0.5 dynamoComponentsDownloader: quay.io/bentoml/bento-downloader:0.0.5
kaniko: quay.io/bentoml/kaniko:debug kaniko: gcr.io/kaniko-project/executor:debug
buildkit: quay.io/bentoml/buildkit:master buildkit: moby/buildkit:v0.20.2
buildkitRootless: quay.io/bentoml/buildkit:master-rootless buildkitRootless: moby/buildkit:v0.20.2-rootless
metricsTransformer: quay.io/bentoml/yatai-bento-metrics-transformer:0.0.4 metricsTransformer: quay.io/bentoml/yatai-bento-metrics-transformer:0.0.4
debugger: quay.io/bentoml/bento-debugger:0.0.8 debugger: quay.io/bentoml/bento-debugger:0.0.8
monitorExporter: quay.io/bentoml/bentoml-monitor-exporter:0.0.3 monitorExporter: quay.io/bentoml/bentoml-monitor-exporter:0.0.3
proxy: quay.io/bentoml/bentoml-proxy:0.0.1 proxy: quay.io/bentoml/bentoml-proxy:0.0.1
disableAutomateBentoImageBuilder: false
enableRestrictedSecurityContext: false enableRestrictedSecurityContext: false
disableYataiComponentRegistration: false
dockerRegistry: dockerRegistry:
server: "" server: ""
inClusterServer: "" inClusterServer: ""
username: "" username: ""
password: "" password: ""
secure: true secure: true
bentoRepositoryName: dynamo-pipelines dynamoComponentsRepositoryName: dynamo-pipelines
bentoImageBuildEngine: buildkit imageBuildEngine: buildkit
addNamespacePrefixToImageName: false addNamespacePrefixToImageName: false
estargz: estargz:
enabled: false enabled: false
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES * Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES
*/ */
package yataiclient package api_store_client
import ( import (
"context" "context"
...@@ -27,53 +27,27 @@ import ( ...@@ -27,53 +27,27 @@ import (
"github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/schemas" "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/schemas"
) )
const ( type ApiStoreClient struct {
YataiApiTokenHeaderName = "X-YATAI-API-TOKEN"
NgcOrganizationHeaderName = "Nv-Ngc-Org"
NgcUserHeaderName = "Nv-Actor-Id"
)
type DynamoAuthHeaders struct {
OrgId string
UserId string
}
type YataiClient struct {
endpoint string endpoint string
apiToken string
headers DynamoAuthHeaders
} }
func NewYataiClient(endpoint, apiToken string) *YataiClient { func NewApiStoreClient(endpoint string) *ApiStoreClient {
return &YataiClient{ return &ApiStoreClient{
endpoint: endpoint, endpoint: endpoint,
apiToken: apiToken,
}
}
func (c *YataiClient) SetAuth(headers DynamoAuthHeaders) {
c.headers = headers
}
func (c *YataiClient) getHeaders() map[string]string {
return map[string]string{
YataiApiTokenHeaderName: c.apiToken,
NgcOrganizationHeaderName: c.headers.OrgId,
NgcUserHeaderName: c.headers.UserId,
} }
} }
func (c *YataiClient) GetBento(ctx context.Context, bentoRepositoryName, bentoVersion string) (bento *schemas.DynamoNIM, err error) { func (c *ApiStoreClient) GetDynamoComponent(ctx context.Context, name, version string) (component *schemas.DynamoComponent, err error) {
url_ := urlJoin(c.endpoint, fmt.Sprintf("/api/v1/bento_repositories/%s/bentos/%s", bentoRepositoryName, bentoVersion)) url_ := urlJoin(c.endpoint, fmt.Sprintf("/api/v1/dynamo_nims/%s/versions/%s", name, version))
bento = &schemas.DynamoNIM{} component = &schemas.DynamoComponent{}
_, err = DoJsonRequest(ctx, "GET", url_, c.getHeaders(), nil, nil, bento, nil) _, err = DoJsonRequest(ctx, "GET", url_, nil, nil, nil, component, nil)
return return
} }
func (c *YataiClient) PresignBentoDownloadURL(ctx context.Context, bentoRepositoryName, bentoVersion string) (bento *schemas.DynamoNIM, err error) { func (c *ApiStoreClient) PresignDynamoComponentDownloadURL(ctx context.Context, name, version string) (component *schemas.DynamoComponent, err error) {
url_ := urlJoin(c.endpoint, fmt.Sprintf("/api/v1/dynamo_nims/%s/versions/%s/presign_download_url", bentoRepositoryName, bentoVersion)) url_ := urlJoin(c.endpoint, fmt.Sprintf("/api/v1/dynamo_nims/%s/versions/%s/presign_download_url", name, version))
bento = &schemas.DynamoNIM{} component = &schemas.DynamoComponent{}
_, err = DoJsonRequest(ctx, "PATCH", url_, c.getHeaders(), nil, nil, bento, nil) _, err = DoJsonRequest(ctx, "PATCH", url_, nil, nil, nil, component, nil)
return return
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package yataiclient package api_store_client
import ( import (
"context" "context"
......
...@@ -23,10 +23,10 @@ import ( ...@@ -23,10 +23,10 @@ import (
"time" "time"
) )
type DynamoNIM struct { type DynamoComponent struct {
PresignedDownloadUrl string `json:"presigned_download_url"` PresignedDownloadUrl string `json:"presigned_download_url"`
TransmissionStrategy *TransmissionStrategy `json:"transmission_strategy"` TransmissionStrategy *TransmissionStrategy `json:"transmission_strategy"`
Manifest *DynamoNIMManifest `json:"manifest"` Manifest *DynamoComponentManifest `json:"manifest"`
} }
type TransmissionStrategy string type TransmissionStrategy string
...@@ -36,7 +36,7 @@ const ( ...@@ -36,7 +36,7 @@ const (
TransmissionStrategyProxy TransmissionStrategy = "proxy" TransmissionStrategyProxy TransmissionStrategy = "proxy"
) )
type DynamoNIMManifest struct { type DynamoComponentManifest struct {
BentomlVersion string `json:"bentoml_version"` BentomlVersion string `json:"bentoml_version"`
Models []string `json:"models"` Models []string `json:"models"`
} }
...@@ -77,10 +77,8 @@ const ( ...@@ -77,10 +77,8 @@ const (
) )
type DockerRegistrySchema struct { type DockerRegistrySchema struct {
BentosRepositoryURI string `json:"bentosRepositoryURI"` DynamoRepositoryURI string `json:"dynamoRepositoryURI"`
ModelsRepositoryURI string `json:"modelsRepositoryURI"` DynamoRepositoryURIInCluster string `json:"dynamoRepositoryURIInCluster"`
BentosRepositoryURIInCluster string `json:"bentosRepositoryURIInCluster"`
ModelsRepositoryURIInCluster string `json:"modelsRepositoryURIInCluster"`
Server string `json:"server"` Server string `json:"server"`
Username string `json:"username"` Username string `json:"username"`
Password string `json:"password"` Password string `json:"password"`
......
...@@ -179,7 +179,7 @@ func main() { ...@@ -179,7 +179,7 @@ func main() {
if err = (&controller.DynamoNimDeploymentReconciler{ if err = (&controller.DynamoNimDeploymentReconciler{
Client: mgr.GetClient(), Client: mgr.GetClient(),
Scheme: mgr.GetScheme(), Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("yatai-deployment"), Recorder: mgr.GetEventRecorderFor("dynamo-deployment"),
Config: ctrlConfig, Config: ctrlConfig,
NatsAddr: natsAddr, NatsAddr: natsAddr,
EtcdAddr: etcdAddr, EtcdAddr: etcdAddr,
...@@ -192,7 +192,7 @@ func main() { ...@@ -192,7 +192,7 @@ func main() {
if err = (&controller.DynamoNimRequestReconciler{ if err = (&controller.DynamoNimRequestReconciler{
Client: mgr.GetClient(), Client: mgr.GetClient(),
Scheme: mgr.GetScheme(), Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("yatai-image-builder"), Recorder: mgr.GetEventRecorderFor("dynamo-image-builder"),
Config: ctrlConfig, Config: ctrlConfig,
}).SetupWithManager(mgr); err != nil { }).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DynamoNimRequest") setupLog.Error(err, "unable to create controller", "controller", "DynamoNimRequest")
......
...@@ -24,43 +24,41 @@ import ( ...@@ -24,43 +24,41 @@ import (
"github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/consts" "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/consts"
) )
func GetYataiImageBuilderNamespace(ctx context.Context) (namespace string, err error) { func GetDynamoImageBuilderNamespace(ctx context.Context) (namespace string, err error) {
return os.Getenv(consts.EnvYataiImageBuilderNamespace), nil return os.Getenv(consts.EnvDynamoImageBuilderNamespace), nil
} }
type DockerRegistryConfig struct { type DockerRegistryConfig struct {
BentoRepositoryName string `yaml:"bento_repository_name"` DynamoComponentsRepositoryName string `yaml:"dynamo_components_repository_name"`
ModelRepositoryName string `yaml:"model_repository_name"` Server string `yaml:"server"`
Server string `yaml:"server"` InClusterServer string `yaml:"in_cluster_server"`
InClusterServer string `yaml:"in_cluster_server"` Username string `yaml:"username"`
Username string `yaml:"username"` Password string `yaml:"password"`
Password string `yaml:"password"` Secure bool `yaml:"secure"`
Secure bool `yaml:"secure"`
} }
func GetDockerRegistryConfig() (conf *DockerRegistryConfig, err error) { func GetDockerRegistryConfig() (conf *DockerRegistryConfig, err error) {
return &DockerRegistryConfig{ return &DockerRegistryConfig{
BentoRepositoryName: os.Getenv(consts.EnvDockerRegistryBentoRepositoryName), DynamoComponentsRepositoryName: os.Getenv(consts.EnvDockerRegistryDynamoComponentsRepositoryName),
ModelRepositoryName: os.Getenv(consts.EnvDockerRegistryModelRepositoryName), Server: os.Getenv(consts.EnvDockerRegistryServer),
Server: os.Getenv(consts.EnvDockerRegistryServer), InClusterServer: os.Getenv(consts.EnvDockerRegistryInClusterServer),
InClusterServer: os.Getenv(consts.EnvDockerRegistryInClusterServer), Username: os.Getenv(consts.EnvDockerRegistryUsername),
Username: os.Getenv(consts.EnvDockerRegistryUsername), Password: os.Getenv(consts.EnvDockerRegistryPassword),
Password: os.Getenv(consts.EnvDockerRegistryPassword), Secure: os.Getenv(consts.EnvDockerRegistrySecure) == "true",
Secure: os.Getenv(consts.EnvDockerRegistrySecure) == "true",
}, nil }, nil
} }
type YataiConfig struct { type ApiStoreConfig struct {
Endpoint string `yaml:"endpoint"` Endpoint string `yaml:"endpoint"`
ClusterName string `yaml:"cluster_name"` ClusterName string `yaml:"cluster_name"`
ApiToken string `yaml:"api_token"` ApiToken string `yaml:"api_token"`
} }
func GetYataiConfig(ctx context.Context) (conf *YataiConfig, err error) { func GetApiStoreConfig(ctx context.Context) (conf *ApiStoreConfig, err error) {
return &YataiConfig{ return &ApiStoreConfig{
Endpoint: os.Getenv(consts.EnvYataiEndpoint), Endpoint: os.Getenv(consts.EnvApiStoreEndpoint),
ClusterName: os.Getenv(consts.EnvYataiClusterName), ClusterName: os.Getenv(consts.EnvApiStoreClusterName),
ApiToken: os.Getenv(consts.EnvYataiApiToken), ApiToken: os.Getenv(consts.EnvApiStoreApiToken),
}, nil }, nil
} }
...@@ -72,16 +70,16 @@ func getEnv(key, fallback string) string { ...@@ -72,16 +70,16 @@ func getEnv(key, fallback string) string {
} }
type InternalImages struct { type InternalImages struct {
BentoDownloader string DynamoComponentsDownloader string
Kaniko string Kaniko string
MetricsTransformer string MetricsTransformer string
Buildkit string Buildkit string
BuildkitRootless string BuildkitRootless string
} }
func GetInternalImages() (conf *InternalImages) { func GetInternalImages() (conf *InternalImages) {
conf = &InternalImages{} conf = &InternalImages{}
conf.BentoDownloader = getEnv(consts.EnvInternalImagesBentoDownloader, consts.InternalImagesBentoDownloaderDefault) conf.DynamoComponentsDownloader = getEnv(consts.EnvInternalImagesDynamoComponentsDownloader, consts.InternalImagesDynamoComponentsDownloaderDefault)
conf.Kaniko = getEnv(consts.EnvInternalImagesKaniko, consts.InternalImagesKanikoDefault) conf.Kaniko = getEnv(consts.EnvInternalImagesKaniko, consts.InternalImagesKanikoDefault)
conf.MetricsTransformer = getEnv(consts.EnvInternalImagesMetricsTransformer, consts.InternalImagesMetricsTransformerDefault) conf.MetricsTransformer = getEnv(consts.EnvInternalImagesMetricsTransformer, consts.InternalImagesMetricsTransformerDefault)
conf.Buildkit = getEnv(consts.EnvInternalImagesBuildkit, consts.InternalImagesBuildkitDefault) conf.Buildkit = getEnv(consts.EnvInternalImagesBuildkit, consts.InternalImagesBuildkitDefault)
......
...@@ -3,96 +3,81 @@ package consts ...@@ -3,96 +3,81 @@ package consts
const ( const (
HPACPUDefaultAverageUtilization = 80 HPACPUDefaultAverageUtilization = 80
// nolint: gosec
YataiApiTokenHeaderName = "X-YATAI-API-TOKEN"
NgcOrganizationHeaderName = "Nv-Ngc-Org"
NgcUserHeaderName = "Nv-Actor-Id"
DefaultUserId = "default" DefaultUserId = "default"
DefaultOrgId = "default" DefaultOrgId = "default"
BentoServicePort = 3000 DynamoServicePort = 3000
BentoServicePortName = "http" DynamoServicePortName = "http"
BentoContainerPortName = "http" DynamoContainerPortName = "http"
YataiImageBuilderComponentName = "yatai-image-builder" DynamoImageBuilderComponentName = "dynamo-image-builder"
YataiDeploymentComponentName = "yatai-deployment"
YataiBentoDeploymentComponentApiServer = "api-server" DynamoDeploymentComponentApiServer = "api-server"
InternalImagesBentoDownloaderDefault = "quay.io/bentoml/bento-downloader:0.0.3" InternalImagesDynamoComponentsDownloaderDefault = "quay.io/bentoml/bento-downloader:0.0.3"
InternalImagesKanikoDefault = "quay.io/bentoml/kaniko:1.9.1" InternalImagesKanikoDefault = "gcr.io/kaniko-project/executor:debug"
InternalImagesMetricsTransformerDefault = "quay.io/bentoml/yatai-bento-metrics-transformer:0.0.3" InternalImagesMetricsTransformerDefault = "quay.io/bentoml/yatai-bento-metrics-transformer:0.0.3"
InternalImagesBuildkitDefault = "quay.io/bentoml/buildkit:master" InternalImagesBuildkitDefault = "moby/buildkit:v0.20.2"
InternalImagesBuildkitRootlessDefault = "quay.io/bentoml/buildkit:master-rootless" InternalImagesBuildkitRootlessDefault = "moby/buildkit:v0.20.2-rootless"
EnvYataiEndpoint = "YATAI_ENDPOINT" EnvApiStoreEndpoint = "API_STORE_ENDPOINT"
EnvYataiClusterName = "YATAI_CLUSTER_NAME" EnvApiStoreClusterName = "API_STORE_CLUSTER_NAME"
// nolint: gosec // nolint: gosec
EnvYataiApiToken = "YATAI_API_TOKEN" EnvApiStoreApiToken = "API_STORE_API_TOKEN"
EnvBentoServicePort = "PORT" EnvDynamoServicePort = "PORT"
// tracking envars // tracking envars
EnvYataiDeploymentUID = "YATAI_T_DEPLOYMENT_UID" EnvDynamoDeploymentUID = "DYNAMO_DEPLOYMENT_UID"
EnvYataiBentoDeploymentName = "YATAI_BENTO_DEPLOYMENT_NAME" EnvDynamoDeploymentName = "DYNAMO_DEPLOYMENT_NAME"
EnvYataiBentoDeploymentNamespace = "YATAI_BENTO_DEPLOYMENT_NAMESPACE" EnvDynamoDeploymentNamespace = "DYNAMO_DEPLOYMENT_NAMESPACE"
EnvDockerRegistryServer = "DOCKER_REGISTRY_SERVER" EnvDockerRegistryServer = "DOCKER_REGISTRY_SERVER"
EnvDockerRegistryInClusterServer = "DOCKER_REGISTRY_IN_CLUSTER_SERVER" EnvDockerRegistryInClusterServer = "DOCKER_REGISTRY_IN_CLUSTER_SERVER"
EnvDockerRegistryUsername = "DOCKER_REGISTRY_USERNAME" EnvDockerRegistryUsername = "DOCKER_REGISTRY_USERNAME"
// nolint:gosec // nolint:gosec
EnvDockerRegistryPassword = "DOCKER_REGISTRY_PASSWORD" EnvDockerRegistryPassword = "DOCKER_REGISTRY_PASSWORD"
EnvDockerRegistrySecure = "DOCKER_REGISTRY_SECURE" EnvDockerRegistrySecure = "DOCKER_REGISTRY_SECURE"
EnvDockerRegistryBentoRepositoryName = "DOCKER_REGISTRY_BENTO_REPOSITORY_NAME" EnvDockerRegistryDynamoComponentsRepositoryName = "DOCKER_REGISTRY_DYNAMO_COMPONENTS_REPOSITORY_NAME"
EnvDockerRegistryModelRepositoryName = "DOCKER_REGISTRY_MODEL_REPOSITORY_NAME"
EnvInternalImagesDynamoComponentsDownloader = "INTERNAL_IMAGES_DYNAMO_COMPONENTS_DOWNLOADER"
EnvInternalImagesBentoDownloader = "INTERNAL_IMAGES_BENTO_DOWNLOADER" EnvInternalImagesKaniko = "INTERNAL_IMAGES_KANIKO"
EnvInternalImagesKaniko = "INTERNAL_IMAGES_KANIKO" EnvInternalImagesMetricsTransformer = "INTERNAL_IMAGES_METRICS_TRANSFORMER"
EnvInternalImagesMetricsTransformer = "INTERNAL_IMAGES_METRICS_TRANSFORMER" EnvInternalImagesBuildkit = "INTERNAL_IMAGES_BUILDKIT"
EnvInternalImagesBuildkit = "INTERNAL_IMAGES_BUILDKIT" EnvInternalImagesBuildkitRootless = "INTERNAL_IMAGES_BUILDKIT_ROOTLESS"
EnvInternalImagesBuildkitRootless = "INTERNAL_IMAGES_BUILDKIT_ROOTLESS"
EnvDynamoSystemNamespace = "DYNAMO_SYSTEM_NAMESPACE"
EnvYataiSystemNamespace = "YATAI_SYSTEM_NAMESPACE" EnvDynamoImageBuilderNamespace = "DYNAMO_IMAGE_BUILDER_NAMESPACE"
EnvYataiImageBuilderNamespace = "YATAI_IMAGE_BUILDER_NAMESPACE"
EnvYataiDeploymentNamespace = "YATAI_DEPLOYMENT_NAMESPACE" KubeLabelDynamoSelector = "nvidia.com/selector"
EnvBentoDeploymentNamespaces = "BENTO_DEPLOYMENT_NAMESPACES" KubeLabelDynamoRepository = "nvidia.com/dynamo-repository"
EnvImageBuildersNamespace = "IMAGE_BUILDERS_NAMESPACE" KubeLabelDynamoVersion = "nvidia.com/dynamo-version"
KubeLabelYataiSelector = "yatai.ai/selector" KubeLabelDynamoDeployment = "nvidia.com/dynamo-deployment"
KubeLabelYataiBentoRepository = "yatai.ai/bento-repository" KubeLabelDynamoDeploymentComponentType = "nvidia.com/dynamo-deployment-component-type"
KubeLabelYataiBento = "yatai.ai/bento" KubeLabelDynamoDeploymentTargetType = "nvidia.com/dynamo-deployment-target-type"
KubeLabelYataiModelRepository = "yatai.ai/model-repository" KubeLabelDynamoCreator = "nvidia.com/dynamo-creator"
KubeLabelYataiModel = "yatai.ai/model"
KubeLabelIsDynamoImageBuilder = "nvidia.com/is-dynamo-image-builder"
KubeLabelYataiBentoDeployment = "yatai.ai/bento-deployment" KubeLabelDynamoRequest = "nvidia.com/dynamo-request"
KubeLabelYataiBentoDeploymentComponentType = "yatai.ai/bento-deployment-component-type"
KubeLabelYataiBentoDeploymentTargetType = "yatai.ai/bento-deployment-target-type"
KubeLabelBentoRepository = "yatai.ai/bento-repository"
KubeLabelBentoVersion = "yatai.ai/bento-version"
KubeLabelCreator = "yatai.ai/creator"
KubeLabelIsBentoImageBuilder = "yatai.ai/is-bento-image-builder"
KubeLabelIsModelSeeder = "yatai.ai/is-model-seeder"
KubeLabelBentoRequest = "yatai.ai/bento-request"
KubeLabelValueFalse = "false" KubeLabelValueFalse = "false"
KubeLabelValueTrue = "true" KubeLabelValueTrue = "true"
KubeLabelYataiImageBuilderPod = "yatai.ai/yatai-image-builder-pod" KubeLabelDynamoImageBuilderPod = "nvidia.com/dynamo-image-builder-pod"
KubeLabelBentoDeploymentPod = "yatai.ai/bento-deployment-pod" KubeLabelDynamoDeploymentPod = "nvidia.com/dynamo-deployment-pod"
KubeAnnotationBentoRepository = "yatai.ai/bento-repository" KubeAnnotationDynamoRepository = "nvidia.com/dynamo-repository"
KubeAnnotationBentoVersion = "yatai.ai/bento-version" KubeAnnotationDynamoVersion = "nvidia.com/dynamo-version"
KubeAnnotationDockerRegistryInsecure = "yatai.ai/docker-registry-insecure" KubeAnnotationDynamoDockerRegistryInsecure = "nvidia.com/docker-registry-insecure"
KubeAnnotationYataiImageBuilderSeparateModels = "yatai.ai/yatai-image-builder-separate-models"
KubeAnnotationIsMultiTenancy = "yatai.ai/is-multi-tenancy"
KubeResourceGPUNvidia = "nvidia.com/gpu" KubeResourceGPUNvidia = "nvidia.com/gpu"
// nolint: gosec // nolint: gosec
KubeSecretNameRegcred = "yatai-regcred" KubeSecretNameRegcred = "dynamo-regcred"
KubeAnnotationDynamoNimRequestHash = "nvidia.com/dynamo-request-hash"
KubeAnnotationDynamoNimRequestImageBuiderHash = "nvidia.com/dynamo-request-image-builder-hash"
KubeAnnotationDynamoNimStorageNS = "nvidia.com/dynamo-storage-namespace"
) )
...@@ -37,7 +37,7 @@ import ( ...@@ -37,7 +37,7 @@ import (
nvidiacomv1alpha1 "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/v1alpha1" nvidiacomv1alpha1 "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/v1alpha1"
commonController "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/controller_common" commonController "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/controller_common"
"github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/nim" "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/dynamo"
) )
const ( const (
...@@ -121,26 +121,26 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req ...@@ -121,26 +121,26 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, nil return ctrl.Result{}, nil
} }
// fetch the DynamoNIMConfig // fetch the dynamoGraphConfig
dynamoNIMConfig, err := nim.GetDynamoNIMConfig(ctx, dynamoDeployment, r.Recorder) dynamoGraphConfig, err := dynamo.GetDynamoGraphConfig(ctx, dynamoDeployment, r.Recorder)
if err != nil { if err != nil {
reason = "failed_to_get_the_DynamoNIMConfig" reason = "failed_to_get_the_DynamoGraphConfig"
return ctrl.Result{}, err return ctrl.Result{}, err
} }
// generate the DynamoNimDeployments from the config // generate the dynamoComponentsDeployments from the config
dynamoNimDeployments, err := nim.GenerateDynamoNIMDeployments(ctx, dynamoDeployment, dynamoNIMConfig, r.generateDefaultIngressSpec(dynamoDeployment)) dynamoComponentsDeployments, err := dynamo.GenerateDynamoComponentsDeployments(ctx, dynamoDeployment, dynamoGraphConfig, r.generateDefaultIngressSpec(dynamoDeployment))
if err != nil { if err != nil {
reason = "failed_to_generate_the_DynamoNimDeployments" reason = "failed_to_generate_the_DynamoComponentsDeployments"
return ctrl.Result{}, err return ctrl.Result{}, err
} }
// merge the DynamoNimDeployments with the DynamoNimDeployments from the CRD // merge the dynamoComponentsDeployments with the dynamoComponentsDeployments from the CRD
for serviceName, deployment := range dynamoNimDeployments { for serviceName, deployment := range dynamoComponentsDeployments {
if _, ok := dynamoDeployment.Spec.Services[serviceName]; ok { if _, ok := dynamoDeployment.Spec.Services[serviceName]; ok {
err := mergo.Merge(&deployment.Spec.DynamoNimDeploymentSharedSpec, dynamoDeployment.Spec.Services[serviceName].DynamoNimDeploymentSharedSpec, mergo.WithOverride) err := mergo.Merge(&deployment.Spec.DynamoNimDeploymentSharedSpec, dynamoDeployment.Spec.Services[serviceName].DynamoNimDeploymentSharedSpec, mergo.WithOverride)
if err != nil { if err != nil {
reason = "failed_to_merge_the_DynamoNimDeployments" reason = "failed_to_merge_the_DynamoComponentsDeployments"
return ctrl.Result{}, err return ctrl.Result{}, err
} }
} }
...@@ -149,8 +149,8 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req ...@@ -149,8 +149,8 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
} }
} }
// Set common env vars on each of the dynamoNimDeployments // Set common env vars on each of the dynamoComponentsDeployments
for _, deployment := range dynamoNimDeployments { for _, deployment := range dynamoComponentsDeployments {
if len(dynamoDeployment.Spec.Envs) > 0 { if len(dynamoDeployment.Spec.Envs) > 0 {
deployment.Spec.Envs = mergeEnvs(dynamoDeployment.Spec.Envs, deployment.Spec.Envs) deployment.Spec.Envs = mergeEnvs(dynamoDeployment.Spec.Envs, deployment.Spec.Envs)
} }
...@@ -177,20 +177,20 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req ...@@ -177,20 +177,20 @@ func (r *DynamoDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
} }
notReadyDeployments := []string{} notReadyDeployments := []string{}
// reconcile the DynamoNimDeployments // reconcile the dynamoComponentsDeployments
for serviceName, dynamoNimDeployment := range dynamoNimDeployments { for serviceName, dynamoComponentDeployment := range dynamoComponentsDeployments {
logger.Info("Reconciling the DynamoNimDeployment", "serviceName", serviceName, "dynamoNimDeployment", dynamoNimDeployment) logger.Info("Reconciling the DynamoNimDeployment", "serviceName", serviceName, "dynamoComponentDeployment", dynamoComponentDeployment)
if err := ctrl.SetControllerReference(dynamoDeployment, dynamoNimDeployment, r.Scheme); err != nil { if err := ctrl.SetControllerReference(dynamoDeployment, dynamoComponentDeployment, r.Scheme); err != nil {
reason = "failed_to_set_the_controller_reference_for_the_DynamoNimDeployment" reason = "failed_to_set_the_controller_reference_for_the_DynamoComponentDeployment"
return ctrl.Result{}, err return ctrl.Result{}, err
} }
dynamoNimDeployment, err = commonController.SyncResource(ctx, r.Client, dynamoNimDeployment, types.NamespacedName{Name: dynamoNimDeployment.Name, Namespace: dynamoNimDeployment.Namespace}, false) dynamoComponentDeployment, err = commonController.SyncResource(ctx, r.Client, dynamoComponentDeployment, types.NamespacedName{Name: dynamoComponentDeployment.Name, Namespace: dynamoComponentDeployment.Namespace}, false)
if err != nil { if err != nil {
reason = "failed_to_sync_the_DynamoNimDeployment" reason = "failed_to_sync_the_DynamoNimDeployment"
return ctrl.Result{}, err return ctrl.Result{}, err
} }
if !dynamoNimDeployment.Status.IsReady() { if !dynamoComponentDeployment.Status.IsReady() {
notReadyDeployments = append(notReadyDeployments, dynamoNimDeployment.Name) notReadyDeployments = append(notReadyDeployments, dynamoComponentDeployment.Name)
} }
} }
if len(notReadyDeployments) == 0 { if len(notReadyDeployments) == 0 {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package nim package dynamo
import ( import (
"bytes" "bytes"
...@@ -26,12 +26,11 @@ import ( ...@@ -26,12 +26,11 @@ import (
"strings" "strings"
"emperror.dev/errors" "emperror.dev/errors"
apiStoreClient "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/api_store_client"
compounaiCommon "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/common" compounaiCommon "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/common"
"github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/schemas" "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/schemas"
yataiclient "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/dynamo/yatai-client"
"github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/v1alpha1" "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/api/v1alpha1"
commonconfig "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/config" commonconfig "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/config"
commonconsts "github.com/ai-dynamo/dynamo/deploy/dynamo/operator/internal/consts"
"github.com/huandu/xstrings" "github.com/huandu/xstrings"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors" k8serrors "k8s.io/apimachinery/pkg/api/errors"
...@@ -89,58 +88,53 @@ func GetDefaultDynamoNamespace(ctx context.Context, dynamoDeployment *v1alpha1.D ...@@ -89,58 +88,53 @@ func GetDefaultDynamoNamespace(ctx context.Context, dynamoDeployment *v1alpha1.D
return fmt.Sprintf("dynamo-%s", dynamoDeployment.Name) return fmt.Sprintf("dynamo-%s", dynamoDeployment.Name)
} }
func RetrieveDynamoNimDownloadURL(ctx context.Context, dynamoDeployment *v1alpha1.DynamoDeployment, recorder EventRecorder) (*string, *string, error) { func RetrieveDynamoGraphDownloadURL(ctx context.Context, dynamoDeployment *v1alpha1.DynamoDeployment, recorder EventRecorder) (*string, error) {
dynamoNimDownloadURL := "" dynamoGraphDownloadURL := ""
dynamoNimApiToken := "" var dynamoComponent *schemas.DynamoComponent
var dynamoNim *schemas.DynamoNIM dynamoComponentRepositoryName, _, dynamoComponentVersion := xstrings.Partition(dynamoDeployment.Spec.DynamoNim, ":")
dynamoNimRepositoryName, _, dynamoNimVersion := xstrings.Partition(dynamoDeployment.Spec.DynamoNim, ":")
var err error var err error
var yataiClient_ **yataiclient.YataiClient var apiStoreClient *apiStoreClient.ApiStoreClient
var yataiConf_ **commonconfig.YataiConfig var apiStoreConf *commonconfig.ApiStoreConfig
yataiClient_, yataiConf_, err = GetYataiClient(ctx) apiStoreClient, apiStoreConf, err = GetApiStoreClient(ctx)
if err != nil { if err != nil {
err = errors.Wrap(err, "get yatai client") err = errors.Wrap(err, "get api store client")
return nil, nil, err return nil, err
} }
if yataiClient_ == nil || yataiConf_ == nil { if apiStoreClient == nil || apiStoreConf == nil {
err = errors.New("can't get yatai client, please check yatai configuration") err = errors.New("can't get api store client, please check api store configuration")
return nil, nil, err return nil, err
} }
yataiClient := *yataiClient_ recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Getting dynamo graph %s from api store service", dynamoDeployment.Spec.DynamoNim)
yataiConf := *yataiConf_ dynamoComponent, err = apiStoreClient.GetDynamoComponent(ctx, dynamoComponentRepositoryName, dynamoComponentVersion)
recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Getting dynamoNim %s from yatai service", dynamoDeployment.Spec.DynamoNim)
dynamoNim, err = yataiClient.GetBento(ctx, dynamoNimRepositoryName, dynamoNimVersion)
if err != nil { if err != nil {
err = errors.Wrap(err, "get dynamoNim") err = errors.Wrap(err, "get dynamo component")
return nil, nil, err return nil, err
} }
recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Got dynamoNim %s from yatai service", dynamoDeployment.Spec.DynamoNim) recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Got dynamo graph %s from api store service", dynamoDeployment.Spec.DynamoNim)
if dynamoNim.TransmissionStrategy != nil && *dynamoNim.TransmissionStrategy == schemas.TransmissionStrategyPresignedURL { if dynamoComponent.TransmissionStrategy != nil && *dynamoComponent.TransmissionStrategy == schemas.TransmissionStrategyPresignedURL {
var dynamoNim_ *schemas.DynamoNIM var dynamoComponent_ *schemas.DynamoComponent
recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Getting presigned url for dynamoNim %s from yatai service", dynamoDeployment.Spec.DynamoNim) recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Getting presigned url for dynamo graph %s from api store service", dynamoDeployment.Spec.DynamoNim)
dynamoNim_, err = yataiClient.PresignBentoDownloadURL(ctx, dynamoNimRepositoryName, dynamoNimVersion) dynamoComponent_, err = apiStoreClient.PresignDynamoComponentDownloadURL(ctx, dynamoComponentRepositoryName, dynamoComponentVersion)
if err != nil { if err != nil {
err = errors.Wrap(err, "presign dynamoNim download url") err = errors.Wrap(err, "presign dynamo component download url")
return nil, nil, err return nil, err
} }
recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Got presigned url for dynamoNim %s from yatai service", dynamoDeployment.Spec.DynamoNim) recorder.Eventf(dynamoDeployment, corev1.EventTypeNormal, "GenerateImageBuilderPod", "Got presigned url for dynamo graph %s from api store service", dynamoDeployment.Spec.DynamoNim)
dynamoNimDownloadURL = dynamoNim_.PresignedDownloadUrl dynamoGraphDownloadURL = dynamoComponent_.PresignedDownloadUrl
} else { } else {
dynamoNimDownloadURL = fmt.Sprintf("%s/api/v1/dynamo_nims/%s/versions/%s/download", yataiConf.Endpoint, dynamoNimRepositoryName, dynamoNimVersion) dynamoGraphDownloadURL = fmt.Sprintf("%s/api/v1/dynamo_nims/%s/versions/%s/download", apiStoreConf.Endpoint, dynamoComponentRepositoryName, dynamoComponentVersion)
dynamoNimApiToken = fmt.Sprintf("%s:%s:$%s", commonconsts.YataiImageBuilderComponentName, yataiConf.ClusterName, commonconsts.EnvYataiApiToken)
} }
return &dynamoNimDownloadURL, &dynamoNimApiToken, nil return &dynamoGraphDownloadURL, nil
} }
// ServicesConfig represents the top-level YAML structure of a dynamoNim yaml file stored in a dynamoNim tar file // ServicesConfig represents the top-level YAML structure of a dynamoNim yaml file stored in a dynamoNim tar file
type DynamoNIMConfig struct { type DynamoGraphConfig struct {
DynamoTag string `yaml:"service"` DynamoTag string `yaml:"service"`
Services []ServiceConfig `yaml:"services"` Services []ServiceConfig `yaml:"services"`
EntryService string `yaml:"entry_service"` EntryService string `yaml:"entry_service"`
...@@ -150,12 +144,11 @@ type EventRecorder interface { ...@@ -150,12 +144,11 @@ type EventRecorder interface {
Eventf(obj runtime.Object, eventtype string, reason string, message string, args ...interface{}) Eventf(obj runtime.Object, eventtype string, reason string, message string, args ...interface{})
} }
func RetrieveDynamoNIMConfigurationFile(ctx context.Context, url string, yataiApiToken string) (*bytes.Buffer, error) { func RetrieveDynamoGraphConfigurationFile(ctx context.Context, url string) (*bytes.Buffer, error) {
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header.Set(commonconsts.YataiApiTokenHeaderName, yataiApiToken)
client := &http.Client{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)
...@@ -185,55 +178,53 @@ func RetrieveDynamoNIMConfigurationFile(ctx context.Context, url string, yataiAp ...@@ -185,55 +178,53 @@ func RetrieveDynamoNIMConfigurationFile(ctx context.Context, url string, yataiAp
return yamlContent, nil return yamlContent, nil
} }
func GetYataiClient(ctx context.Context) (yataiClient **yataiclient.YataiClient, yataiConf **commonconfig.YataiConfig, err error) { func GetApiStoreClient(ctx context.Context) (*apiStoreClient.ApiStoreClient, *commonconfig.ApiStoreConfig, error) {
yataiConf_, err := commonconfig.GetYataiConfig(ctx) apiStoreConf, err := commonconfig.GetApiStoreConfig(ctx)
isNotFound := k8serrors.IsNotFound(err) isNotFound := k8serrors.IsNotFound(err)
if err != nil && !isNotFound { if err != nil && !isNotFound {
err = errors.Wrap(err, "get yatai config") err = errors.Wrap(err, "get api store config")
return return nil, nil, err
} }
if isNotFound { if isNotFound {
return return nil, nil, errors.New("endpoint config not found")
} }
if yataiConf_.Endpoint == "" { if apiStoreConf.Endpoint == "" {
return return nil, nil, errors.New("endpoint is empty")
} }
if yataiConf_.ClusterName == "" { if apiStoreConf.ClusterName == "" {
yataiConf_.ClusterName = "default" apiStoreConf.ClusterName = "default"
} }
yataiClient_ := yataiclient.NewYataiClient(yataiConf_.Endpoint, fmt.Sprintf("%s:%s:%s", commonconsts.YataiImageBuilderComponentName, yataiConf_.ClusterName, yataiConf_.ApiToken)) apiStoreClient := apiStoreClient.NewApiStoreClient(apiStoreConf.Endpoint)
yataiClient = &yataiClient_ return apiStoreClient, apiStoreConf, nil
yataiConf = &yataiConf_
return
} }
func ParseDynamoNIMConfig(ctx context.Context, yamlContent *bytes.Buffer) (*DynamoNIMConfig, error) { func ParseDynamoGraphConfig(ctx context.Context, yamlContent *bytes.Buffer) (*DynamoGraphConfig, error) {
var config DynamoNIMConfig var config DynamoGraphConfig
logger := log.FromContext(ctx) logger := log.FromContext(ctx)
logger.Info("trying to parse dynamoNim config", "yamlContent", yamlContent.String()) logger.Info("trying to parse dynamo graph config", "yamlContent", yamlContent.String())
err := yaml.Unmarshal(yamlContent.Bytes(), &config) err := yaml.Unmarshal(yamlContent.Bytes(), &config)
return &config, err return &config, err
} }
func GetDynamoNIMConfig(ctx context.Context, dynamoDeployment *v1alpha1.DynamoDeployment, recorder EventRecorder) (*DynamoNIMConfig, error) { func GetDynamoGraphConfig(ctx context.Context, dynamoDeployment *v1alpha1.DynamoDeployment, recorder EventRecorder) (*DynamoGraphConfig, error) {
dynamoNimDownloadURL, dynamoNimApiToken, err := RetrieveDynamoNimDownloadURL(ctx, dynamoDeployment, recorder) dynamoGraphDownloadURL, err := RetrieveDynamoGraphDownloadURL(ctx, dynamoDeployment, recorder)
if err != nil { if err != nil {
return nil, err return nil, err
} }
yamlContent, err := RetrieveDynamoNIMConfigurationFile(ctx, *dynamoNimDownloadURL, *dynamoNimApiToken) yamlContent, err := RetrieveDynamoGraphConfigurationFile(ctx, *dynamoGraphDownloadURL)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return ParseDynamoNIMConfig(ctx, yamlContent) return ParseDynamoGraphConfig(ctx, yamlContent)
} }
// generate DynamoNIMDeployment from config // GenerateDynamoComponentsDeployments generates a map of DynamoComponentDeployments from a DynamoGraphConfig
func GenerateDynamoNIMDeployments(ctx context.Context, parentDynamoDeployment *v1alpha1.DynamoDeployment, config *DynamoNIMConfig, ingressSpec *v1alpha1.IngressSpec) (map[string]*v1alpha1.DynamoNimDeployment, error) { func GenerateDynamoComponentsDeployments(ctx context.Context, parentDynamoDeployment *v1alpha1.DynamoDeployment, config *DynamoGraphConfig, ingressSpec *v1alpha1.IngressSpec) (map[string]*v1alpha1.DynamoNimDeployment, error) {
dynamoServices := make(map[string]string) dynamoServices := make(map[string]string)
deployments := make(map[string]*v1alpha1.DynamoNimDeployment) deployments := make(map[string]*v1alpha1.DynamoNimDeployment)
for _, service := range config.Services { for _, service := range config.Services {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package nim package dynamo
import ( import (
"context" "context"
...@@ -30,7 +30,7 @@ import ( ...@@ -30,7 +30,7 @@ import (
func TestGenerateDynamoNIMDeployments(t *testing.T) { func TestGenerateDynamoNIMDeployments(t *testing.T) {
type args struct { type args struct {
parentDynamoDeployment *v1alpha1.DynamoDeployment parentDynamoDeployment *v1alpha1.DynamoDeployment
config *DynamoNIMConfig config *DynamoGraphConfig
ingressSpec *v1alpha1.IngressSpec ingressSpec *v1alpha1.IngressSpec
} }
tests := []struct { tests := []struct {
...@@ -51,7 +51,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) { ...@@ -51,7 +51,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) {
DynamoNim: "dynamonim:ac4e234", DynamoNim: "dynamonim:ac4e234",
}, },
}, },
config: &DynamoNIMConfig{ config: &DynamoGraphConfig{
DynamoTag: "dynamonim:MyService1", DynamoTag: "dynamonim:MyService1",
Services: []ServiceConfig{ Services: []ServiceConfig{
{ {
...@@ -159,7 +159,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) { ...@@ -159,7 +159,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) {
DynamoNim: "dynamonim:ac4e234", DynamoNim: "dynamonim:ac4e234",
}, },
}, },
config: &DynamoNIMConfig{ config: &DynamoGraphConfig{
DynamoTag: "dynamonim:MyService2", DynamoTag: "dynamonim:MyService2",
EntryService: "service1", EntryService: "service1",
Services: []ServiceConfig{ Services: []ServiceConfig{
...@@ -272,7 +272,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) { ...@@ -272,7 +272,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) {
DynamoNim: "dynamonim:ac4e234", DynamoNim: "dynamonim:ac4e234",
}, },
}, },
config: &DynamoNIMConfig{ config: &DynamoGraphConfig{
DynamoTag: "dynamonim:MyService2", DynamoTag: "dynamonim:MyService2",
EntryService: "service1", EntryService: "service1",
Services: []ServiceConfig{ Services: []ServiceConfig{
...@@ -378,7 +378,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) { ...@@ -378,7 +378,7 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) {
DynamoNim: "dynamonim:ac4e234", DynamoNim: "dynamonim:ac4e234",
}, },
}, },
config: &DynamoNIMConfig{ config: &DynamoGraphConfig{
DynamoTag: "dynamonim:MyService3", DynamoTag: "dynamonim:MyService3",
Services: []ServiceConfig{ Services: []ServiceConfig{
{ {
...@@ -423,9 +423,9 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) { ...@@ -423,9 +423,9 @@ func TestGenerateDynamoNIMDeployments(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
g := gomega.NewGomegaWithT(t) g := gomega.NewGomegaWithT(t)
got, err := GenerateDynamoNIMDeployments(context.Background(), tt.args.parentDynamoDeployment, tt.args.config, tt.args.ingressSpec) got, err := GenerateDynamoComponentsDeployments(context.Background(), tt.args.parentDynamoDeployment, tt.args.config, tt.args.ingressSpec)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("GenerateDynamoNIMDeployments() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("GenerateDynamoComponentsDeployments() error = %v, wantErr %v", err, tt.wantErr)
return return
} }
g.Expect(got).To(gomega.Equal(tt.want)) g.Expect(got).To(gomega.Equal(tt.want))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment