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

Add payload processor feature flag #166

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,42 @@ Additionally, in that namespace:
* a `ServiceMonitor` will be created to allow Prometheus to scrape metrics from the service.
* (if on OpenShift) a `Route` will be created to allow external access to the service.

By default, the `TrustyAIService` will only attempt to configure ModelMesh `InferenceServices`.
This can be customized using the optional `payloadProcessor` section of the CR.
For instance,

```yaml
apiVersion: trustyai.opendatahub.io.trusty.opendatahub.io/v1
kind: TrustyAIService
metadata:
name: trustyai-service-example
spec:
storage:
format: "PVC"
folder: "/inputs"
size: "1Gi"
data:
filename: "data.csv"
format: "CSV"
metrics:
schedule: "5s"
batchSize: 5000
payloadProcessor:
modelmesh: "yes"
kserve: "yes"
```

Will enable configuration of KServe inference services too, while

```yaml
# ...
payloadProcessor:
modelmesh: "no"
kserve: "yes"
```

would configure KServe _only_.

### Custom Image Configuration using ConfigMap
You can specify a custom TrustyAI-service image via adding parameters to the TrustyAI-Operator KFDef, for example:

Expand Down
53 changes: 49 additions & 4 deletions api/v1alpha1/trustyaiservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ type MetricsSpec struct {
type TrustyAIServiceSpec struct {
// Number of replicas
// +optional
Replicas *int32 `json:"replicas"`
Storage StorageSpec `json:"storage"`
Data DataSpec `json:"data"`
Metrics MetricsSpec `json:"metrics"`
Replicas *int32 `json:"replicas"`
Storage StorageSpec `json:"storage"`
Data DataSpec `json:"data"`
Metrics MetricsSpec `json:"metrics"`
PayloadProcessor *PayloadProcessorSpec `json:"payloadProcessor,omitempty"`
}

// PayloadProcessorSpec defines whether a specific InferenceService type should be configured to use a payload processor
type PayloadProcessorSpec struct {
ModelMesh string `json:"modelmesh,omitempty"`
KServe string `json:"kserve,omitempty"`
}

// TrustyAIServiceStatus defines the observed state of TrustyAIService
Expand Down Expand Up @@ -90,6 +97,44 @@ func init() {
SchemeBuilder.Register(&TrustyAIService{}, &TrustyAIServiceList{})
}

func (t *TrustyAIService) SetDefaults() {
if t.Spec.PayloadProcessor == nil {
// Set both fields to their defaults if payloadProcessor is entirely missing
t.Spec.PayloadProcessor = &PayloadProcessorSpec{
ModelMesh: "yes", // Default for ModelMesh
KServe: "no", // Default for KServe
}
} else {
// Set individual fields to their defaults if they are not specified
if t.Spec.PayloadProcessor.ModelMesh == "" {
t.Spec.PayloadProcessor.ModelMesh = "yes"
}
if t.Spec.PayloadProcessor.KServe == "" {
t.Spec.PayloadProcessor.KServe = "no"
}
}
}

// IsModelMeshEnabled checks if ModelMesh is enabled in the payloadProcessor settings
// Defaults to true if payloadProcessor is not specified
func (t *TrustyAIService) IsModelMeshEnabled() bool {
// Default to true if payloadProcessor is not specified
if t.Spec.PayloadProcessor == nil {
return true
}
return t.Spec.PayloadProcessor.ModelMesh == "yes"
}

// IsKServeEnabled checks if KServe is enabled in the payloadProcessor settings
// Defaults to false if payloadProcessor is not specified
func (t *TrustyAIService) IsKServeEnabled() bool {
// Default to false if payloadProcessor is not specified
if t.Spec.PayloadProcessor == nil {
return false
}
return t.Spec.PayloadProcessor.KServe == "yes"
}

// SetStatus sets the status of the TrustyAIService
func (t *TrustyAIService) SetStatus(condType, reason, message string, status corev1.ConditionStatus) {
now := metav1.Now()
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -15,108 +15,117 @@ spec:
singular: trustyaiservice
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: TrustyAIService is the Schema for the trustyaiservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
- name: v1alpha1
schema:
openAPIV3Schema:
description: TrustyAIService is the Schema for the trustyaiservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: TrustyAIServiceSpec defines the desired state of TrustyAIService
properties:
data:
type: string
metadata:
type: object
spec:
description: TrustyAIServiceSpec defines the desired state of TrustyAIService
properties:
data:
properties:
filename:
type: string
format:
type: string
required:
- filename
- format
type: object
metrics:
properties:
batchSize:
type: integer
schedule:
type: string
required:
- schedule
type: object
payloadProcessor:
description: PayloadProcessorSpec defines whether a specific InferenceService
type should be configured to use a payload processor
properties:
kserve:
type: string
modelmesh:
type: string
type: object
replicas:
description: Number of replicas
format: int32
type: integer
storage:
properties:
folder:
type: string
format:
type: string
size:
type: string
required:
- folder
- format
- size
type: object
required:
- data
- metrics
- storage
type: object
status:
description: TrustyAIServiceStatus defines the observed state of TrustyAIService
properties:
conditions:
items:
description: Condition represents possible conditions of a TrustyAIServiceStatus
properties:
filename:
lastTransitionTime:
format: date-time
type: string
format:
message:
type: string
required:
- filename
- format
type: object
metrics:
properties:
batchSize:
type: integer
schedule:
type: string
required:
- schedule
type: object
replicas:
description: Number of replicas
format: int32
type: integer
storage:
properties:
folder:
reason:
type: string
format:
status:
type: string
size:
type:
type: string
required:
- folder
- format
- size
- lastTransitionTime
- message
- reason
- status
- type
type: object
required:
- data
- metrics
- storage
type: object
status:
description: TrustyAIServiceStatus defines the observed state of TrustyAIService
properties:
conditions:
items:
description: Condition represents possible conditions of a TrustyAIServiceStatus
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
phase:
description: Define your status fields here
type: string
ready:
type: string
replicas:
format: int32
type: integer
required:
- conditions
- phase
- replicas
type: object
type: object
served: true
storage: true
subresources:
status: {}
type: array
phase:
description: Define your status fields here
type: string
ready:
type: string
replicas:
format: int32
type: integer
required:
- conditions
- phase
- replicas
type: object
type: object
served: true
storage: true
subresources:
status: {}
4 changes: 4 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Append samples you want in your CSV to this file as resources ##
resources:
- trustyai.opendatahub.io_v1alpha1_trustyaiservice.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: trustyai.opendatahub.io.trustyai.opendatahub.io/v1alpha1
kind: TrustyAIService
metadata:
labels:
app.kubernetes.io/name: trustyaiservice
app.kubernetes.io/instance: trustyaiservice-sample
app.kubernetes.io/part-of: trustyai-service-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: trustyai-service-operator
name: trustyaiservice-sample
spec:
# TODO(user): Add fields here
Loading
Loading