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

Require Service.ContainerPort #983

Closed
thockin opened this issue Aug 21, 2014 · 24 comments
Closed

Require Service.ContainerPort #983

thockin opened this issue Aug 21, 2014 · 24 comments
Assignees
Labels
area/api Indicates an issue on api area. area/usability priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Milestone

Comments

@thockin
Copy link
Member

thockin commented Aug 21, 2014

The fallback for now is to use Container[0].Port[0] which is, IMO, confusing.

@brendandburns
Copy link
Contributor

If you have a simple pod, with one port, and a service for that pod, it feels highly redundant and verbose to have to specify the port too.

I'm not going to fight super hard for this default, but that's the reason it's there.

@thockin
Copy link
Member Author

thockin commented Aug 21, 2014

Discussion happening on two threads, I'll leave it on the other one since I
already replied there. TL;DR Clayton to tie-break.

On Wed, Aug 20, 2014 at 8:49 PM, brendandburns notifications@github.com
wrote:

If you have a simple pod, with one port, and a service for that pod, it
feels highly redundant and verbose to have to specify the port too.

I'm not going to fight super hard for this default, but that's the reason
it's there.

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

@bgrant0607
Copy link
Member

See also #974

@dchen1107
Copy link
Member

Can we just simply name it as Service.Port, not Service.ContainerPort. ContainerPort here is confusing too.

@bgrant0607
Copy link
Member

Service.Port is the port clients use to connect to the service. Service.ContainerPort is the port to which the service proxy connects on the containers. Service.ContainerPort is consistent with the terminology in the pod port spec.

@thockin
Copy link
Member Author

thockin commented Aug 21, 2014

PodPort would make more sense in Service.
On Aug 21, 2014 9:10 AM, "bgrant0607" notifications@github.com wrote:

Service.Port is the port clients use to connect to the service.
Service.ContainerPort is the port to which the service proxy connects on
the containers. Service.ContainerPort is consistent with the terminology in
the pod port spec.

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

@lavalamp
Copy link
Member

'DestinationPort' is super clear and my preference. PodPort is ambiguous, I vote strong no; is it supposed to mean the where the port shows up in the sending pod or the receiving pod? (Likewise for the current ContainerPort; in fact, I had Port and ContainerPort backwards in my head until chatting with Brian yesterday.)

Using the first port implies that there's an ordering to the ports, which may be an impression we don't want to foster. Is there any other sane default we can use?

I honestly don't think it's that redundant to require both. The service describes a flow of traffic, I think it's actually a little weird to not say where the traffic is supposed to go.

@smarterclayton
Copy link
Contributor

Agree port ordering should not be significant.

@thockin
Copy link
Member Author

thockin commented Aug 23, 2014

Clayton: to clarify, if port ordering is not significant, then no "default to first port" applies to the spec, which implies that ContainerPort (possibly renamed to DestinationPort) is a required field?

Do we care about compat here? Changing a field to required may break people.

@smarterclayton
Copy link
Contributor

We could change that when we rev the API if necessary.

@jbeda
Copy link
Contributor

jbeda commented Aug 25, 2014

Merging in discussion from #1030.

How about this:

  • An unnamed port is given the name "default". There can only be one of these.
  • Change ContainerPort to something better. I like DestinationPort or TargetPort.
  • If you don't specify ContainerPort on a service we assume default as the port.

@bgrant0607
Copy link
Member

Does the service proxy perform the port name->number mapping? Does it work even in the case that not all pods have the same name->number mapping? Do we want that to work? I assume that it doesn't work in the case of an external load balancer.

I like TargetPort.

@jbeda
Copy link
Contributor

jbeda commented Aug 26, 2014

I would expect that ​the proxy would handle the name going to different
numbers on different containers. That would let you upgrade/change the
port and things would keep working.

@lavalamp
Copy link
Member

TargetPort is less clear than DestinationPort.

I was proposing to name unnamed ports by their port number, not by their index. IMO we should never ever use indexes to refer to ports, we should treat them as a set, not as a list.

@thockin
Copy link
Member Author

thockin commented Aug 26, 2014

I agree, indexing ports is bad. Let's agree to drop that.

I'm fine with the implicit "default", but I am not sure it adds much to the overall system. Why not just say that Service.DestinationPort is required and it can be specified as a port name (string) or a port number (int).

Last topic: the proxy does not resolve names to port numbers, the master does. I am not sure if this part works: Endpoints in api/types.go says it can have port numbers, implying that a service could resolve to different ports per pod. Service.ContainerPort can take port names, which means that, hypothetically, a Service could be made up of pods with different port numbers on the same name. Someone should, like, test that :)

@smarterclayton
Copy link
Contributor

That sounds like a feature I want (migrate ports across pod templates with the same service) if it actually, you know, worked.

@thockin
Copy link
Member Author

thockin commented Aug 27, 2014

It might work. Nobody has tried AFAIK :) I bet it does, with named ports.

On Tue, Aug 26, 2014 at 3:56 PM, Clayton Coleman notifications@github.com
wrote:

That sounds like a feature I want (migrate ports across pod templates with
the same service) if it actually, you know, worked.

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

@thockin
Copy link
Member Author

thockin commented Sep 14, 2014

More fuel for this.

We happily default the Service.ContainerPort to Pod.Containers[0].Ports[0] in pkg/service/endpoints_controller.go, but when we set env vars in pkg/registry/service/rest.go, we just use Service.ContainerPort, which is 0.

@Gurpartap reported this today.

The defaulting should either be done in the validation of service, by writing back the defaulted port, or should not be done at all.

@bgrant0607 bgrant0607 added area/api Indicates an issue on api area. area/usability and removed kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Oct 4, 2014
@bgrant0607 bgrant0607 added this to the v0.8 milestone Oct 4, 2014
@bgrant0607 bgrant0607 added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Dec 1, 2014
@bgrant0607
Copy link
Member

We should resolve this as part of the switch to v1beta3 -- #1519 and #2585.

@bgrant0607 bgrant0607 modified the milestones: v1.0, v0.8 Dec 1, 2014
@thockin
Copy link
Member Author

thockin commented Dec 2, 2014

I'm torn. On the one hand, requiring it is simpler. On the other hand,
allowing the default to be runtime discovered actually means the values can
be different per-pod (not sure if that is good). Also, because we do not
inspect containers for EXPOSEd ports, we miss some. Also the current
default is dumb, but that can be fixed.

I guess in typing it out I lean towards simpler is better.

On Mon, Dec 1, 2014 at 12:57 PM, bgrant0607 notifications@github.com
wrote:

We should resolve this as part of the switch to v1beta3 -- #1519
#1519 and #2585
#2585.

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

@pmorie
Copy link
Member

pmorie commented Jan 15, 2015

+1 to the idea of working with ports only as a set.

One thing I'll add, making it explicit and requiring ContainerPort to be set makes it much easier to write a UI that presents how service align with ports in pods.

ContainerPort isn't the greatest name. I like TargetPodPort the best but it is a bit verbose.

@bgrant0607 bgrant0607 added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Feb 5, 2015
@goltermann goltermann removed this from the v1.0 milestone Feb 6, 2015
@thockin thockin removed this from the v1.0 milestone Feb 6, 2015
@bgrant0607 bgrant0607 modified the milestone: v1.0 Feb 6, 2015
@brendandburns
Copy link
Contributor

Assigning to @thockin since he says his refactor will cover the rename.

@jdef
Copy link
Contributor

jdef commented Mar 11, 2015

xref mesosphere/kubernetes-mesos#59

@brendandburns
Copy link
Contributor

I'm going to close this issue as:

  • Port has been renamed to ContainerPort
  • We now have improved default behavior, and attempts to implement a (more) complete solution were rejected by @thockin

Re-open if you have any concerns.

vishh pushed a commit to vishh/kubernetes that referenced this issue Apr 6, 2016
rphillips pushed a commit to rphillips/kubernetes that referenced this issue Oct 4, 2021
…rry-pick-963-to-release-4.9

[release-4.9] Bug 2008619: UPSTREAM: <carry>: openshift-hack/images/os/Dockerfile: Add io.openshift.build.versions, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Indicates an issue on api area. area/usability priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

10 participants