Skip to content

Commit

Permalink
feat: initial move of kserve to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
grdryn committed Nov 12, 2024
1 parent 466473e commit 217ca78
Show file tree
Hide file tree
Showing 41 changed files with 1,370 additions and 700 deletions.
56 changes: 48 additions & 8 deletions apis/components/v1/kserve_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,49 @@ limitations under the License.
package v1

import (
"github.com/opendatahub-io/opendatahub-operator/v2/apis/components"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/opendatahub-io/opendatahub-operator/v2/apis/components"
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
const (
KserveComponentName = "kserve"
// value should match what's set in the XValidation below
KserveInstanceName = "default-kserve"
KserveKind = "Kserve"
)

// +kubebuilder:validation:Pattern=`^(Serverless|RawDeployment)$`
type DefaultDeploymentMode string

const (
// Serverless will be used as the default deployment mode for Kserve. This requires Serverless and ServiceMesh operators configured as dependencies.
Serverless DefaultDeploymentMode = "Serverless"
// RawDeployment will be used as the default deployment mode for Kserve.
RawDeployment DefaultDeploymentMode = "RawDeployment"
)

// KserveCommonSpec spec defines the shared desired state of Kserve
type KserveCommonSpec struct {
components.DevFlagsSpec `json:",inline"`
// Serving configures the KNative-Serving stack used for model serving. A Service
// Mesh (Istio) is prerequisite, since it is used as networking layer.
Serving infrav1.ServingSpec `json:"serving,omitempty"`
// Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.
// The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.
// This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode.
// +kubebuilder:validation:Enum=Serverless;RawDeployment
DefaultDeploymentMode DefaultDeploymentMode `json:"defaultDeploymentMode,omitempty"`
}

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

// KserveSpec defines the desired state of Kserve
type KserveSpec 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 Kserve. Edit kserve_types.go to remove/update
Foo string `json:"foo,omitempty"`
// kserve spec exposed to DSC api
KserveCommonSpec `json:",inline"`
// kserve spec exposed only to internal api
}

// KserveStatus defines the observed state of Kserve
Expand All @@ -41,6 +70,9 @@ type KserveStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-kserve'",message="Kserve name must be default-kserve"
// +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"

// Kserve is the Schema for the kserves API
type Kserve struct {
Expand All @@ -52,7 +84,7 @@ type Kserve struct {
}

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

func (c *Kserve) GetStatus() *components.Status {
Expand All @@ -71,3 +103,11 @@ type KserveList struct {
func init() {
SchemeBuilder.Register(&Kserve{}, &KserveList{})
}

// DSCKserve contains all the configuration exposed in DSC instance for Kserve component
type DSCKserve struct {
// configuration fields common across components
components.ManagementSpec `json:",inline"`
// Kserve specific fields
KserveCommonSpec `json:",inline"`
}
37 changes: 36 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.

3 changes: 1 addition & 2 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/components/codeflare"
"github.com/opendatahub-io/opendatahub-operator/v2/components/datasciencepipelines"
"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/trainingoperator"
Expand Down Expand Up @@ -61,7 +60,7 @@ type Components struct {
// Kserve component configuration.
// Require OpenShift Serverless and OpenShift Service Mesh Operators to be installed before enable component
// Does not support enabled ModelMeshServing at the same time
Kserve kserve.Kserve `json:"kserve,omitempty"`
Kserve componentsv1.DSCKserve `json:"kserve,omitempty"`

// Kueue component configuration.
Kueue kueue.Kueue `json:"kueue,omitempty"`
Expand Down
110 changes: 106 additions & 4 deletions bundle/manifests/components.opendatahub.io_kserves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ spec:
singular: kserve
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: Kserve is the Schema for the kserves API
Expand All @@ -39,10 +48,100 @@ spec:
spec:
description: KserveSpec defines the desired state of Kserve
properties:
foo:
description: Foo is an example field of Kserve. Edit kserve_types.go
to remove/update
defaultDeploymentMode:
description: |-
Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.
The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.
This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode.
enum:
- Serverless
- RawDeployment
pattern: ^(Serverless|RawDeployment)$
type: string
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
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Mesh (Istio) is prerequisite, since it is used as networking layer.
properties:
ingressGateway:
description: |-
IngressGateway allows to customize some parameters for the Istio Ingress Gateway
that is bound to KNative-Serving.
properties:
certificate:
description: |-
Certificate specifies configuration of the TLS certificate securing communication
for the gateway.
properties:
secretName:
description: |-
SecretName specifies the name of the Kubernetes Secret resource that contains a
TLS certificate secure HTTP communications for the KNative network.
type: string
type:
default: OpenshiftDefaultIngress
description: |-
Type specifies if the TLS certificate should be generated automatically, or if the certificate
is provided by the user. Allowed values are:
* SelfSigned: A certificate is going to be generated using an own private key.
* Provided: Pre-existence of the TLS Secret (see SecretName) with a valid certificate is assumed.
* OpenshiftDefaultIngress: Default ingress certificate configured for OpenShift
enum:
- SelfSigned
- Provided
- OpenshiftDefaultIngress
type: string
type: object
domain:
description: |-
Domain specifies the host name for intercepting incoming requests.
Most likely, you will want to use a wildcard name, like *.example.com.
If not set, the domain of the OpenShift Ingress is used.
If you choose to generate a certificate, this is the domain used for the certificate request.
type: string
type: object
managementState:
default: Managed
enum:
- Managed
- Unmanaged
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
name:
default: knative-serving
description: |-
Name specifies the name of the KNativeServing resource that is going to be
created to instruct the KNative Operator to deploy KNative serving components.
This resource is created in the "knative-serving" namespace.
type: string
type: object
type: object
status:
description: KserveStatus defines the observed state of Kserve
Expand Down Expand Up @@ -110,6 +209,9 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: Kserve name must be default-kserve
rule: self.metadata.name == 'default-kserve'
served: true
storage: true
subresources:
Expand Down
Loading

0 comments on commit 217ca78

Please sign in to comment.