Skip to content

implement cluster-local-domain-tls in serving - #14610

Merged
knative-prow[bot] merged 10 commits into
knative:mainfrom
ReToCode:encryption-certmanager-only
Jan 25, 2024
Merged

knative-prow[bot] merged 10 commits into
knative:mainfrom
ReToCode:encryption-certmanager-only

Conversation

@ReToCode

@ReToCode ReToCode commented Nov 10, 2023 •

Copy link
Copy Markdown
Contributor

Context: Serving Encryption (view) and https://github.com/knative/serving/blob/main/docs/encryption/knative-encryption.md

Fixes #14217

Changes

  • Drops the existing self-built reconcilers for certificates
  • Drops the creation of a secret for Queue-Proxy
  • Introduces reconciliation of KnativeCertificates when cluster-local-domain-tls is enabled
  • Creates a KnativeCertificate for Activator and one in each namespace where Queue-Proxy is
  • Adds new certificate type labels to KnativeCertificates
  • Added new tests and e2e tests for the functionality
  • Extracted some testing stuff to make it work on all existing tests as well. Kourier with enabled cluster-local-domain-tls will also run all existing tests with TLS.
  • Cherry-pick [Automated] Update net-istio nightly #14706

Depends on these being merged first:

Release Note

Serving now supports the experimental feature `cluster-local-domain-tls` and creates the necessary `KnativeCertificates`

/hold

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 10, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2023
@knative-prow knative-prow Bot added area/API API objects and controllers size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. area/autoscale area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Nov 10, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from c96a9cb to 68c4e4c Compare November 10, 2023 10:11
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 10, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from d6939f2 to b297bec Compare November 14, 2023 09:14
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 14, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch 3 times, most recently from 0eeae3d to 6198bf3 Compare November 22, 2023 13:43
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from 6198bf3 to a8d4cde Compare November 22, 2023 14:04
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from a8d4cde to 33bc391 Compare November 30, 2023 10:17
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 30, 2023

@ReToCode ReToCode left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added some inline comments to help with reviews.

Comment thread pkg/reconciler/route/domains/domains.go Outdated
}

// GetDomainsForVisibility return all domains for the specified visibility.
func GetDomainsForVisibility(ctx context.Context, targetName string, r *v1.Route, visibility netv1alpha1.IngressVisibility) (sets.String, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is moved and renamed from ingress.go

I also added some tests for this function.

// We use https://golang.org/pkg/hash/adler32/#Checksum to compute the digest which returns a uint32.
// We represent the digest in unsigned integer format with maximum value of 4,294,967,295 which are 10 digits.
// The "-[tag digest]" is computed only if there's a tag
func certNameFromRouteAndTag(route *v1.Route, tag string) string {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

extracted from existing function

}, nil
}

func routeDomain(ctx context.Context, targetName string, r *servingv1.Route, visibility netv1alpha1.IngressVisibility) (sets.String, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to domains.go, see above.

return unusedCerts, nil
}

func (c *Reconciler) deleteOrphanedCerts(ctx context.Context, orphanCerts []*netv1alpha1.Certificate) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

extracted to be reused from both callees.

Comment thread pkg/testing/v1/route.go
// WithRouteConditionsTLSNotEnabledForClusterLocalMessage calls
// MarkTLSNotEnabled with TLSNotEnabledForClusterLocalMessage after initialized
// the Service's conditions.
func WithRouteConditionsTLSNotEnabledForClusterLocalMessage(rt *v1.Route) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we don't longer need this, as we support it now.

v1test "knative.dev/serving/test/v1"
)

const (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to separate file, see above.


// if cluster-local-domain-tls is enabled, this will return the CA used to sign the certificates.
// TestProxyToHelloworld will use this CA to verify the https connection
secret, err := GetCASecret(clients)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All our tests that call cluster-local domains need to trust if we enable TLS, this helper gets the CA secret and the following TestProxyToHelloworld will add this CA to it's trust pool and thus validate the TLS connection.

}
transport.TLSClientConfig = &tls.Config{
RootCAs: rootCAs,
// If SERVER_NAME is not set the empty value will make the

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

httpproxy no longer needs to trust a defined SERVER_NAME. The certificates will be valid for the actual service. Also we get the CA directly in the env variable.

Comment thread third_party/kourier-latest/kourier.yaml Resolved
@ReToCode ReToCode changed the title [TEST-ONLY] testing cluster-local-domain-tls in Serving [WIP] implement cluster-local-domain-tls in serving Nov 30, 2023
@knative-prow knative-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 30, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 30, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from 4be9d8f to 8ad22bc Compare November 30, 2023 12:59
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 30, 2023
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from bf85971 to 67cf527 Compare January 16, 2024 07:01
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2024
Comment thread pkg/reconciler/revision/controller.go Outdated
}
deploymentInformer.Informer().AddEventHandler(handleMatchingControllers)
paInformer.Informer().AddEventHandler(handleMatchingControllers)
certificateInformer.Informer().AddEventHandler(handleMatchingControllers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the namespace is the owner of the certificate - this won't work.

You could re-sync all the revisions when the cert changes by listing and enqueing (then filtering) - or you can use a tracker https://pkg.go.dev/knative.dev/pkg/tracker

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see, makes sense. Updated it to using a tracker, I added it after the initial creation of a Certificate was successful. If that would fail (e.g. on the first Revision), we'd have an error on the Revision reconciliation anyway.

@ReToCode

Copy link
Copy Markdown
Contributor Author

I disabled istio-tls testing - unsure if you want to re-enable it again as part of this PR

Let's keep that as a follow-up thing, as we also have flakiness with ambient that we'd need to look into.

@ReToCode

Copy link
Copy Markdown
Contributor Author

/test unit-tests

Comment thread pkg/reconciler/revision/controller.go Resolved
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from 535f6fa to 8a08a96 Compare January 18, 2024 15:08
Comment thread pkg/reconciler/revision/controller.go Resolved
// Tell our trackers to reconcile when the KnativeCertificate changes
gvk := rev.GetGroupVersionKind()
apiVersion, kind := gvk.ToAPIVersionAndKind()
if err := c.tracker.TrackReference(tracker.Reference{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is backwards

you want to track the cert and reconcile the revision so the invocation is

TrackReference(certificate, rev)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh that API is quite confusing, but it makes sense that it has to be this way. Thanks for explaining and bearing with me on this.

@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from 8a08a96 to fb1065f Compare January 19, 2024 06:27
@ReToCode
ReToCode force-pushed the encryption-certmanager-only branch from fb1065f to e04287b Compare January 19, 2024 06:29
@ReToCode

Copy link
Copy Markdown
Contributor Author

/hold

We'll bring this in after the release cut

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 24, 2024
@ReToCode

Copy link
Copy Markdown
Contributor Author

/unhold

@knative-prow knative-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 24, 2024
@dprotaso

Copy link
Copy Markdown
Member

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 25, 2024
@knative-prow

knative-prow Bot commented Jan 25, 2024

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, ReToCode

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2024
@knative-prow
knative-prow Bot merged commit 0bae8a2 into knative:main Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers area/autoscale area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cluster-local-domain-tls] create KnativeCertificate in Serving when cluster-local encryption is enabled

3 participants