Skip to content
Merged
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
9 changes: 9 additions & 0 deletions charts/kserve-resources/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- operator.knative.dev
resources:
- knativeservings
verbs:
- get
- list
- watch
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
Expand All @@ -161,6 +169,7 @@ rules:
- routes
verbs:
- create
- delete
- get
- list
- patch
Expand Down
15 changes: 15 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/tools/record"
operatorv1beta1 "knative.dev/operator/pkg/apis/operator/v1beta1"
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/config"
Expand Down Expand Up @@ -176,6 +177,20 @@ func main() {
os.Exit(1)
}
}

knServingFound, knServingCheckErr := utils.IsCrdAvailable(cfg, operatorv1beta1.SchemeGroupVersion.String(), constants.KnativeServingKind)
if knServingCheckErr != nil {
setupLog.Error(knServingCheckErr, "error when checking if Knative KnativeServing kind is available")
os.Exit(1)
}
if knServingFound {
setupLog.Info("Setting up Knative Operator scheme")
if err := operatorv1beta1.AddToScheme(mgr.GetScheme()); err != nil {
setupLog.Error(err, "unable to add Knative Operator APIs to scheme")
os.Exit(1)
}
}

if !ingressConfig.DisableIstioVirtualHost {
vsFound, vsCheckErr := utils.IsCrdAvailable(cfg, istioclientv1beta1.SchemeGroupVersion.String(), constants.IstioVirtualServiceKind)
if vsCheckErr != nil {
Expand Down
1 change: 1 addition & 0 deletions config/configmap/inferenceservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ data:
# revisions, which prevents the reconciliation loop to be triggered if the annotations is
# configured here are used.
# Default values are:
# "autoscaling.knative.dev/initial-scale",
# "autoscaling.knative.dev/min-scale",
# "autoscaling.knative.dev/max-scale",
# "internal.serving.kserve.io/storage-initializer-sourceuri",
Expand Down
1 change: 1 addition & 0 deletions config/overlays/odh/inferenceservice-config-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ data:
inferenceService: |-
{
"serviceAnnotationDisallowedList": [
"autoscaling.knative.dev/initial-scale",
"autoscaling.knative.dev/min-scale",
"autoscaling.knative.dev/max-scale",
"internal.serving.kserve.io/storage-initializer-sourceuri",
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- operator.knative.dev
resources:
- knativeservings
verbs:
- get
- list
- watch
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2
k8s.io/utils v0.0.0-20240821151609-f90d01438635
knative.dev/networking v0.0.0-20240815142417-37fdbdd0854b
knative.dev/operator v0.42.2
knative.dev/pkg v0.0.0-20240815051656-89743d9bbf7c
knative.dev/serving v0.42.2
sigs.k8s.io/controller-runtime v0.19.2
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/manifestival/manifestival v0.7.2 h1:l4uFdWX/xQK4QcRfqGoMtBvaZeWPEuwD6hVsCwUqZY4=
github.com/manifestival/manifestival v0.7.2/go.mod h1:nl3T6HlfHCeidooWVTMI9vYNTBkQ1GdhLNb+smozbdk=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
Expand Down Expand Up @@ -764,8 +766,12 @@ k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 h1:GKE9U8BH16uynoxQii0auT
k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2/go.mod h1:coRQXBK9NxO98XUv3ZD6AK3xzHCxV6+b7lrquKwaKzA=
k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2duqHWf5OX9S3zjI=
k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/caching v0.0.0-20240716132144-989f54c83776 h1:2nINnWuXtb9e2nG/EJxSCeghcmu6qmvmomJ7woiP5Is=
knative.dev/caching v0.0.0-20240716132144-989f54c83776/go.mod h1:Uj74eO9rLiK1eb8wmDBED1hJBZQ7MJ9cvq/d8Ktsm3c=
knative.dev/networking v0.0.0-20240815142417-37fdbdd0854b h1:ws/Jeho6on84+5tfNKLAKriVVGIwivHbgPEtZjBfcs0=
knative.dev/networking v0.0.0-20240815142417-37fdbdd0854b/go.mod h1:2eMQVGLBZ5Kj1C4kKPuPhO7BsUeF6fkmhZFDQPIP+88=
knative.dev/operator v0.42.2 h1:wgAWYHwoSFmV+wPHCt5dZahHTHLy2VCM4G82PEo9iSc=
knative.dev/operator v0.42.2/go.mod h1:cfSpJMgvwmuZ7USaxC+zgEuizMFc/xweREW5DG6J1DA=
knative.dev/pkg v0.0.0-20240815051656-89743d9bbf7c h1:2crXVk4FG0dSG6WHaIT+WKbUzn7qG2wn0AfYmvA22zs=
knative.dev/pkg v0.0.0-20240815051656-89743d9bbf7c/go.mod h1:cI2RPEEHZk+/dBpfHobs0aBdPA1mMZVUVWnGAc8NSzM=
knative.dev/serving v0.42.2 h1:yKieg3MeNvpVz+4JJPbvmpee3v3LK3zO5h5HJBtzaNk=
Expand Down
14 changes: 11 additions & 3 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var (
AutoscalerClass = KServeAPIGroupName + "/autoscalerClass"
AutoscalerMetrics = KServeAPIGroupName + "/metrics"
TargetUtilizationPercentage = KServeAPIGroupName + "/targetUtilizationPercentage"
InitialScaleAnnotationKey = KnativeAutoscalingAPIGroupName + "/initial-scale"
MinScaleAnnotationKey = KnativeAutoscalingAPIGroupName + "/min-scale"
MaxScaleAnnotationKey = KnativeAutoscalingAPIGroupName + "/max-scale"
RollOutDurationAnnotationKey = KnativeServingAPIGroupName + "/rollout-duration"
Expand Down Expand Up @@ -263,9 +264,14 @@ type InferenceServiceProtocol string

// Knative constants
const (
KnativeLocalGateway = "knative-serving/knative-local-gateway"
KnativeIngressGateway = "knative-serving/knative-ingress-gateway"
VisibilityLabel = "networking.knative.dev/visibility"
AutoscalerKey = "autoscaler"
AutoscalerInitialScaleKey = "initial-scale"
AutoscalerAllowZeroScaleKey = "allow-zero-initial-scale"
DefaultKnServingName = "knative-serving"
DefaultKnServingNamespace = "knative-serving"
KnativeLocalGateway = "knative-serving/knative-local-gateway"
KnativeIngressGateway = "knative-serving/knative-ingress-gateway"
VisibilityLabel = "networking.knative.dev/visibility"
)

var (
Expand Down Expand Up @@ -379,6 +385,7 @@ var (
// revisions, which prevents the reconciliation loop to be triggered if the annotations is
// configured here are used.
ServiceAnnotationDisallowedList = []string{
autoscaling.InitialScaleAnnotationKey,
autoscaling.MinScaleAnnotationKey,
autoscaling.MaxScaleAnnotationKey,
StorageInitializerSourceUriInternalAnnotationKey,
Expand Down Expand Up @@ -504,6 +511,7 @@ const (
const (
IstioVirtualServiceKind = "VirtualService"
KnativeServiceKind = "Service"
KnativeServingKind = "KnativeServing"
HTTPRouteKind = "HTTPRoute"
GatewayKind = "Gateway"
ServiceKind = "Service"
Expand Down
22 changes: 20 additions & 2 deletions pkg/controller/v1alpha1/inferencegraph/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
// +kubebuilder:rbac:groups=serving.knative.dev,resources=services/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=create;get;update;patch;watch;delete
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes/status,verbs=get
// +kubebuilder:rbac:groups=operator.knative.dev,resources=knativeservings,verbs=get;list;watch
package inferencegraph

import (
Expand All @@ -45,6 +46,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
operatorv1beta1 "knative.dev/operator/pkg/apis/operator/v1beta1"
"knative.dev/pkg/apis"
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -266,10 +268,26 @@ func (r *InferenceGraphReconciler) Reconcile(ctx context.Context, req ctrl.Reque
if !ksvcAvailable {
r.Recorder.Event(graph, v1.EventTypeWarning, "ServerlessModeRejected",
"It is not possible to use Serverless deployment mode when Knative Services are not available")
return reconcile.Result{Requeue: false}, reconcile.TerminalError(fmt.Errorf("the resolved deployment mode of InferenceGraph '%s' is Serverless, but Knative Serving is not available", graph.Name))
return reconcile.Result{Requeue: false}, reconcile.TerminalError(fmt.Errorf("the resolved deployment mode of InferenceGraph '%s' is Serverless, but Knative Services are not available", graph.Name))
}

// Abort if Knative KnativeServings are not available
knServingFound, knServingCheckErr := utils.IsCrdAvailable(r.ClientConfig, operatorv1beta1.SchemeGroupVersion.String(), constants.KnativeServingKind)
if knServingCheckErr != nil {
return reconcile.Result{}, knServingCheckErr
}

if !knServingFound {
r.Recorder.Event(graph, v1.EventTypeWarning, "ServerlessModeRejected",
"It is not possible to use Serverless deployment mode when Knative KnativeServings are not available")
return reconcile.Result{Requeue: false}, reconcile.TerminalError(fmt.Errorf("the resolved deployment mode of InferenceGraph '%s' is Serverless, but Knative KnativeServings are not available", graph.Name))
}

desired, err := createKnativeService(r.Client, graph.ObjectMeta, graph, routerConfig)
if err != nil {
return ctrl.Result{}, errors.Wrapf(err, "fails to create new knative service")
}

desired := createKnativeService(graph.ObjectMeta, graph, routerConfig)
err = controllerutil.SetControllerReference(graph, desired, r.Scheme)
if err != nil {
return reconcile.Result{}, err
Expand Down
Loading
Loading