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

Loosening TLS validation to enable indirect TLS config #2721

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

robscott
Copy link
Member

What type of PR is this?
/kind documentation
/kind feature

What this PR does / why we need it:
This loosens TLS validation as requested by #2668 and #2713 and adds documentation for the self-service approaches and overall indirect TLS config this enables. This also adds a new InvalidTLSConfig reason for the Programmed condition on Gateways.

Which issue(s) this PR fixes:
Fixes #763
Fixes #2668
Fixes #2713

Does this PR introduce a user-facing change?:

TLS Configuration is no longer required on Gateway Listeners to enable more flexible TLS configuration.

This is a big PR, going to leave it on hold for a bit while we wait for consensus.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 18, 2024
@robscott
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 18, 2024
@robscott
Copy link
Member Author

@k8s-ci-robot
Copy link
Contributor

@robscott: GitHub didn't allow me to request PR reviews from the following users: EItanya.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @youngnick @candita @arkodg @sunjayBhatia @EItanya

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@robscott robscott added this to the v1.1 milestone Jan 18, 2024
Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

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

Looks great overall, I'm not super familiar with CEL so I'll just comment on the new intended behavior WRT documentation

apis/v1/gateway_types.go Outdated Show resolved Hide resolved
site-src/guides/implementers.md Outdated Show resolved Hide resolved
Comment on lines +240 to +243
hostnames. This would also likely benefit from a Listener or Gateway-level
opt-in for the behavior.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would an option be a bad example of a way to offer opt-in behavior here? It would definitely be a bit of an abuse of the map[string]string structure, but would have the benefit of not requiring API changes.

For example:

example.com/tls-allowed-namespace-selector: foo=bar

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm generally against any form of structured content within these kind of annotation-like fields since it's so easy to mess up. Maybe I should add some guidelines for what doesn't belong here? Was that what you were suggesting here?

Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

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

worth updating this page with some content as well? https://gateway-api.sigs.k8s.io/guides/tls

at least alluding to the fact that some implementations may decide to implement downstream TLS, specifying certs, other options, etc. in different ways

it strikes me that making the tls section no longer required for some protocols, it could make the table here confusing: https://gateway-api.sigs.k8s.io/guides/tls/#clientserver-and-tls

@robscott
Copy link
Member Author

worth updating this page with some content as well? https://gateway-api.sigs.k8s.io/guides/tls

at least alluding to the fact that some implementations may decide to implement downstream TLS, specifying certs, other options, etc. in different ways

Good point, added a note to start that page off.

Comment on lines 378 to 379
//
// +kubebuilder:validation:XValidation:message="certificateRefs must be specified when TLSModeType is Terminate",rule="self.mode == 'Terminate' ? size(self.certificateRefs) > 0 : true"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is entirely removing this validation necessary? Maybe, instead of removing, it could be changed to at least one of either certificateRefs or options must be specified when mode is Terminate?

Copy link
Contributor

Choose a reason for hiding this comment

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

@robscott note that the comment on line 385 (below) also needs to be updated

Copy link
Member Author

Choose a reason for hiding this comment

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

@robscott note that the comment on line 385 (below) also needs to be updated\

Thanks @frankbu! I updated the relevant comments in that area.

Is entirely removing this validation necessary? Maybe, instead of removing, it could be changed to at least one of either certificateRefs or options must be specified when mode is Terminate?

Unfortunately I don't think that would work for one of the initial user stories that led to this - specifically a user wanting certs to be added automatically after they created a Gateway (#763 (comment)). I think the most likely way that would work would involve some kind of controller that automatically generates and populates certificates for Gateways in a given set of namespaces or maybe with a predefined label or annotation. I'm assuming that in most cases, this kind of config would apply to an entire Gateway, not just a listener, so TLS options wouldn't really fit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking that case could be handled by not having any user GatewayTLSConfig setting at all. In that case, the validation only applies when the user is explicitly setting the mode to Terminate using either certificateRefs or some other impl-specific option.

My concern is that if we remove all validation now, we won't be able to add it later. Alternatively, we can always take away more validation in the future without breaking anybody.

Copy link
Member Author

Choose a reason for hiding this comment

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

Chatted on Slack about this and although there are some use cases that could benefit from setting mode and nothing else, they're not sufficient to justify dropping this validation altogether at this point. If we need to, we can revisit this in the future, but we can never retroactively tighten validation. Have updated this to require "options" or "certificateRefs" when mode is "Terminate" as @frankbu suggested.

Copy link
Contributor

@frankbu frankbu left a comment

Choose a reason for hiding this comment

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

Thanks @robscott! LGTM

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: frankbu, robscott, shaneutt

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

The pull request process is described here

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

@robscott
Copy link
Member Author

robscott commented Mar 1, 2024

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2024
@k8s-ci-robot k8s-ci-robot merged commit f610278 into kubernetes-sigs:main Mar 1, 2024
8 checks passed
@aojea aojea mentioned this pull request Apr 24, 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
7 participants