Skip to content

Commit

Permalink
add enablement flag for nim (#1330)
Browse files Browse the repository at this point in the history
* add enablement flag for nim

* add generated files

* add api generated file

* revert image for csv

* update NIM with its own spec

* create nim struct remove from serverless

* updated generated files

* update nim to default removed

* update image to correct var

* update to managed as default

* add nim-state to params.env

* fix NVIDIA typo

* resolve conflict

* add NIM flag check to model mesh

* fix condtional for standard practice nim flag

* fix to conditional for standards

* update typo for error output nim flag kserve

* Fix deploy to dependent path

* update doc/manifests references for nim flag

* fix image typo csv

* update if on nim-state
  • Loading branch information
trujillm authored Nov 27, 2024
1 parent 7296988 commit b44b0cd
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and configure these applications.
- [Deployment](#deployment)
- [Test with customized manifests](#test-with-customized-manifests)
- [Update API docs](#update-api-docs)
- [Enabled logging](#enabled-logging)
- [Example DSCInitialization](#example-dscinitialization)
- [Example DataScienceCluster](#example-datasciencecluster)
- [Run functional Tests](#run-functional-tests)
Expand Down Expand Up @@ -304,6 +305,8 @@ spec:
managementState: Managed
kserve:
managementState: Managed
nim:
managementState: Managed
serving:
ingressGateway:
certificate:
Expand Down
12 changes: 12 additions & 0 deletions apis/infrastructure/v1/nim_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1

import (
operatorv1 "github.com/openshift/api/operator/v1"
)

// nimSpec enables NVIDIA NIM integration
type NimSpec struct {
// +kubebuilder:validation:Enum=Managed;Removed
// +kubebuilder:default=Managed
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
}
15 changes: 15 additions & 0 deletions apis/infrastructure/v1/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 @@ -245,6 +245,17 @@ spec:
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ metadata:
},
"kserve": {
"managementState": "Managed",
"nim": {
"managementState": "Managed"
},
"serving": {
"ingressGateway": {
"certificate": {
Expand Down Expand Up @@ -103,7 +106,7 @@ metadata:
categories: AI/Machine Learning, Big Data
certified: "False"
containerImage: quay.io/opendatahub/opendatahub-operator:v2.21.0
createdAt: "2024-11-18T18:28:55Z"
createdAt: "2024-11-22T19:16:14Z"
olm.skipRange: '>=1.0.0 <2.21.0'
operators.operatorframework.io/builder: operator-sdk-v1.31.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
12 changes: 11 additions & 1 deletion components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Kserve struct {
// 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"`
// Configures and enables NVIDIA NIM integration
NIM infrav1.NimSpec `json:"nim,omitempty"`
}

func (k *Kserve) Init(ctx context.Context, _ cluster.Platform) error {
Expand All @@ -63,7 +65,6 @@ func (k *Kserve) Init(ctx context.Context, _ cluster.Platform) error {
var dependentParamMap = map[string]string{
"odh-model-controller": "RELATED_IMAGE_ODH_MODEL_CONTROLLER_IMAGE",
}

// Update image parameters for odh-model-controller
if err := deploy.ApplyParams(DependentPath, dependentParamMap); err != nil {
log.Error(err, "failed to update image", "path", DependentPath)
Expand Down Expand Up @@ -117,6 +118,9 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

if !enabled {
if err := deploy.ApplyParams(DependentPath, nil, map[string]string{"nim-state": "removed"}); err != nil {
return fmt.Errorf("failed to update NIM flag to removed : %w", err)
}
if err := k.removeServerlessFeatures(ctx, cli, owner, dscispec); err != nil {
return err
}
Expand All @@ -131,6 +135,12 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
return err
}
}
extraParamsMap := map[string]string{
"nim-state": string(k.NIM.ManagementState),
}
if err := deploy.ApplyParams(DependentPath, nil, extraParamsMap); err != nil {
return fmt.Errorf("failed to update NIM flag from %s : %w", Path, err)
}
}

if err := k.configureServiceMesh(ctx, cli, owner, dscispec); err != nil {
Expand Down
1 change: 1 addition & 0 deletions components/kserve/zz_generated.deepcopy.go

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

25 changes: 25 additions & 0 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

Expand Down Expand Up @@ -126,6 +128,13 @@ func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,
}
}

extraParamsMap := map[string]string{
"nim-state": getNimManagementFlag(owner),
}
if err := deploy.ApplyParams(DependentPath, nil, extraParamsMap); err != nil {
return fmt.Errorf("failed to update image from %s : %w", Path, err)
}

if err := deploy.DeployManifestsFromPath(ctx, cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
return fmt.Errorf("failed to apply manifests from %s : %w", Path, err)
}
Expand Down Expand Up @@ -173,3 +182,19 @@ func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,

return nil
}

func getNimManagementFlag(obj metav1.Object) string {
removed := string(operatorv1.Removed)
un, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
if err != nil {
return removed
}
kserve, foundKserve, _ := unstructured.NestedString(un, "spec", "components", "kserve", "managementState")
if foundKserve && kserve != removed {
nim, foundNim, _ := unstructured.NestedString(un, "spec", "components", "kserve", "nim", "managementState")
if foundNim {
return nim
}
}
return removed
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ spec:
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
3 changes: 3 additions & 0 deletions config/samples/datasciencecluster_v1_datasciencecluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
managementState: "Managed"
kserve: {
managementState: "Managed",
nim: {
managementState: "Managed"
},
serving: {
ingressGateway: {
certificate: {
Expand Down
17 changes: 17 additions & 0 deletions docs/api-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ _Appears in:_
| `Component` _[Component](#component)_ | | | |
| `serving` _[ServingSpec](#servingspec)_ | Serving configures the KNative-Serving stack used for model serving. A Service<br />Mesh (Istio) is prerequisite, since it is used as networking layer. | | |
| `defaultDeploymentMode` _[DefaultDeploymentMode](#defaultdeploymentmode)_ | Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.<br />The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.<br />This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode. | | Enum: [Serverless RawDeployment] <br />Pattern: `^(Serverless\|RawDeployment)$` <br /> |
| `nim` _[NimSpec](#nimspec)_ | Configures and enables NVIDIA NIM integration | | |



Expand Down Expand Up @@ -523,6 +524,22 @@ _Appears in:_
| `certificate` _[CertificateSpec](#certificatespec)_ | Certificate specifies configuration of the TLS certificate securing communication<br />for the gateway. | | |


#### NimSpec



nimSpec enables NVIDIA NIM integration



_Appears in:_
- [Kserve](#kserve)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `managementState` _[ManagementState](#managementstate)_ | | Managed | Enum: [Managed Removed] <br /> |


#### ServiceMeshSpec


Expand Down

0 comments on commit b44b0cd

Please sign in to comment.