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

feat: add support for modelmeshserving as component #1338

Merged
93 changes: 93 additions & 0 deletions apis/components/v1/modelcontroller_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
"github.com/opendatahub-io/opendatahub-operator/v2/apis/common"
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// shared by kserve and modelmeshserving
// value should match whats set in the XValidation below
ModelControllerInstanceName = "default-modelcontroller"
ModelControllerKind = "ModelController"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-modelcontroller'",message="ModelController name must be default-modelcontroller"
// +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"
// +kubebuilder:printcolumn:name="URI",type=string,JSONPath=`.status.URI`,description="devFlag's URI used to download"

// ModelController is the Schema for the modelcontroller API, it is a shared component between kserve and modelmeshserving
type ModelController struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ModelControllerSpec `json:"spec,omitempty"`
Status ModelControllerStatus `json:"status,omitempty"`
}

// ModelControllerSpec defines the desired state of ModelController
type ModelControllerSpec struct {
//ModelMeshServing DSCModelMeshServing `json:"modelMeshServing,omitempty"`
Kserve *ModelControllerKerveSpec `json:"kserve,omitempty"`
ModelMeshServing *ModelControllerMMSpec `json:"modelMeshServing,omitempty"`
}

// a mini version of the DSCKserve only keep devflags and management spec
type ModelControllerKerveSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

// a mini version of the DSCModelMeshServing only keep devflags and management spec
type ModelControllerMMSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

// ModelControllerStatus defines the observed state of ModelController
type ModelControllerStatus struct {
common.Status `json:",inline"`
// devflag's URI
URI string `json:"URI,omitempty"`
}

// +kubebuilder:object:root=true
// ModelControllerList contains a list of ModelController
type ModelControllerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ModelController `json:"items"`
}

func init() {
SchemeBuilder.Register(&ModelController{}, &ModelControllerList{})
}

func (c *ModelController) GetDevFlags() *common.DevFlags { return nil }

func (c *ModelController) GetStatus() *common.Status {
return &c.Status.Status
}
54 changes: 34 additions & 20 deletions apis/components/v1/modelmeshserving_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,21 @@ 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.

// ModelMeshServingSpec defines the desired state of ModelMeshServing
type ModelMeshServingSpec 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 ModelMeshServing. Edit modelmeshserving_types.go to remove/update
Foo string `json:"foo,omitempty"`
}
const (
ModelMeshServingComponentName = "model-mesh"
// value should match whats set in the XValidation below
ModelMeshServingInstanceName = "default-modelmesh"
ModelMeshServingKind = "ModelMeshServing"
)

// ModelMeshServingStatus defines the observed state of ModelMeshServing
type ModelMeshServingStatus struct {
common.Status `json:",inline"`
}
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-modelmesh'",message="ModelMeshServing name must be default-modelmesh"
// +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"

// ModelMeshServing is the Schema for the modelmeshservings API
type ModelMeshServing struct {
Expand All @@ -51,16 +46,21 @@ type ModelMeshServing struct {
Status ModelMeshServingStatus `json:"status,omitempty"`
}

func (c *ModelMeshServing) GetDevFlags() *common.DevFlags {
return nil
// ModelMeshServingSpec defines the desired state of ModelMeshServing
type ModelMeshServingSpec struct {
ModelMeshServingCommonSpec `json:",inline"`
}

func (c *ModelMeshServing) GetStatus() *common.Status {
return &c.Status.Status
type ModelMeshServingCommonSpec struct {
common.DevFlagsSpec `json:",inline"`
}

// +kubebuilder:object:root=true
// ModelMeshServingStatus defines the observed state of ModelMeshServing
type ModelMeshServingStatus struct {
common.Status `json:",inline"`
}

// +kubebuilder:object:root=true
// ModelMeshServingList contains a list of ModelMeshServing
type ModelMeshServingList struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -71,3 +71,17 @@ type ModelMeshServingList struct {
func init() {
SchemeBuilder.Register(&ModelMeshServing{}, &ModelMeshServingList{})
}

func (c *ModelMeshServing) GetDevFlags() *common.DevFlags {
return c.Spec.DevFlags
}
func (c *ModelMeshServing) GetStatus() *common.Status {
return &c.Status.Status
}

// DSCModelMeshServing contains all the configuration exposed in DSC instance for ModelMeshServing component
type DSCModelMeshServing struct {
common.ManagementSpec `json:",inline"`
// configuration fields common across components
ModelMeshServingCommonSpec `json:",inline"`
}
168 changes: 167 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.

4 changes: 1 addition & 3 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelmeshserving"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
)

Expand All @@ -45,8 +44,7 @@ type Components struct {
Workbenches componentsv1.DSCWorkbenches `json:"workbenches,omitempty"`

// ModelMeshServing component configuration.
// Does not support enabled Kserve at the same time
ModelMeshServing modelmeshserving.ModelMeshServing `json:"modelmeshserving,omitempty"`
ModelMeshServing componentsv1.DSCModelMeshServing `json:"modelmeshserving,omitempty"`

// DataServicePipeline component configuration.
// Require OpenShift Pipelines Operator to be installed before enable component
Expand Down
Loading
Loading