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

feat: TLS listeners supported #112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mlavacca
Copy link
Member

What this PR does / why we need it:

Support for TLS Listeners and TLSRoutes.

Which issue this PR fixes

Fixes #64

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Comment on lines +36 to +40
// ListenereReasonInvalidTLSMode must be used with the Accepted condition
// to express that the listener has an invalid TLS mode.
// HTTPS can only be configured with mode Terminate, while TLS can only be
// be configured with mode Passthrough.
ListenereReasonInvalidTLSMode k8sutils.ConditionReason = "InvalidTLSMode"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// ListenereReasonInvalidTLSMode must be used with the Accepted condition
// to express that the listener has an invalid TLS mode.
// HTTPS can only be configured with mode Terminate, while TLS can only be
// be configured with mode Passthrough.
ListenereReasonInvalidTLSMode k8sutils.ConditionReason = "InvalidTLSMode"
// ListenerReasonInvalidTLSMode must be used with the Accepted condition
// to express that the listener has an invalid TLS mode.
// HTTPS can only be configured with mode Terminate, while TLS can only be
// be configured with mode Passthrough.
ListenerReasonInvalidTLSMode k8sutils.ConditionReason = "InvalidTLSMode"

We might add a reference link to https://gateway-api.sigs.k8s.io/guides/tls/#clientserver-and-tls which contains the table with allowed modes for particular route types.

Comment on lines +437 to +440
{
Name: "",
Value: consts.ControlPlaneAdmissionWebhookEnvVarValue,
},
Copy link
Member

Choose a reason for hiding this comment

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

I believe we don't need this right?

Comment on lines +593 to +595
if listener.Protocol != gatewayv1.HTTPProtocolType &&
listener.Protocol != gatewayv1.HTTPSProtocolType &&
listener.Protocol != gatewayv1.TLSProtocolType {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the supportedRoutesByProtocol() like so:

_, ok := supportedRoutesByProtocol()[listener.Protocol]

and then check !ok? This way we can avoid forgetting to update this when we add support for other protocols. WDYT?

Comment on lines +599 to +611
// Only TLS terminate mode supported with HTTPS Listeners.
if listener.Protocol == gatewayv1.HTTPSProtocolType && *listener.TLS.Mode != gatewayv1.TLSModeTerminate {
acceptedCondition.Status = metav1.ConditionFalse
acceptedCondition.Reason = string(ListenereReasonInvalidTLSMode)
acceptedCondition.Message = "Only Terminate mode is supported with HTTPS listeners"
}

// Only TLS passthrough mode supported with TLS Listeners.
if listener.Protocol == gatewayv1.TLSProtocolType && *listener.TLS.Mode != gatewayv1.TLSModePassthrough {
acceptedCondition.Status = metav1.ConditionFalse
acceptedCondition.Reason = string(ListenereReasonInvalidTLSMode)
acceptedCondition.Message = "Only Passthrough mode is supported with TLS listeners"
}
Copy link
Member

Choose a reason for hiding this comment

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

WDYT about using a switch on the protocol here and then nesting the particular conditions for those protocols inside the cases?

Copy link
Member

Choose a reason for hiding this comment

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

Can we add one more sample with just the TLSRoute and a Gateway with TLS listener?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable TLS listeners on Gateways
2 participants