Skip to content

Commit

Permalink
feat: add TrustyAI as component (#1356)
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Nov 11, 2024
1 parent ef5552f commit 1209501
Show file tree
Hide file tree
Showing 21 changed files with 678 additions and 265 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Example commands to run test suite for the dashboard `component` only, with the
make run-nowebhook
```
```shell
make e2e-test -e OPERATOR_NAMESPACE=<namespace> -e E2E_TEST_FLAGS="--test-operator-controller=false --test-webhook=false --test-component=dashboard"
make e2e-test -e OPERATOR_NAMESPACE=<namespace> -e E2E_TEST_FLAGS="--test-operator-controller=false --test-webhook=false --test-component=dashboard,trustyai"
```


Expand Down
54 changes: 34 additions & 20 deletions apis/components/v1/trustyai_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.

// TrustyAISpec defines the desired state of TrustyAI
type TrustyAISpec 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 TrustyAI. Edit trustyai_types.go to remove/update
Foo string `json:"foo,omitempty"`
}
const (
TrustyAIComponentName = "trustyai"
// value should match whats set in the XValidation below
TrustyAIInstanceName = "default-trustyai"
TrustyAIKind = "TrustyAI"
)

// TrustyAIStatus defines the observed state of TrustyAI
type TrustyAIStatus struct {
components.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-trustyai'",message="TrustyAI name must be default-trustyai"
// +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"

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

func (c *TrustyAI) GetDevFlags() *components.DevFlags {
return nil
// TrustyAISpec defines the desired state of TrustyAI
type TrustyAISpec struct {
TrustyAICommonSpec `json:",inline"`
}

func (c *TrustyAI) GetStatus() *components.Status {
return &c.Status.Status
type TrustyAICommonSpec struct {
components.DevFlagsSpec `json:",inline"`
}

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

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

func (c *TrustyAI) GetDevFlags() *components.DevFlags {
return c.Spec.DevFlags
}
func (c *TrustyAI) GetStatus() *components.Status {
return &c.Status.Status
}

// DSCTrustyAI contains all the configuration exposed in DSC instance for TrustyAI component
type DSCTrustyAI struct {
components.ManagementSpec `json:",inline"`
// configuration fields common across components
TrustyAICommonSpec `json:",inline"`
}
36 changes: 35 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 @@ -32,7 +32,6 @@ import (
"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"
"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/pkg/cluster"
)
Expand Down Expand Up @@ -75,7 +74,7 @@ type Components struct {
Ray componentsv1.DSCRay `json:"ray,omitempty"`

// TrustyAI component configuration.
TrustyAI trustyai.TrustyAI `json:"trustyai,omitempty"`
TrustyAI componentsv1.DSCTrustyAI `json:"trustyai,omitempty"`

// ModelRegistry component configuration.
ModelRegistry componentsv1.DSCModelRegistry `json:"modelregistry,omitempty"`
Expand Down
44 changes: 39 additions & 5 deletions bundle/manifests/components.opendatahub.io_trustyais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ spec:
singular: trustyai
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: TrustyAI is the Schema for the trustyais API
Expand All @@ -39,10 +48,32 @@ spec:
spec:
description: TrustyAISpec defines the desired state of TrustyAI
properties:
foo:
description: Foo is an example field of TrustyAI. Edit trustyai_types.go
to remove/update
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
type: object
status:
description: TrustyAIStatus defines the observed state of TrustyAI
Expand Down Expand Up @@ -110,6 +141,9 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: TrustyAI name must be default-trustyai
rule: self.metadata.name == 'default-trustyai'
served: true
storage: true
subresources:
Expand Down
126 changes: 0 additions & 126 deletions components/trustyai/trustyai.go

This file was deleted.

Loading

0 comments on commit 1209501

Please sign in to comment.