mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Change default when no BE proto given, add test for that
Also improve error message when BE proto is wrong
This commit is contained in:
parent
e19c069b9d
commit
59334408a6
@ -2133,12 +2133,12 @@ func buildListener(port api.ServicePort, annotations map[string]string) (*elb.Li
|
|||||||
if certID != "" {
|
if certID != "" {
|
||||||
instanceProtocol = annotations[ServiceAnnotationLoadBalancerBEProtocol]
|
instanceProtocol = annotations[ServiceAnnotationLoadBalancerBEProtocol]
|
||||||
if instanceProtocol == "" {
|
if instanceProtocol == "" {
|
||||||
protocol = "https"
|
protocol = "ssl"
|
||||||
instanceProtocol = "http"
|
instanceProtocol = "tcp"
|
||||||
} else {
|
} else {
|
||||||
protocol = backendProtocolMapping[instanceProtocol]
|
protocol = backendProtocolMapping[instanceProtocol]
|
||||||
if protocol == "" {
|
if protocol == "" {
|
||||||
return nil, fmt.Errorf("Invalid backend protocol %s in %s", instanceProtocol, certID)
|
return nil, fmt.Errorf("Invalid backend protocol %s for %s in %s", instanceProtocol, certID, ServiceAnnotationLoadBalancerBEProtocol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener.SSLCertificateId = &certID
|
listener.SSLCertificateId = &certID
|
||||||
|
@ -1216,9 +1216,14 @@ func TestBuildListener(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"No cert or BE protocol annotation, passthrough",
|
"No cert or BE protocol annotation, passthrough",
|
||||||
80, 8000, "", "",
|
80, 7999, "", "",
|
||||||
false, "tcp", "tcp", "",
|
false, "tcp", "tcp", "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Cert annotation without BE protocol specified, SSL->TCP",
|
||||||
|
80, 8000, "", "cert",
|
||||||
|
false, "ssl", "tcp", "cert",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"BE protocol without cert annotation, passthrough",
|
"BE protocol without cert annotation, passthrough",
|
||||||
443, 8001, "https", "",
|
443, 8001, "https", "",
|
||||||
@ -1265,7 +1270,7 @@ func TestBuildListener(t *testing.T) {
|
|||||||
if test.certAnnotation != "" {
|
if test.certAnnotation != "" {
|
||||||
annotations[ServiceAnnotationLoadBalancerCertificate] = test.certAnnotation
|
annotations[ServiceAnnotationLoadBalancerCertificate] = test.certAnnotation
|
||||||
}
|
}
|
||||||
l, err := getListener(api.ServicePort{
|
l, err := buildListener(api.ServicePort{
|
||||||
NodePort: int32(test.instancePort),
|
NodePort: int32(test.instancePort),
|
||||||
Port: int32(test.lbPort),
|
Port: int32(test.lbPort),
|
||||||
Protocol: api.Protocol("tcp"),
|
Protocol: api.Protocol("tcp"),
|
||||||
|
Loading…
Reference in New Issue
Block a user