Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(serverless): Patch to enable Secret filtering in KNative Serving #814

Merged
merged 1 commit into from
Jan 29, 2024
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
28 changes: 19 additions & 9 deletions components/kserve/serverless_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature/serverless"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature/servicemesh"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/gvr"
)

const (
knativeServingNamespace = "knative-serving"
templatesDir = "templates/serverless"
templatesDir = "templates/serverless"
)

func (k *Kserve) configureServerlessFeatures() feature.DefinedFeatures {
Expand All @@ -27,23 +25,35 @@ func (k *Kserve) configureServerlessFeatures() feature.DefinedFeatures {
serverless.EnsureServerlessOperatorInstalled,
serverless.EnsureServerlessAbsent,
servicemesh.EnsureServiceMeshInstalled,
feature.CreateNamespaceIfNotExists(knativeServingNamespace),
feature.CreateNamespaceIfNotExists(serverless.KnativeServingNamespace),
).
Load()
if err != nil {
return err
}
initializer.Features = append(initializer.Features, servingDeployment)

servingNetIstioSecretFiltering, err := feature.CreateFeature("serverless-net-istio-secret-filtering").
With(initializer.DSCInitializationSpec).
From(initializer.Source).
Manifests(
path.Join(templatesDir, "serving-net-istio-secret-filtering.patch.tmpl"),
).
WithData(PopulateComponentSettings(k)).
PreConditions(serverless.EnsureServerlessServingDeployed).
PostConditions(
feature.WaitForPodsToBeReady(knativeServingNamespace),
feature.WaitForPodsToBeReady(serverless.KnativeServingNamespace),
).
Load()
if err != nil {
return err
}
initializer.Features = append(initializer.Features, servingDeployment)
initializer.Features = append(initializer.Features, servingNetIstioSecretFiltering)

servingIstioGateways, err := feature.CreateFeature("serverless-serving-gateways").
With(initializer.DSCInitializationSpec).
From(initializer.Source).
PreConditions(
// Check serverless is installed
feature.WaitForResourceToBeCreated(knativeServingNamespace, gvr.KnativeServing)).
PreConditions(serverless.EnsureServerlessServingDeployed).
WithData(
serverless.ServingDefaultValues,
serverless.ServingIngressDomain,
Expand Down
6 changes: 6 additions & 0 deletions pkg/feature/serverless/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/gvr"
)

const (
KnativeServingNamespace = "knative-serving"
)

var log = ctrlLog.Log.WithName("features")

func EnsureServerlessAbsent(f *feature.Feature) error {
Expand Down Expand Up @@ -50,3 +54,5 @@ func EnsureServerlessOperatorInstalled(f *feature.Feature) error {

return nil
}

var EnsureServerlessServingDeployed = feature.WaitForResourceToBeCreated(KnativeServingNamespace, gvr.KnativeServing)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
serverless.openshift.io/default-enable-http2: "true"
spec:
deployments:
workloads:
- annotations:
sidecar.istio.io/inject: "true"
sidecar.istio.io/rewriteAppHTTPProbers: "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
name: {{ .Serving.Name }}
namespace: knative-serving
spec:
workloads:
- name: activator
annotations:
sidecar.istio.io/inject: "true"
sidecar.istio.io/rewriteAppHTTPProbers: "true"
- name: autoscaler
annotations:
sidecar.istio.io/inject: "true"
sidecar.istio.io/rewriteAppHTTPProbers: "true"
- name: net-istio-controller
env:
- container: controller
envVars:
- name: ENABLE_SECRET_INFORMER_FILTERING_BY_CERT_UID
value: 'true'
Comment on lines +16 to +21
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ReToCode @skonto Tagging you to confirm that this is what makes sense for the long-term.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it makes sense. We are working on making this the default anyway. Downstream it will be the default in the next release (1.32).

Please use workloads instead of deployments. deployments is deprecated and replaced with workloads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I changed, but there is a catch:

Being this a patch, I wonder what would happen for existing installs that need to be upgraded?
My guess is that since this is a patch, we would end up with a resource that would contain both deployments and workloads (assuming it would be accepted). So, not sure if it would be a good state....

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have that problem either way until we finally drop deployments. But workloads is applied later than deployments, so if we have conflicting values the workloads wins.

Anything I forgot @skonto?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployments first and then workloads are merged in a slice and then they are applied in that order.

Loading