Skip to content

Allow Service NodePorts on low ports #9995

Closed
@thockin

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

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

thockin commented on Jun 18, 2015

@thockin
MemberAuthor

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

ghost
thockin

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

ghost
ghost
thockin

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

ghost
eparis

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)

ghost
thockin

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.

eparis

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

42 remaining items

Loading
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

        Participants

        @statik@matti@cjbottaro@denizdogan@rektide

        Issue actions

          Allow Service NodePorts on low ports · Issue #9995 · kubernetes/kubernetes