Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ModelRegistry component API and reconciler #1337

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

51 changes: 47 additions & 4 deletions bundle/manifests/components.opendatahub.io_modelregistries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ spec:
singular: modelregistry
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Ready
jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- description: Reason
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1
schema:
openAPIV3Schema:
description: ModelRegistry is the Schema for the modelregistries API
Expand All @@ -39,9 +48,38 @@ spec:
spec:
description: ModelRegistrySpec defines the desired state of ModelRegistry
properties:
foo:
description: Foo is an example field of ModelRegistry. Edit modelregistry_types.go
to remove/update
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the folder
containing manifests in a repository, default value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any sub-folder
or path: `base`, `overlays/dev`, `default`, `odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with tag/branch.
e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
registriesNamespace:
default: odh-model-registries
description: Namespace for model registries to be installed, configurable
only once when model registry is enabled, defaults to "odh-model-registries"
maxLength: 63
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?)?$
type: string
type: object
status:
Expand Down Expand Up @@ -108,8 +146,13 @@ spec:
type: integer
phase:
type: string
registriesNamespace:
type: string
type: object
type: object
x-kubernetes-validations:
- message: ModelRegistry name must be default-model-registry
rule: self.metadata.name == 'default-model-registry'
served: true
storage: true
subresources:
Expand Down
Loading