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

AWS: SSL support for ELB listeners through annotations #23495

Merged
merged 5 commits into from
May 12, 2016

Conversation

therc
Copy link
Member

@therc therc commented Mar 25, 2016

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

@therc
Copy link
Member Author

therc commented Mar 25, 2016

cc @justinsb

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-merge labels Mar 25, 2016
@k8s-github-robot
Copy link

The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?

@therc therc mentioned this pull request Mar 26, 2016
@therc therc changed the title Add support for HTTPS->HTTP ELB listeners through annotations Add SSL support for ELB listeners through annotations Mar 28, 2016
@therc
Copy link
Member Author

therc commented Mar 28, 2016

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 protocol=certARN syntax, added checks and errors, moved the listener creation to an earlier stage so that we don't leave security groups behind and added comments/pointers.

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 28, 2016
@k8s-github-robot
Copy link

The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?

@therc
Copy link
Member Author

therc commented Apr 14, 2016

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).

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 14, 2016
@justinsb justinsb added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Apr 21, 2016
@justinsb justinsb added this to the v1.3 milestone Apr 21, 2016
@justinsb
Copy link
Member

Nice. A few thoughts:

  1. Is HTTP vs TCP orthogonal here? e.g. should it maybe be a different annotation. There is also another WIP PR (AWS: ELB proxy protocol support via annotation service.beta.kubernetes.io/aws-load-balancer-proxy-protocol #24569) to add PROXY protocol, so I'd like to figure out what our final set of annotations should be (once we have SSL, PROXY, HTTP etc).
  2. Do we want to support http & https? Even if the http listener is only going to redirect to https, I think we still need it. But I'm also not sure exactly how we solve this cleanly within the framework we have.

Random thoughts (no action required):

  1. I'm wondering if we should use the arn, or use tags to create something easier to manage. But if you're requiring a full arn e.g. arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert then that works fine because we can always look at the arn: prefix.
  2. A long-term goal of k8s (as I understand it) is to allow multiple untrusted tenants to share a k8s cluster. So being able to use any cert you know the name of is not ideal. But I imagine we would solve this with an ACL tag on the cert, or an ACL entry when we implement real ACLs.

@therc
Copy link
Member Author

therc commented Apr 28, 2016

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.

@dwelch2344
Copy link

Hey all, just weighing in...

@justinb: Do we want to support http & https? Even if the http listener is only going to redirect to https, I think we still need it. But I'm also not sure exactly how we solve this cleanly within the framework we have.
This is a definite must IMO. Doesn't necessarily need to be there first cut, but I would say that a lot of people (including myself) would expect this ability and get burned without it.

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.

@therc
Copy link
Member Author

therc commented May 2, 2016

I split the single annotation into aws-load-balancer-ssl-cert / aws-load-balancer-backend-protocol=(https|http|ssl|tcp) and updated the PR description. Mixed listeners will be implemented separately.

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)
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@justinsb
Copy link
Member

justinsb commented May 10, 2016

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
@therc
Copy link
Member Author

therc commented May 10, 2016

I fixed all nits and changed the default.

if certID != "" {
instanceProtocol = annotations[ServiceAnnotationLoadBalancerBEProtocol]
if instanceProtocol == "" {
protocol = "ssl"
Copy link
Member

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!

Copy link
Member

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

@justinsb justinsb changed the title Add SSL support for ELB listeners through annotations AWS: SSL support for ELB listeners through annotations May 12, 2016
@justinsb justinsb added release-note Denotes a PR that will be considered when it comes time to generate release notes. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed release-note-label-needed labels May 12, 2016
@justinsb
Copy link
Member

LGTM :-)

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented May 12, 2016

GCE e2e build/test passed for commit 5933440.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 4ac4e0f into kubernetes:master May 12, 2016
k8s-github-robot pushed a commit that referenced this pull request May 20, 2016
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).
@dkozma
Copy link

dkozma commented May 25, 2016

@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
ELB HTTP/:80 -> 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
ELB HTTPS/:80 -> 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
Copy link
Member Author

therc commented May 25, 2016

@dkozma that's expected, but #26268 will take care of your case.

@dkozma
Copy link

dkozma commented May 25, 2016

@therc Perfect, thanks!

@therc
Copy link
Member Author

therc commented Jun 7, 2016

@dkozma would you be able to test #26976?

@dkozma
Copy link

dkozma commented Jun 7, 2016

@therc I can spin up a cluster tomorrow and let you know the results.

@dkozma
Copy link

dkozma commented Jun 10, 2016

@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.

@razic
Copy link

razic commented Aug 9, 2016

@therc
@dkozma

I have a suggestion to this feature. Currently the annotation is named aws-load-balancer-backend-protocol. However, look at the image below:

screen shot 2016-08-08 at 5 12 48 pm

AWS uses the terminology instance and not backend. To avoid confusion, and to ensure consistency, I suggest that we change

aws-load-balancer-backend-protocol

to

aws-load-balancer-instance-protocol

Please let me know your thoughts. Thanks!

xingzhou pushed a commit to xingzhou/kubernetes that referenced this pull request Dec 15, 2016
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).
@ghost
Copy link

ghost commented Jan 31, 2017

cc @kubernetes/sig-federation-misc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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
Development

Successfully merging this pull request may close these issues.

8 participants