Skip to content

Commit

Permalink
Create ModelRegistry component API and reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Nov 4, 2024
1 parent 86668ce commit 69e62d4
Show file tree
Hide file tree
Showing 32 changed files with 1,155 additions and 484 deletions.
54 changes: 45 additions & 9 deletions apis/components/v1/modelregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,45 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
const (
ModelRegistryComponentName = "model-registry-operator"
// ModelRegistryInstanceName the name of the ModelRegistry instance singleton.
// value should match what's set in the XValidation below
ModelRegistryInstanceName = "default-model-registry"
ModelRegistryKind = "ModelRegistry"
)

// ModelRegistryCommonSpec spec defines the shared desired state of ModelRegistry
type ModelRegistryCommonSpec struct {
// model registry spec exposed to DSC api
components.DevFlagsSpec `json:",inline"`

// Namespace for model registries to be installed, configurable only once when model registry is enabled, defaults to "odh-model-registries"
// +kubebuilder:default="odh-model-registries"
// +kubebuilder:validation:Pattern="^([a-z0-9]([-a-z0-9]*[a-z0-9])?)?$"
// +kubebuilder:validation:MaxLength=63
RegistriesNamespace string `json:"registriesNamespace,omitempty"`
}

// ModelRegistrySpec defines the desired state of ModelRegistry
type ModelRegistrySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of ModelRegistry. Edit modelregistry_types.go to remove/update
Foo string `json:"foo,omitempty"`
// model registry spec exposed to DSC api
ModelRegistryCommonSpec `json:",inline"`
// model registry spec exposed only to internal api
}

// ModelRegistryStatus defines the observed state of ModelRegistry
type ModelRegistryStatus struct {
components.Status `json:",inline"`
components.Status `json:",inline"`
DSCModelRegistryStatus `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-model-registry'",message="ModelRegistry name must be default-model-registry"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready"
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason"

// ModelRegistry is the Schema for the modelregistries API
type ModelRegistry struct {
Expand All @@ -52,7 +71,7 @@ type ModelRegistry struct {
}

func (c *ModelRegistry) GetDevFlags() *components.DevFlags {
return nil
return c.Spec.DevFlags
}

func (c *ModelRegistry) GetStatus() *components.Status {
Expand All @@ -71,3 +90,20 @@ type ModelRegistryList struct {
func init() {
SchemeBuilder.Register(&ModelRegistry{}, &ModelRegistryList{})
}

// +kubebuilder:object:generate=true
// +kubebuilder:validation:XValidation:rule="(self.managementState != 'Managed') || (oldSelf.registriesNamespace == '') || (oldSelf.managementState != 'Managed')|| (self.registriesNamespace == oldSelf.registriesNamespace)",message="RegistriesNamespace is immutable when model registry is Managed"
//nolint:lll

// DSCModelRegistry contains all the configuration exposed in DSC instance for ModelRegistry component
type DSCModelRegistry struct {
// configuration fields common across components
components.ManagementSpec `json:",inline"`
// model registry specific field
ModelRegistryCommonSpec `json:",inline"`
}

// DSCModelRegistryStatus struct holds the status for the ModelRegistry component exposed in the DSC
type DSCModelRegistryStatus struct {
RegistriesNamespace string `json:"registriesNamespace,omitempty"`
}
52 changes: 51 additions & 1 deletion apis/components/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components/kserve"
"github.com/opendatahub-io/opendatahub-operator/v2/components/kueue"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelmeshserving"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelregistry"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trainingoperator"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trustyai"
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
)

Expand Down Expand Up @@ -80,16 +78,16 @@ type Components struct {
TrustyAI trustyai.TrustyAI `json:"trustyai,omitempty"`

// ModelRegistry component configuration.
ModelRegistry modelregistry.ModelRegistry `json:"modelregistry,omitempty"`
ModelRegistry componentsv1.DSCModelRegistry `json:"modelregistry,omitempty"`

//Training Operator component configuration.
// Training Operator component configuration.
TrainingOperator trainingoperator.TrainingOperator `json:"trainingoperator,omitempty"`
}

// ComponentsStatus defines the custom status of DataScienceCluster components.
type ComponentsStatus struct {
// ModelRegistry component status
ModelRegistry *status.ModelRegistryStatus `json:"modelregistry,omitempty"`
ModelRegistry *componentsv1.DSCModelRegistryStatus `json:"modelregistry,omitempty"`
}

// DataScienceClusterStatus defines the observed state of DataScienceCluster.
Expand Down Expand Up @@ -119,10 +117,10 @@ type DataScienceClusterStatus struct {
Release cluster.Release `json:"release,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster,shortName=dsc
//+kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,shortName=dsc
// +kubebuilder:storageversion

// DataScienceCluster is the Schema for the datascienceclusters API.
type DataScienceCluster struct {
Expand All @@ -133,7 +131,7 @@ type DataScienceCluster struct {
Status DataScienceClusterStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// DataScienceClusterList contains a list of DataScienceCluster.
type DataScienceClusterList struct {
Expand Down
4 changes: 2 additions & 2 deletions apis/datasciencecluster/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 69e62d4

Please sign in to comment.