Skip to content

Commit e2c9247

Browse files
authored
Add well-known label to InferenceGraphs (#463)
Implementation of authentication for InferenceGraphs using Serverless mode will use ServiceMesh with Authorino (like InferenceServices case). For this, an Istio AuthorizationPolicy is applied mesh-wide. The AuthorizationPolicy uses a static label selector that is expected to be present on all Pods that require to be protected. Currently, the InferenceGraph does not have a static label that can be used. This PR is adding the `serving.kserve.io/kind: InferenceGraph` to pods that belong to InferenceGraph to properly protect them per user request. Signed-off-by: Edgar Hernández <[email protected]>
1 parent 7010e26 commit e2c9247

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

pkg/constants/constants.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ import (
3030
)
3131

3232
// KServe Constants
33-
var (
33+
const (
3434
KServeName = "kserve"
3535
KServeAPIGroupName = "serving.kserve.io"
3636
KnativeAutoscalingAPIGroupName = "autoscaling.knative.dev"
3737
KnativeServingAPIGroupNamePrefix = "serving.knative"
3838
KnativeServingAPIGroupName = KnativeServingAPIGroupNamePrefix + ".dev"
39-
KServeNamespace = getEnvOrDefault("POD_NAMESPACE", "kserve")
40-
KServeDefaultVersion = "v0.5.0"
4139
)
4240

41+
var KServeNamespace = getEnvOrDefault("POD_NAMESPACE", "kserve")
42+
4343
// InferenceService Constants
4444
var (
4545
InferenceServiceName = "inferenceservice"
@@ -300,6 +300,7 @@ const (
300300
KServiceComponentLabel = "component"
301301
KServiceModelLabel = "model"
302302
KServiceEndpointLabel = "endpoint"
303+
KServeWorkloadKind = KServeAPIGroupName + "/kind"
303304
)
304305

305306
// Labels for TrainedModel

pkg/controller/v1alpha1/inferencegraph/controller_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ import (
2121
"fmt"
2222
"time"
2323

24-
"github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
25-
"github.com/kserve/kserve/pkg/constants"
26-
"github.com/kserve/kserve/pkg/utils"
2724
. "github.com/onsi/ginkgo/v2"
2825
. "github.com/onsi/gomega"
2926
"google.golang.org/protobuf/proto"
@@ -36,6 +33,10 @@ import (
3633
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
3734
"sigs.k8s.io/controller-runtime/pkg/client"
3835
"sigs.k8s.io/controller-runtime/pkg/reconcile"
36+
37+
"github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
38+
"github.com/kserve/kserve/pkg/constants"
39+
"github.com/kserve/kserve/pkg/utils"
3940
)
4041

4142
var _ = Describe("Inference Graph controller test", func() {
@@ -132,6 +133,7 @@ var _ = Describe("Inference Graph controller test", func() {
132133
ObjectMeta: metav1.ObjectMeta{
133134
Labels: map[string]string{
134135
"serving.kserve.io/inferencegraph": graphName,
136+
constants.KServeWorkloadKind: "InferenceGraph",
135137
},
136138
Annotations: map[string]string{
137139
"autoscaling.knative.dev/min-scale": "1",
@@ -290,6 +292,7 @@ var _ = Describe("Inference Graph controller test", func() {
290292
ObjectMeta: metav1.ObjectMeta{
291293
Labels: map[string]string{
292294
"serving.kserve.io/inferencegraph": graphName,
295+
constants.KServeWorkloadKind: "InferenceGraph",
293296
},
294297
Annotations: map[string]string{
295298
"autoscaling.knative.dev/min-scale": "1",
@@ -462,6 +465,7 @@ var _ = Describe("Inference Graph controller test", func() {
462465
ObjectMeta: metav1.ObjectMeta{
463466
Labels: map[string]string{
464467
"serving.kserve.io/inferencegraph": graphName,
468+
constants.KServeWorkloadKind: "InferenceGraph",
465469
},
466470
Annotations: map[string]string{
467471
"autoscaling.knative.dev/min-scale": "1",

pkg/controller/v1alpha1/inferencegraph/knative_reconciler.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import (
2323
"reflect"
2424
"strings"
2525

26-
v1alpha1api "github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
27-
"github.com/kserve/kserve/pkg/constants"
28-
"github.com/kserve/kserve/pkg/utils"
2926
"github.com/pkg/errors"
3027
"google.golang.org/protobuf/proto"
3128
v1 "k8s.io/api/core/v1"
@@ -42,6 +39,10 @@ import (
4239
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
4340
"sigs.k8s.io/controller-runtime/pkg/client"
4441
logf "sigs.k8s.io/controller-runtime/pkg/log"
42+
43+
v1alpha1api "github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
44+
"github.com/kserve/kserve/pkg/constants"
45+
"github.com/kserve/kserve/pkg/utils"
4546
)
4647

4748
var log = logf.Log.WithName("GraphKsvcReconciler")
@@ -169,6 +170,7 @@ func createKnativeService(componentMeta metav1.ObjectMeta, graph *v1alpha1api.In
169170
return !utils.Includes(constants.RevisionTemplateLabelDisallowedList, key)
170171
})
171172
labels[constants.InferenceGraphLabel] = componentMeta.Name
173+
labels[constants.KServeWorkloadKind] = "InferenceGraph"
172174
service := &knservingv1.Service{
173175
ObjectMeta: metav1.ObjectMeta{
174176
Name: componentMeta.Name,

0 commit comments

Comments
 (0)