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

clarify requirement for port in forwardTo #685

Closed
wants to merge 1 commit into from

Conversation

hbagdi
Copy link
Contributor

@hbagdi hbagdi commented May 26, 2021

What type of PR is this?

/kind documentation
What this PR does / why we need it:

Clarify when port is required and when it is optional.

Which issue(s) this PR fixes:

For #578

Does this PR introduce a user-facing change?:

NONE

/cc @robscott @stevesloka @danehans

@k8s-ci-robot k8s-ci-robot added the kind/documentation Categorizes issue or PR as related to documentation. label May 26, 2021
@k8s-ci-robot
Copy link
Contributor

@hbagdi: GitHub didn't allow me to request PR reviews from the following users: stevesloka.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

What type of PR is this?

/kind documentation
What this PR does / why we need it:

Clarify when port is required and when it is optional.

Which issue(s) this PR fixes:

For #578

Does this PR introduce a user-facing change?:

NONE

/cc @robscott @stevesloka @danehans

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 26, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbagdi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 26, 2021
@hbagdi
Copy link
Contributor Author

hbagdi commented May 26, 2021

Please see #578 (comment) for some additional context.

@robscott
Copy link
Member

/retest

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks for the work on this!

// when forwarding to a backendRef or serviceName.
// Port is required when the request is being forwarded to a Kubernetes
// Service. Port is optional with BackendRef to enable use cases where
// the port should be read from the referrant resource.
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 like something we should enforce with webhook validation. What should we do if BackendRef points to a Service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems like something we should enforce with webhook validation.

Absolutely, please see #578 (comment). With this patch and the validation bit, the user experience should be good.

What should we do if BackendRef points to a Service?

I didn't consider that part because I wrongly assumed that was not allowed. Is there a good reason to allow such a thing in the first place? At this level of detail, I personally prefer having only one way to do something.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't consider that part because I wrongly assumed that was not allowed. Is there a good reason to allow such a thing in the first place?

One potential example - say we end up adding the ability to forward traffic to a Service in another namespace. We have 3 options:

  1. Add a backendRef.Namespace field, this supports everything if Service can be referenced by BackendRef
  2. Add a serviceNamespace field, this only supports Service
  3. Add both a serviceNamespace field and backendRef.Namespace field

I'm pretty sure we want to avoid 3, and 2 could eventually lead to 3.

At this level of detail, I personally prefer having only one way to do something.

This may be a good argument against the serviceName shortcut altogether. I need to think about it more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is devolving into a separate conversation on if we should have serviceName shortcut or not.
Let's take a look at the following two examples:

forwardTo:
- serviceName: foo
  port: 80
forwardTo:
- backendRef:
    kind: Service
    name: foo
  port: 80

The easy path is shorter but not significantly so. The two additional lines also help with creating awareness around this extension point. Given how many corner cases exist with this special case, I think it would be best if we drop serviceName special case from here and rest of the API as well.

@jpeach @bowei @robscott @danehans Would love to hear your take on this.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be confusing if backendRef.kind defaulted to Service? That would make the difference even smaller:

forwardTo:
- serviceName: foo
  port: 80
forwardTo:
- backendRef:
    name: foo
    port: 80

Given that we've required port to be specified when the backend is a Service, there's no longer a simple serviceName only short form anyway.

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'd rather take one extra line of YAML over solving the corner cases the shortcut is introducing.
Would love to hear from others.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @hbagdi on this one. I don't see the serviceName shortcut adding enough value to make the effort worthwhile.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are thinking about having backendRef default to Service then why not do the following:

forwardTo:
- backendName: foo
  port: 80
  kind: <defaults to Service>

This still provides the shortcut, provides only 1 way of doing things, and is also the minimal number of lines. I hate to be so focused on number of YAML lines, but forwardTo is also one of the most heavily used fields in the API so the verbosity will be multiplied.

Using a key like backendName is also nice because backend is a proper term for thing that's being pointed to. I have already heard people call it "the forwardTo" which feels a bit off.

@k8s-ci-robot
Copy link
Contributor

@hbagdi: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2021
@hbagdi
Copy link
Contributor Author

hbagdi commented Jul 13, 2021

@youngnick @robscott @mark-church I've introduced a small GEP to arrive at a decision here: #719.
I'd love to hear your thoughts in that PR.

@hbagdi
Copy link
Contributor Author

hbagdi commented Aug 6, 2021

/close
See #750

@k8s-ci-robot
Copy link
Contributor

@hbagdi: Closed this PR.

In response to this:

/close
See #750

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants