forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ModelRegistry component (opendatahub-io#775) (opendatahub-i…
…o#776) * feat: Add ModelRegistry component (opendatahub-io#775) * fix: Fix modelregistry odh overlays path * fix: fix dsc_create_test tests err nil check * fix: refactor ModelRegistry.ReconcileComponent for new parameters * chore: added modelregistry to README.md * fix: add missing rbac rules for deploymentconfigs and daemonsets * chore: code lint cleanup * fix: added check for nil DevFlags in model-registry component * fix: add nil check for dscispec.DevFlags in model-registry ReconcileComponent * fix: remove RBAC rules for daemonsets and deploymentconfigs * fix(chore): fix lint errors in dsc_deletion_test.go
- Loading branch information
Showing
17 changed files
with
319 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Package modelregistry provides utility functions to config ModelRegistry, an ML Model metadata repository service | ||
package modelregistry | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
|
||
operatorv1 "github.com/openshift/api/operator/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/components" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" | ||
) | ||
|
||
var ( | ||
ComponentName = "model-registry-operator" | ||
Path = deploy.DefaultManifestPath + "/" + ComponentName + "/overlays/odh" | ||
) | ||
|
||
// Verifies that ModelRegistry implements ComponentInterface. | ||
var _ components.ComponentInterface = (*ModelRegistry)(nil) | ||
|
||
// ModelRegistry struct holds the configuration for the ModelRegistry component. | ||
// +kubebuilder:object:generate=true | ||
type ModelRegistry struct { | ||
components.Component `json:""` | ||
} | ||
|
||
func (m *ModelRegistry) 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 | ||
} | ||
// If overlay is defined, update paths | ||
defaultKustomizePath := "overlays/odh" | ||
if manifestConfig.SourcePath != "" { | ||
defaultKustomizePath = manifestConfig.SourcePath | ||
} | ||
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *ModelRegistry) GetComponentName() string { | ||
return ComponentName | ||
} | ||
|
||
func (m *ModelRegistry) ReconcileComponent(_ context.Context, cli client.Client, _ *rest.Config, | ||
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, _ bool) error { | ||
var imageParamMap = map[string]string{ | ||
"IMAGES_MODELREGISTRY_OPERATOR": "RELATED_IMAGE_ODH_MODELREGISTRY_OPERATOR_IMAGE", | ||
"IMAGES_GRPC_SERVICE": "RELATED_IMAGE_ODH_MODELREGISTRY_GRPC_SERVICE_IMAGE", | ||
"IMAGES_REST_SERVICE": "RELATED_IMAGE_ODH_MODELREGISTRY_REST_SERVICE_IMAGE", | ||
} | ||
enabled := m.GetManagementState() == operatorv1.Managed | ||
|
||
platform, err := deploy.GetPlatform(cli) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if enabled { | ||
if m.DevFlags != nil { | ||
// Download manifests and update paths | ||
if err = m.OverrideManifests(string(platform)); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// Update image parameters only when we do not have customized manifests set | ||
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (m.DevFlags == nil || len(m.DevFlags.Manifests) == 0) { | ||
if err := deploy.ApplyParams(Path, m.SetImageParamsMap(imageParamMap), false); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
// Deploy ModelRegistry Operator | ||
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, m.GetComponentName(), enabled) | ||
|
||
return err | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ spec: | |
managementState: "Managed" | ||
trustyai: | ||
managementState: "Managed" | ||
modelregistry: | ||
managementState: "Removed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.