Skip to content

Commit

Permalink
fix: template serving runtime for nim missing gvk and has wrong pull …
Browse files Browse the repository at this point in the history
…secret name (#303)

* fix: nim pull secret name in servingrutime template

Signed-off-by: Tomer Figenblat <[email protected]>

* fix: template object is stripped from gvk

Signed-off-by: Tomer Figenblat <[email protected]>

---------

Signed-off-by: Tomer Figenblat <[email protected]>
  • Loading branch information
TomerFi authored Nov 15, 2024
1 parent 657a4bb commit f52fab2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/nim_account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (r *NimAccountReconciler) reconcileRuntimeTemplate(ctx context.Context, acc
template.Labels = labels

template.Objects = []runtime.RawExtension{
{Object: utils.GetNimServingRuntimeTemplate()},
{Object: utils.GetNimServingRuntimeTemplate(r.Scheme())},
}
return nil
}); err != nil {
Expand Down
14 changes: 10 additions & 4 deletions controllers/utils/nim.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"fmt"
"github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
kserveconstants "github.com/kserve/kserve/pkg/constants"
"github.com/opendatahub-io/odh-model-controller/controllers/constants"
"io"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"net/http"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"strings"
"time"
)
Expand Down Expand Up @@ -288,9 +289,9 @@ func getModelData(runtime NimRuntime, tokenResp *NimTokenResponse) (*NimModel, s
}

// GetNimServingRuntimeTemplate returns the Template used by ODH for creating serving runtimes
func GetNimServingRuntimeTemplate() *v1alpha1.ServingRuntime {
func GetNimServingRuntimeTemplate(scheme *runtime.Scheme) *v1alpha1.ServingRuntime {
multiModel := false
return &v1alpha1.ServingRuntime{
sr := &v1alpha1.ServingRuntime{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"opendatahub.io/recommended-accelerators": "[\"nvidia.com/gpu\"]",
Expand Down Expand Up @@ -355,7 +356,7 @@ func GetNimServingRuntimeTemplate() *v1alpha1.ServingRuntime {
},
ImagePullSecrets: []corev1.LocalObjectReference{
{
Name: constants.NimPullSecretName,
Name: "ngc-secret",
},
},
Volumes: []corev1.Volume{
Expand All @@ -376,4 +377,9 @@ func GetNimServingRuntimeTemplate() *v1alpha1.ServingRuntime {
},
},
}

gvk, _ := apiutil.GVKForObject(sr, scheme)
sr.SetGroupVersionKind(gvk)

return sr
}

0 comments on commit f52fab2

Please sign in to comment.