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

aggregator: add port support, unified for both modes #45082

Closed
wants to merge 6 commits into from

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Apr 28, 2017

Add a port field to the service reference of an APIService.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 28, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sttts
We suggest the following additional approver: deads2k

Assign the PR to them by writing /assign @deads2k in a comment when ready.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Apr 28, 2017
@deads2k
Copy link
Contributor

deads2k commented Apr 28, 2017

@cheftako you want to take a look?

@@ -96,7 +97,10 @@ func (c *APIServiceRegistrationController) sync(key string) error {
return err
}

c.apiHandlerManager.AddAPIService(apiService, c.getDestinationHost(apiService))
host := c.getDestinationHost(apiService)
if len(host) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

If an APIService is updated to remove its referenced service (becomes local), we need to update to reflect that, right?

@sttts sttts force-pushed the sttts-aggregator-ports branch 2 times, most recently from ff58e0d to d79e123 Compare April 28, 2017 15:42

port := int32(443)
if len(service.Spec.Ports) > 0 {
port = service.Spec.Ports[0].Port
Copy link
Member

Choose a reason for hiding this comment

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

This seems fine if len() == 1. However if len() > 1 this seems problematic. I couldn't find any indication of ordering in our documentation so I'm not sure we can rely on that. In fact one of our examples has the https port second and that seems like the port we should be using. So if len() > 1 we could look for a name which indicates what we should be using, such as https. We could also look to fix the registration system to specify a port (?name) if there is more than 1 port. Picking the first port seems like what we should do if all other resolution mechanisms fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed that there is an order. If not, this does not make sense, totally agree. Actually, I do not want too many heuristic. I would prefer adding an explicit port name to the apiservice spec and only allow to leave that empty if there is exactly one port in a service. Wdyt?

}

port := int32(443)
if len(service.Spec.Ports) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

The validation code as far as I can tell prevents you getting in to the length equals 0 case. Not sure it would be safe to force the port to 443 if that wasn't true. Not sure how the networking code would function if no ports were specified but if it either left all ports open or forwarded based on which ports the relevant pod specified, then you could be forcing to the wrong port and something that had been working would now be broken.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2017
@luxas
Copy link
Member

luxas commented May 30, 2017

First port is used if defined. Otherwise, 443. We could extend this with a portName field in the future.

@sttts Why not just support portName right away?

@sttts sttts force-pushed the sttts-aggregator-ports branch from d79e123 to 1588934 Compare May 30, 2017 13:09
@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 30, 2017
@sttts sttts changed the title kube-aggregator: add support for service port definitions aggregator: unify resolver implementation and tests May 30, 2017
@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels May 30, 2017
@sttts
Copy link
Contributor Author

sttts commented May 30, 2017

@deads2k @cheftako I rebased this onto the merged pod ip resolver code, reactivated our old resolver tests and unified both resolvers. I would very much like to get this into 1.7 before people start using the new api, especially the requirements around service ports and the service name syntax scheme:name:port.

}
if len(portStr) == 0 {
switch svcScheme {
case "http":
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't safely proxy over http. I think we should always force https.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My argument for http was that it's useful during development without certs. But if we can ignore self-signed certs anyway, there is not much need for http.

@deads2k
Copy link
Contributor

deads2k commented May 30, 2017

especially the requirements around service ports and the service name syntax scheme:name:port.

We have to use SSL in order to identify the aggregator from the user API server. For ports, my first choice is always 443 on the service (the endpoint thing is going to have to do the translation), my second choice is to add a port field and the endpoint thing still has to do the translation from service to endpoint port.

@sttts sttts force-pushed the sttts-aggregator-ports branch from cce231a to f3fa433 Compare May 30, 2017 14:17
@sttts sttts changed the title aggregator: unify resolver implementation and tests aggregator: add port support, unified for both modes May 30, 2017
@sttts
Copy link
Contributor Author

sttts commented May 30, 2017

I have extracted the uncontroversial part of the code without the scheme+port syntax into #46623. ptal.

@sttts
Copy link
Contributor Author

sttts commented May 30, 2017

my second choice is to add a port field and the endpoint thing still has to do the translation from service to endpoint port.

I favor this one. Let us add a Port *IntString field which defaults to 443.

@sttts sttts force-pushed the sttts-aggregator-ports branch from f3fa433 to 5d2838e Compare May 30, 2017 16:45
@sttts
Copy link
Contributor Author

sttts commented May 30, 2017

@deads2k @cheftako added the port field to ServiceReference. ptal

@sttts sttts force-pushed the sttts-aggregator-ports branch 3 times, most recently from 0e094f7 to 5fdf001 Compare May 31, 2017 10:32
@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 31, 2017
@sttts sttts force-pushed the sttts-aggregator-ports branch from 5fdf001 to 6fc2aae Compare May 31, 2017 11:38
@sttts sttts force-pushed the sttts-aggregator-ports branch from 6fc2aae to 810422a Compare May 31, 2017 12:23
@sttts
Copy link
Contributor Author

sttts commented May 31, 2017

@k8s-bot pull-kubernetes-unit test this

1 similar comment
@sttts
Copy link
Contributor Author

sttts commented May 31, 2017

@k8s-bot pull-kubernetes-unit test this

@sttts
Copy link
Contributor Author

sttts commented May 31, 2017

@k8s-bot pull-kubernetes-verify test this

@sttts sttts modified the milestone: v1.7 May 31, 2017
k8s-github-robot pushed a commit that referenced this pull request Jun 1, 2017
Automatic merge from submit-queue (batch tested with PRs 43505, 45168, 46439, 46677, 46623)

aggregator: unify resolver implementation and tests

This is #45082, but without the port support.
@k8s-github-robot
Copy link

@sttts PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2017
@k8s-github-robot
Copy link

This PR hasn't been active in 38 days. It will be closed in 51 days (Aug 29, 2017).

cc @cheftako @deads2k @sttts

You can add 'keep-open' label to prevent this from happening, or add a comment to keep it open another 90 days

@sttts
Copy link
Contributor Author

sttts commented Jul 19, 2017

We decided not to implement custom port support. So closing it for now.

@sttts sttts closed this Jul 19, 2017
@WIZARD-CXY
Copy link
Contributor

@sttts I wonder why " we decided not to implement custom port support"? I think it is nice to have.

@sttts
Copy link
Contributor Author

sttts commented Jan 2, 2018

@WIZARD-CXY because it is only "nice to have", i.e. you can easily use a default port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants