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>
(cherry picked from commit 2231cba)
  • Loading branch information
VedantMahabaleshwarkar authored and VaishnaviHire committed Oct 20, 2023
1 parent a0e9b00 commit 830aa1a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 27 deletions.
9 changes: 7 additions & 2 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci
}
}
}
if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
return err

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

return nil
Expand Down
83 changes: 58 additions & 25 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
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 @@ -17,28 +16,44 @@ import (

var (
ComponentName = "model-mesh"
Path = deploy.DefaultManifestPath + "/" + ComponentName + "/base"
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 @@ -59,6 +74,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
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
platform, err := deploy.GetPlatform(cli)
Expand All @@ -71,9 +91,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 @@ -90,17 +109,31 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
return err
}

// Get modelmesh monitoring namespace
dscInit := &dsciv1.DSCInitialization{}
err = cli.Get(context.TODO(), client.ObjectKey{
Name: "default",
}, dscInit)
if err != nil {
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
var monitoringNamespace string
if dscInit.Spec.Monitoring.Namespace != "" {
monitoringNamespace = dscInit.Spec.Monitoring.Namespace
if dscispec.Monitoring.Namespace != "" {
monitoringNamespace = dscispec.Monitoring.Namespace
} else {
monitoringNamespace = dscispec.ApplicationsNamespace
}
Expand Down
5 changes: 5 additions & 0 deletions get_all_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 @@ -60,9 +62,12 @@ MANIFESTS_TARBALL_URL="${GITHUB_URL}/${MANIFEST_ORG}/odh-manifests/tarball/${MAN

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
<<<<<<< HEAD
# modelmesh
cp -r ./.odh-manifests-tmp/model-mesh/ ./odh-manifests
cp -r ./.odh-manifests-tmp/odh-model-controller/ ./odh-manifests
=======
>>>>>>> 2231cba1 (add manifests for odh-model-controller and model-mesh (#639))
cp -r ./.odh-manifests-tmp/modelmesh-monitoring/ ./odh-manifests
# Kserve
cp -r ./.odh-manifests-tmp/kserve/ ./odh-manifests
Expand Down

0 comments on commit 830aa1a

Please sign in to comment.