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

Skip gateway TLS listener in passthrough mode #6986

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions pkg/controller/certificate-shim/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ func validateGatewayListenerBlock(path *field.Path, l gwapi.Listener, ingLike me
return errs
}

if l.TLS.Mode == nil {
errs = append(errs, field.Required(path.Child("tls").Child("mode"),
"the mode field is required"))
} else if l.Protocol == gwapi.TLSProtocolType && *l.TLS.Mode == gwapi.TLSModePassthrough {
// skip TLS-listener in TLS-passthrough mode
return errs
} else if *l.TLS.Mode != gwapi.TLSModeTerminate {
errs = append(errs, field.NotSupported(path.Child("tls").Child("mode"),
*l.TLS.Mode, []string{string(gwapi.TLSModeTerminate)}))
}

if len(l.TLS.CertificateRefs) == 0 {
errs = append(errs, field.Required(path.Child("tls").Child("certificateRef"),
"listener has no certificateRefs"))
Expand All @@ -280,14 +291,6 @@ func validateGatewayListenerBlock(path *field.Path, l gwapi.Listener, ingLike me
}
}

if l.TLS.Mode == nil {
errs = append(errs, field.Required(path.Child("tls").Child("mode"),
"the mode field is required"))
} else if *l.TLS.Mode != gwapi.TLSModeTerminate {
errs = append(errs, field.NotSupported(path.Child("tls").Child("mode"),
*l.TLS.Mode, []string{string(gwapi.TLSModeTerminate)}))
}

return errs
}

Expand Down
62 changes: 62 additions & 0 deletions pkg/controller/certificate-shim/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2462,6 +2462,68 @@ func TestSync(t *testing.T) {
},
},
},
{
Name: "should skip TLS protocol listener in TLS passthrough mode",
Issuer: acmeIssuer,
IssuerLister: []runtime.Object{acmeIssuer},
ExpectedEvents: []string{
`Normal CreateCertificate Successfully created Certificate "example-com-tls"`,
},
IngressLike: &gwapi.Gateway{
ObjectMeta: metav1.ObjectMeta{
Name: "gateway-name",
Namespace: gen.DefaultTestNamespace,
Annotations: map[string]string{
cmapi.IngressIssuerNameAnnotationKey: "issuer-name",
},
UID: types.UID("gateway-name"),
},
Spec: gwapi.GatewaySpec{
GatewayClassName: "test-gateway",
Listeners: []gwapi.Listener{{
Hostname: ptrHostname("example.com"),
Port: 443,
Protocol: gwapi.HTTPSProtocolType,
TLS: &gwapi.GatewayTLSConfig{
Mode: ptrMode(gwapi.TLSModeTerminate),
CertificateRefs: []gwapi.SecretObjectReference{
{
Group: func() *gwapi.Group { g := gwapi.Group("core"); return &g }(),
Kind: func() *gwapi.Kind { k := gwapi.Kind("Secret"); return &k }(),
Name: "example-com-tls",
},
},
},
}, {
Hostname: ptrHostname("subdomain.example.com"),
Port: 443,
Protocol: gwapi.TLSProtocolType,
TLS: &gwapi.GatewayTLSConfig{
Mode: ptrMode(gwapi.TLSModePassthrough),
CertificateRefs: []gwapi.SecretObjectReference{},
},
}},
},
},
ExpectedCreate: []*cmapi.Certificate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "example-com-tls",
Namespace: gen.DefaultTestNamespace,
OwnerReferences: buildGatewayOwnerReferences("gateway-name"),
},
Spec: cmapi.CertificateSpec{
DNSNames: []string{"example.com"},
SecretName: "example-com-tls",
Usages: cmapi.DefaultKeyUsages(),
IssuerRef: cmmeta.ObjectReference{
Name: "issuer-name",
Kind: "Issuer",
},
},
},
},
},
{
Name: "should error if the specified issuer is not found",
IngressLike: &gwapi.Gateway{
Expand Down