Skip to content

Commit

Permalink
add enablement flag for nim (opendatahub-io#1330)
Browse files Browse the repository at this point in the history
(cherry picked from commit b44b0cd)
  • Loading branch information
trujillm authored and zdtsw committed Nov 29, 2024
1 parent 76cae1b commit 6132efb
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 @@ -314,6 +315,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
3 changes: 3 additions & 0 deletions bundle/manifests/rhods-operator.clusterserviceversion.yaml
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
11 changes: 11 additions & 0 deletions 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) OverrideManifests(ctx context.Context, _ cluster.Platform) error {
Expand Down Expand Up @@ -106,6 +108,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 @@ -120,6 +125,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 @@ -11,6 +11,8 @@ import (
"github.com/go-logr/logr"
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"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
Expand Down Expand Up @@ -117,6 +119,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 @@ -169,3 +178,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 6132efb

Please sign in to comment.