-
Notifications
You must be signed in to change notification settings - Fork 40k
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
AWS: SSL support for ELB listeners through annotations #23495
Conversation
cc @justinsb |
The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label? |
I'm working on tests, but I thought I'd submit the new code before the old one gets looked at. I've implemented the |
The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label? |
I added tests. I gave up on trying FakeELB-based tests: I simply added tests for the new getListener() function (another good reason to factor it out of EnsureLoadBalancer). |
Nice. A few thoughts:
Random thoughts (no action required):
|
I'm wary of needing multiple annotations (cert, http/tcp) just for the SSL certificate. I do agree we just keep all of the ELB annotations in sync. As for http, maybe we can have a prefix or suffix indicating the creation of a plain text listener, too. I think our default use case should be HTTPS/SSL only. Redirects are usually a bad idea, see e.g. http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#ssl I think that in the long run an Ingress with all the necessary checks is the way to go for multiple tenancy. |
Hey all, just weighing in...
Using tags or other annotations are totally fine IMO, even if it's a little messy in that you need to wire a few of them together to make it work. |
I split the single annotation into |
Moved listener creation to a separate function, which had the nice side effect of allowing tests (added eight cases).
} else { | ||
protocol = backendProtocolMapping[instanceProtocol] | ||
if protocol == "" { | ||
return nil, fmt.Errorf("Invalid backend protocol %s in %s", instanceProtocol, certID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reference the name of the annotation, to give users more of a hint here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
A few nits which you can fix or not as you see fit. The default value for protocol though I think is more important... I think it would be surprising to set the ssl-cert annotation and have the protocol switch to HTTP. (otherwise LGTM) |
Also improve error message when BE proto is wrong
I fixed all nits and changed the default. |
if certID != "" { | ||
instanceProtocol = annotations[ServiceAnnotationLoadBalancerBEProtocol] | ||
if instanceProtocol == "" { | ||
protocol = "ssl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should warn/error in the case when the user specifies an invalid annotation (i.e. not found in map, vs not found). But that can be a separate PR - I want to get this one merged!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: never mind... I need more coffee
LGTM :-) |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit 5933440. |
Automatic merge from submit-queue |
Automatic merge from submit-queue Update AWS under the hood doc with ELB SSL annotations Document #23495. No e2e tests or release notes needed (the other PR is already in the release docs).
@therc This looks great - thanks for your work on this. When testing this out, I tried to set up the following: ELB HTTPS/:443 -> Service HTTP listener port by setting: metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:xxxxx:certificate/xxxxx
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8000
protocol: TCP
name: http
- port: 443
targetPort: 8000
protocol: TCP
name: https From this setup, I got: ELB HTTPS/:443 -> HTTP Is this expected behavior? If not, is there a way this can be set up to allow HTTP connections over 80 and not HTTPS? |
@therc Perfect, thanks! |
@therc I can spin up a cluster tomorrow and let you know the results. |
@therc Sorry for the delay on this. Just built your branch and spun up a new cluster and everything works great - I have ELB listeners for 80 and 443 working correctly.. Thank you for your efforts in adding this feature. |
I have a suggestion to this feature. Currently the annotation is named AWS uses the terminology
to
Please let me know your thoughts. Thanks! |
Automatic merge from submit-queue Update AWS under the hood doc with ELB SSL annotations Document kubernetes#23495. No e2e tests or release notes needed (the other PR is already in the release docs).
cc @kubernetes/sig-federation-misc |
In the API, ports have only either TCP or UDP as their protocols, but ELB distinguishes HTTPS->HTTP[S]? from SSL->(SSL|TCP).
Per #24978, this is implemented through two separate annotations:
service.beta.kubernetes.io/aws-load-balancer-ssl-cert=arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012
service.beta.kubernetes.io/aws-load-balancer-backend-protocol=(https|http|ssl|tcp)
Mixing plain-text and encrypted listeners will be in a separate PR, implementing #24978's
aws-load-balancer-ssl-ports=LIST