Skip to content

Allow Service NodePorts on low ports #9995

Closed

Description

@thockin

To capture some of the discussion.

Gripe: Service NodePorts can only be in a "special" port range (apiserver flag). This is annoying for people who want to expose a service on port 80 (for example) but instead have to use something like 30986.

Rationale for this behavior:

  1. We don't want service node ports to tromp on real ports used by the node (e.g. 22).
  2. We don't want service node ports to tromp on pod host ports.
  3. We don't want to randomly allocate someone port 80 or 443 or 22.

Proposed compromise: Allow NodePorts on low ports with a bunch of caveats.

To address rationale points (1) and (2): Make kube-proxy open (and hold open) ports that it is using. This will prevent it from using port 22 (for example) for a service node port.

To address rationale point (3): Use the flag-configured range for random allocations, but allow users to request any port they want.

Caveats and analysis:

  1. Error reporting is not good. We do not know about what non-container stuff is using ports on the host and we do not have an easy way for the API server to allocate ports between pods and services. Not easy to resolve. The implication of this is that port-in-use errors will only be detected by kube-proxy when it tries to open the port on the node. Sending events for this is possible, but not great (one event from every node) and no other node-level error gets a kube-proxy event. Net result: user asked for a service on node port 22, and it just doesn't work and they have no idea why.

  2. Doing dual-ranges (use the flag range for allocations but allow the whole range to be used) is non-trivial and has to be plumbed through more code than I am comfortable with at this point. The implication of not doing this is that sometimes people will get allocated a port that happens to be 22 and can never work. Combined with caveat (1) this is really unpleasant. We could do some REALLY hacky things like just retry the random allocation if it is not in the flagged range. This avoids plumbing the dual-range logic down, but is embarassingly ugly. I am ashamed to have suggested it.

  3. Holding ports open is pretty easy and we should do this anyway. The error reporting properties are still not good.

Summary: I am unconvinced that this is worthwhile to rush into v1. We still have the option of baking a container that receives traffic on a HostPort and redirects it to a service. I have a demo of using socat to do this (simulating a pod manually):

root@kubernetes-minion-nnx6:/home/thockin# docker run -d --dns=10.0.0.10 --dns-search=default.svc.cluster.local -p 8080:93 thockin/hostport-to-service 93 hostnames2:80
1dcc1e94c30834290ae243ac298c6699b2a3348fc014b4b77ae34c13ead44854

root@kubernetes-minion-nnx6:/home/thockin# curl localhost:8080
hostnames2-gxt4f

@brendandburns @justinsb @eparis

Activity

  1. added
    kind/designCategorizes issue or PR as related to design.
    priority/backlogHigher priority than priority/awaiting-more-evidence.
    on Jun 18, 2015
  2. thockin commented on Jun 18, 2015

    @thockin
    MemberAuthor

    Priority to be decided - some argue that it is P0.

  3. thockin commented on Jun 18, 2015

    @thockin
    MemberAuthor

    I hope my summary wasn't TOO slanted. There are legitimate issues that
    this sort of change would fix.
    On Jun 17, 2015 6:16 PM, "Quinton Hoole" notifications@github.com wrote:

    Thanks for summarizing the discussion so succintly @thockin
    https://github.com/thockin.

    Unless I'm misunderstanding the proposal, it involves unpredictable and
    difficult to diagnose failure of services, which seems like a complete
    non-starter to me. Or at the very least, vastly more undesirable than the
    annoyance of not being able to expose a service on a favorite pet host port
    number?

    Am I missing something?

    —
    Reply to this email directly or view it on GitHub
    #9995 (comment)
    .

  4. thockin commented on Jun 18, 2015

    @thockin
    MemberAuthor

    That is one of the legitimate use cases, though no user is claiming this
    one is a hard requirement. The biggest issue is simply friction and "kick
    the tires" operation.
    On Jun 17, 2015 7:23 PM, "Quinton Hoole" notifications@github.com wrote:

    PS: I am familiar with the "I have an upstream application/network device
    which connects/forwards to port x and it's difficult to reconfigure" use
    case. Is that the legitimate issue? Are there others?

    —
    Reply to this email directly or view it on GitHub
    #9995 (comment)
    .

  5. eparis commented on Jun 18, 2015

    @eparis
    Contributor

    A great example would be the L7 ingress router used by openshift. It needs to run on 80 and 443. Quite reasonable and not at all a 'kick-the-tires' kind of thing.

    While hostPort might be possible it does mean that I can't use rc's any more, as I have to start pinning the ingress router container to specific nodes. With publicIPs this was solved, as externally people could be told to use publicIP[0]:443 and everything would be ok as the ingress router could still be managed by the cluster.

    (actually for some cert checking reasons we've had to bastardize the ingress router, but it worked really well on 80)

  6. thockin commented on Jun 19, 2015

    @thockin
    MemberAuthor

    @eparis I don't think I understand your model. You run L7-as-a-service and you tell people to connect to $node_ip on :80 and :443, rather than a load balancer? And you're confident that no user of the cluster will ever ask for a Service with port 80 or 443 and ask for NodePort of the same port?

    If so, you could change the apiserver's --service-node-port-range to "1-32767" and install your L7 before anyone "randomly" claims :80 or :443.

    To reiterate, we WANT to enable this, but there's not time to do it properly before 1.0 - if you're comfortable with the caveats above, you can fix this today. My argument is that it should not default to "ridiculously brittle" mode and that the changes to make it not-brittle are too much churn for this point in the release cycle.

  7. eparis commented on Jun 19, 2015

    @eparis
    Contributor

    --service-node-port-range=1-32767 suffers extremely from accidentally stomping on port 22, not someone screwed up, the SYSTEM screwed up....

  8. eparis commented on Jun 19, 2015

    @eparis
    Contributor

    @thockin some people do have an external load balancer to terminate ssl and load balance to pods, which operates with access to the overlay network. Those people have better scalability for sure. But we provide a simple 'load balancer', running on ${some_node_ips} :80 :443 (nodePort would mean $all_node_ips).

    We have no controller for nodePort yet, but yes, the plan is to outright reject a service if a 'normal' user specified anything other than 0.

    To be honest, it does make me wonder what we do today if someone asks for hostPort=22. I think we just outright reject hostPort, but I don't know for sure...

  9. 22 remaining items

  10. rektide commented on Sep 26, 2020

    @rektide

    Unless I'm misunderstanding the proposal, it involves unpredictable and difficult to diagnose failure of services, which seems like a complete non-starter to me.

    This seems to be the only resistance I've heard to this & I don't understand the complaint. It wasn't elaborated or explained.

    This issue seems like a straightforward way to host a range of services easily that currently are a huge pain to deal with (like http) while maintaining current functionality for most. This should be re-opened. I don't understand why hosting HTTP or DNS is so very very difficult for small operators right now.

  11. paulmiu commented on Oct 3, 2020

    @paulmiu

    @liggitt @wojtek-t @dims @justaugustus (Sorry for mentioning you all, I just randomly picked still active contributors.)

    1. Who is able to reopen this issue?
    2. If this is not intended, who is able to give us a solid explanation why this won't be changed/"fixed"? (As requested in the comment above)

    If you're not responsible for this part of k8s, but know who is, please include that person in this conversation.
    Thanks.

  12. liggitt commented on Oct 3, 2020

    @liggitt
    Member

    @thockin can reopen it if desired and has good context on why it would be a good or bad idea to do so. Adding this topic to the next sig-network agenda would be a good way to discuss it

  13. paulmiu commented on Oct 3, 2020

    @paulmiu

    @liggitt Thanks for your quick response!

    Can you include it in the sig-network agenda (or if I am able to do that too, how can I add this topic to it)?

  14. liggitt commented on Oct 3, 2020

    @liggitt
    Member

    The time and agenda info is at https://github.com/kubernetes/community/tree/master/sig-network

    Joining the kubernetes-dev or kubernetes-sig-network mailing lists should get you access to those

  15. paulmiu commented on Oct 3, 2020

    @paulmiu

    Thanks, I'll do that.

    Edit:

    It's now on the agenda for the next SIG Network Meeting. I've also sent an email to the mailing list.

  16. denizdogan commented on Nov 17, 2020

    @denizdogan

    Was it ever discussed by the SIG? I'm assuming no, based on the note from October 15 that says:

    (deferred - suggesting party not here) Suggested topic by Manu Miu (manu.miu@gmail.com): Discussion of the Github issue “Allow Service NodePorts on low ports” as described in this mailing list email.

  17. fuomag9 commented on Mar 2, 2021

    @fuomag9

    Is there any update on this? I find it very illogical not to be able to open ports different from port 22!

  18. theAkito commented on Mar 2, 2021

    @theAkito

    Is there any update on this? I find it very illogical not to be able to open ports different from port 22!

    I think it is important to stay fair to all parties in a controversial discussion, which is why I would like you to clarify what you are talking about. This has nothing to do with Port 22 (default SSH) port, as in the whole point of the special NodePort range is that ports such as the one for SSH do not get allocated.

    All that said, it is best practice to change the default SSH port to something other than 22, anyway.

  19. fuomag9 commented on Mar 2, 2021

    @fuomag9

    Is there any update on this? I find it very illogical not to be able to open ports different from port 22!

    I think it is important to stay fair to all parties in a controversial discussion, which is why I would like you to clarify what you are talking about. This has nothing to do with Port 22 (default SSH) port, as in the whole point of the special NodePort range is that ports such as the one for SSH do not get allocated.

    All that said, it is best practice to change the default SSH port to something other than 22, anyway.

    I probably bad worded it, I meant it in the "don't conflict with existing stuff" but still allow a lower number in the range of ports to be allocated by NodePort

  20. added
    sig/networkCategorizes an issue or PR as relevant to SIG Network.
    on Mar 2, 2021
  21. BenTheElder commented on Mar 2, 2021

    @BenTheElder
    Member

    I just want to point out that this is actually up to your cluster operator, the node port range has long been configurable
    with the --service-node-port-range option for kube-apiserver. https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/

    Also this old comment:

    If only kubernetes allowed mapping NodePort Service onto a particular port on Node, this would save us one indirection.

    Unless I've completely misunderstood the intent here ... You can absolutely do that. It still has to be within the configured range though. Set the nodePort field on the ports entry.
    https://kubernetes.io/docs/concepts/services-networking/service/#nodeport


    SIG Network still owns this. Any community member has the ability to reopen, but personally I would still defer to the network special interest group. I've sent a poke to them.

  22. aojea commented on Mar 3, 2021

    @aojea
    Member

    This was answered in the mailing list too
    https://groups.google.com/g/kubernetes-sig-network/c/Ihq_1AslEMQ/m/oFiOxOJcAQAJ

    I think that this will be reopened as a bug if --service-node-port-range can not select a different nodeport range or, if it can, those doesn't work

  23. wzrdtales commented on Mar 3, 2021

    @wzrdtales

    @BenTheElder also wondering why this pops up in my mails again and again your interpretation is right, that is what this issue was about. changing the node port range is supported. I guess people that hit on that problem find in google instead of the documentation this issue first.

  24. thockin commented on Mar 5, 2021

    @thockin
    MemberAuthor

    If you set the service-node-port-range to include 22, then that means 22 might be randomly allocated to any Service, even if you have SSH running and want to keep it running. BAD.

    One option discussed a long time back was to allow low ports to be EXPLICITLY requested but not allocated. But then what governs who may request low ports? And how do you block off the ports that you don't want anyone to use?

    TL;DR: this seems like a lot of work and design for something that isn't really that common. You can use a pod hostPort to claim a low port, but only on a single node. That's better, but has many of the same problems - governance, collisions, exclusions.

    NodePorts were designed to build LBs on top of. They are not supposed to be very friendly to humans because humans are not the target audience,

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/designCategorizes issue or PR as related to design.priority/backlogHigher priority than priority/awaiting-more-evidence.sig/networkCategorizes an issue or PR as relevant to SIG Network.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions