-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically inject expected ODH annotations to InferenceGraph and I…
…nferenceServices (#339) * Implementation of ODH defaulters for InferenceGraph and InferenceService On creation of InferenceGraph or InferenceService resources, the following default annotations will be added: * `serving.knative.openshift.io/enablePassthrough: true` * `sidecar.istio.io/inject: true` * `sidecar.istio.io/rewriteAppHTTPProbers: true` The annotations are added only for Serverless mode, and only if they are missing. Signed-off-by: Edgar Hernández <[email protected]> * Feedback: Filippe Extract "ENABLE_WEBHOOKS" string to constant Signed-off-by: Edgar Hernández <[email protected]> --------- Signed-off-by: Edgar Hernández <[email protected]>
- Loading branch information
1 parent
cfe7f97
commit 2a69143
Showing
18 changed files
with
650 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Containerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package serving | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/go-logr/logr" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/opendatahub-io/odh-model-controller/internal/controller/constants" | ||
"github.com/opendatahub-io/odh-model-controller/internal/controller/utils" | ||
) | ||
|
||
func ApplyDefaultServerlessAnnotations(ctx context.Context, client client.Client, resourceName string, resourceMetadata *v1.ObjectMeta, logger logr.Logger) error { | ||
deploymentMode, err := utils.GetDeploymentModeForKServeResource(ctx, client, resourceMetadata.GetAnnotations()) | ||
if err != nil { | ||
return fmt.Errorf("error resolving deployment mode for resource %s: %w", resourceName, err) | ||
} | ||
|
||
if deploymentMode == constants.Serverless { | ||
logAnnotationsAdded := make([]string, 0, 3) | ||
resourceAnnotations := resourceMetadata.GetAnnotations() | ||
if resourceAnnotations == nil { | ||
resourceAnnotations = make(map[string]string) | ||
} | ||
|
||
if _, exists := resourceAnnotations["serving.knative.openshift.io/enablePassthrough"]; !exists { | ||
resourceAnnotations["serving.knative.openshift.io/enablePassthrough"] = "true" | ||
logAnnotationsAdded = append(logAnnotationsAdded, "serving.knative.openshift.io/enablePassthrough") | ||
} | ||
|
||
if _, exists := resourceAnnotations["sidecar.istio.io/inject"]; !exists { | ||
resourceAnnotations["sidecar.istio.io/inject"] = "true" | ||
logAnnotationsAdded = append(logAnnotationsAdded, "sidecar.istio.io/inject") | ||
} | ||
|
||
if _, exists := resourceAnnotations["sidecar.istio.io/rewriteAppHTTPProbers"]; !exists { | ||
resourceAnnotations["sidecar.istio.io/rewriteAppHTTPProbers"] = "true" | ||
logAnnotationsAdded = append(logAnnotationsAdded, "sidecar.istio.io/rewriteAppHTTPProbers") | ||
} | ||
|
||
if len(logAnnotationsAdded) > 0 { | ||
logger.V(1).Info("Annotations added", "annotations", strings.Join(logAnnotationsAdded, ",")) | ||
} | ||
|
||
resourceMetadata.SetAnnotations(resourceAnnotations) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.