Skip to content

Commit

Permalink
add manifests for odh-model-controller and model-mesh (opendatahub-io…
Browse files Browse the repository at this point in the history
…#639)

* add manifests for odh-model-controller and model-mesh

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

* update correct release branches for modelmesh

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

* fix odh-model-controller not getting uninstalled

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

* fix lint

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

* correct release branch for modelmesh to 0.11.0

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

* support adding multiple repos in modelmesh devFlags

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>

---------

Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>
  • Loading branch information
VedantMahabaleshwarkar authored Oct 20, 2023
1 parent 3312a8e commit 2231cba
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 19 deletions.
7 changes: 6 additions & 1 deletion components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci
}
}
}

if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, k.GetComponentName(), enabled); err != nil {
return err
if strings.Contains(err.Error(), "spec.selector") && strings.Contains(err.Error(), "field is immutable") {
// ignore this error
} else {
return err
}
}

return nil
Expand Down
75 changes: 59 additions & 16 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package modelmeshserving
import (
"context"
"path/filepath"
"strings"

dsci "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
Expand All @@ -15,28 +16,45 @@ import (
)

var (
ComponentName = "model-mesh"
Path = deploy.DefaultManifestPath + "/" + ComponentName + "/base"
monitoringPath = deploy.DefaultManifestPath + "/" + "modelmesh-monitoring/base"
ComponentName = "model-mesh"
Path = deploy.DefaultManifestPath + "/" + ComponentName + "/overlays/odh"
monitoringPath = deploy.DefaultManifestPath + "/" + "modelmesh-monitoring/base"
DependentComponentName = "odh-model-controller"
DependentPath = deploy.DefaultManifestPath + "/" + DependentComponentName + "/base"
)

type ModelMeshServing struct {
components.Component `json:""`
}

func (m *ModelMeshServing) OverrideManifests(_ string) error {
// If devflags are set, update default manifests path
if len(m.DevFlags.Manifests) != 0 {
manifestConfig := m.DevFlags.Manifests[0]
if err := deploy.DownloadManifests(ComponentName, manifestConfig); err != nil {
return err
// Go through each manifests and set the overlays if defined
for _, subcomponent := range m.DevFlags.Manifests {
if strings.Contains(subcomponent.URI, DependentComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "base"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
DependentPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath)
}
// If overlay is defined, update paths
defaultKustomizePath := "base"
if manifestConfig.SourcePath != "" {
defaultKustomizePath = manifestConfig.SourcePath

if strings.Contains(subcomponent.URI, ComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "overlays/odh"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
return nil
}
Expand All @@ -57,6 +75,11 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
"odh-model-controller": "RELATED_IMAGE_ODH_MODEL_CONTROLLER_IMAGE",
}

// odh-model-controller to use
var dependentImageParamMap = map[string]string{
"odh-model-controller": "RELATED_IMAGE_ODH_MODEL_CONTROLLER_IMAGE",
}

enabled := m.GetManagementState() == operatorv1.Managed
platform, err := deploy.GetPlatform(cli)
if err != nil {
Expand All @@ -69,9 +92,8 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
if err = m.OverrideManifests(string(platform)); err != nil {
return err
}
err := common.UpdatePodSecurityRolebinding(cli,
[]string{"modelmesh", "modelmesh-controller", "odh-model-controller", "odh-prometheus-operator", "prometheus-custom"},
dscispec.ApplicationsNamespace)

err := common.UpdatePodSecurityRolebinding(cli, []string{"modelmesh", "modelmesh-controller", "odh-prometheus-operator", "prometheus-custom"}, dscispec.ApplicationsNamespace)
if err != nil {
return err
}
Expand All @@ -88,6 +110,27 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
return err
}

// For odh-model-controller
if enabled {
err := common.UpdatePodSecurityRolebinding(cli, []string{"odh-model-controller"}, dscispec.ApplicationsNamespace)
if err != nil {
return err
}
// Update image parameters for odh-model-controller
if dscispec.DevFlags.ManifestsUri == "" {
if err := deploy.ApplyParams(DependentPath, m.SetImageParamsMap(dependentImageParamMap), false); err != nil {
return err
}
}
}
if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, m.GetComponentName(), enabled); err != nil {
if strings.Contains(err.Error(), "spec.selector") && strings.Contains(err.Error(), "field is immutable") {
// ignore this error
} else {
return err
}
}

// Get monitoring namespace
dscInit := &dsci.DSCInitialization{}
err = cli.Get(context.TODO(), client.ObjectKey{
Expand Down
4 changes: 2 additions & 2 deletions get_all_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ declare -A COMPONENT_MANIFESTS=(
["odh-notebook-controller"]="opendatahub-io:kubeflow:v1.7-branch:components/odh-notebook-controller/config:odh-notebook-controller/odh-notebook-controller"
["notebooks"]="opendatahub-io:notebooks:main:manifests:notebooks"
["trustyai"]="trustyai-explainability:trustyai-service-operator:release/1.10.2:config:trustyai-service-operator"
["model-mesh"]="opendatahub-io:modelmesh-serving:release-0.11.0:config:model-mesh"
["odh-model-controller"]="opendatahub-io:odh-model-controller:release-0.11.0:config:odh-model-controller"
)

# Allow overwriting repo using flags component=repo
Expand Down Expand Up @@ -50,8 +52,6 @@ rm -fr ./odh-manifests/* ./.odh-manifests-tmp/

mkdir -p ./.odh-manifests-tmp/ ./odh-manifests/
wget -q -c ${MANIFESTS_TARBALL_URL} -O - | tar -zxv -C ./.odh-manifests-tmp/ --strip-components 1 > /dev/null
cp -r ./.odh-manifests-tmp/model-mesh/ ./odh-manifests
cp -r ./.odh-manifests-tmp/odh-model-controller/ ./odh-manifests
cp -r ./.odh-manifests-tmp/modelmesh-monitoring/ ./odh-manifests
cp -r ./.odh-manifests-tmp/kserve/ ./odh-manifests
rm -rf ${MANIFEST_RELEASE}.tar.gz ./.odh-manifests-tmp/
Expand Down

0 comments on commit 2231cba

Please sign in to comment.