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

Make Kubernetes aware of the LoadBalancer behaviour #92312

Merged
merged 16 commits into from
Nov 9, 2020

Conversation

Sh4d1
Copy link
Member

@Sh4d1 Sh4d1 commented Jun 19, 2020

What type of PR is this?
/kind feature

What this PR does / why we need it:
Implements kubernetes/enhancements#1392
Which issue(s) this PR fixes:
Fixes #79783
Fixes #66607
Special notes for your reviewer:
Naming for the new field still needs to be agreed on
Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/pull/1392

/hold
/cc @thockin
/cc @andrewsykim

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/ipvs kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/network Categorizes an issue or PR as relevant to SIG Network. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 19, 2020
@k8s-ci-robot k8s-ci-robot added area/code-generation area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 20, 2020
@@ -3406,8 +3406,23 @@ type LoadBalancerIngress struct {
// (typically AWS load-balancers)
// +optional
Hostname string

// RouteType specifies the type of route to use for this ingress
// Defaults to `VIP`
Copy link
Member

@aojea aojea Jun 20, 2020

Choose a reason for hiding this comment

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

does this has to be defaulted here?

func SetDefaults_Service(obj *v1.Service) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it needs to get populated by the cloud controller manager, I'm not sure it's the right place. Either we don't default it or we loop through the ingress once EnsureLoadBalancer is called. (Not sure when the SetDefaults_Service is called exactly)

Copy link
Member

Choose a reason for hiding this comment

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

@thockin and/or @andrewsykim would know better,
can you please advice here?

Copy link
Member

Choose a reason for hiding this comment

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

It's a choice.

Do we want every consumer of Service status to find a value in this field? Or do we want the absence of a value to imply a default? Practically speaking, the default is "VIP" since that's what we historically have implemented, so I would be fine to default it as suggested.

for _, ingress := range svcInfo.LoadBalancerIPStrings() {
if ingress != "" {
for _, ingress := range svcInfo.LoadBalancerIngress() {
if ingress.IP != "" && ingress.RouteType != v1.LoadBalancerRouteTypeProxy {
Copy link
Member

Choose a reason for hiding this comment

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

if kube-proxy runs against a previous version of the APIserver this field would not be available, should we check first if the field exists?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 in this case the field would just be an empty string no?

Copy link
Member

Choose a reason for hiding this comment

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

In general we say that clients can be older than servers but not newer. If you want to be pedantic, you check for nil and handle it as the default

Copy link
Member Author

Choose a reason for hiding this comment

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

@thockin do you rather see a IPMode as a string or as a *string. If we set a default on create, I think we can safely use a string and check of empty string instead of nil?

@fedebongio
Copy link
Contributor

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jun 23, 2020
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Overall this looks pretty straight-forward. That said, new fields generally need to be gated and disabled by default, so we can do safe rollbacks. See pkg/features/kube_features.go

@@ -3406,8 +3406,23 @@ type LoadBalancerIngress struct {
// (typically AWS load-balancers)
// +optional
Hostname string

// RouteType specifies the type of route to use for this ingress
// Defaults to `VIP`
Copy link
Member

Choose a reason for hiding this comment

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

It's a choice.

Do we want every consumer of Service status to find a value in this field? Or do we want the absence of a value to imply a default? Practically speaking, the default is "VIP" since that's what we historically have implemented, so I would be fine to default it as suggested.

// RouteType specifies the type of route to use for this ingress
// Defaults to `VIP`
// +optional
RouteType LoadBalancerRouteType
Copy link
Member

Choose a reason for hiding this comment

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

names: This only applies when IP is set, right? So maybe call it ipType or ipDeliveryMode or something starting with ip?

Copy link
Member Author

Choose a reason for hiding this comment

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

ipMode sounds good, wdyt?

pkg/apis/core/types.go Show resolved Hide resolved
pkg/apis/core/types.go Outdated Show resolved Hide resolved
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go Outdated Show resolved Hide resolved
staging/src/k8s.io/apimachinery/pkg/labels/selector.go Outdated Show resolved Hide resolved
staging/src/k8s.io/kubectl/pkg/util/templates/markdown.go Outdated Show resolved Hide resolved
pkg/proxy/iptables/proxier.go Outdated Show resolved Hide resolved
for _, ingress := range svcInfo.LoadBalancerIPStrings() {
if ingress != "" {
for _, ingress := range svcInfo.LoadBalancerIngress() {
if ingress.IP != "" && ingress.RouteType != v1.LoadBalancerRouteTypeProxy {
Copy link
Member

Choose a reason for hiding this comment

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

In general we say that clients can be older than servers but not newer. If you want to be pedantic, you check for nil and handle it as the default

@munnerz
Copy link
Member

munnerz commented Sep 7, 2020

@Sh4d1 are you able to address Tim's comments above? 😄

@Sh4d1
Copy link
Member Author

Sh4d1 commented Nov 10, 2020

@thockin so this will get shipped in 1.20, instead of 1.21 😕 should we rather revert? Or create an exception for the kep ? 🤔

Hence my question, I initially thought it will get shipped with 1.21 (And completly forgot the /hold would get it merged immediatly, and with my messy commits..)

Also wondering how a provisional kep was implemented?
Hence kubernetes/enhancements#2134 but indeed it should have been updated to implementable before.

And I completly missed the ping on kubernetes/enhancements#1860 sorry!

I personally see no objection to create an exception for this feature, was waiting on Tim's opinion.

@thockin
Copy link
Member

thockin commented Nov 10, 2020

I don't mind creating an exception, but this is not trying to end-run around the rules. I lost track of which features were targetted for which release. I am sorry.

@kikisdeliveryservice No intention to bypass the process, apologies. There's just a lot of cross-checks and I moved too fast.

If you prefer to revert this, I don't object - we can re-propose it and sit on it (though in fact some of this wil make other PRs easier, so maybe we merge some internal parts and sit on the feature).

@kikisdeliveryservice
Copy link
Member

Thanks @thockin i've brought this to the attention of the Release Leads and we'll let you know shortly.

@jeremyrickard
Copy link
Contributor

Commented on the KEP issue for this, but figured I'd drop in here too 👋

I think at this point (we're SUPER close to code freeze..), we should revert this and not push for 1.20. There is a KEP PR in flight in k/enhancements that targets 1.21, I think it would be best if we targeted 1.21 for this feature. @thockin maybe doing a revert and landing the internal parts of it would be acceptable, but we're also 2 days away from code freeze so.....

I totally get that ya'll were not trying to bypass the process and things fall through the cracks...we're just kind of out of runway to get the KEP for this updated and start wrangling docs IMO.

@liggitt
Copy link
Member

liggitt commented Nov 11, 2020

The alpha e2e job started failing ingress tests as soon as this was merged, see https://testgrid.k8s.io/google-gce#gci-gce-alpha-enabled-default&width=20

@liggitt
Copy link
Member

liggitt commented Nov 11, 2020

This is the failure message:

"Ingress.extensions "e2e-example-inggr5wl" is invalid: status.loadBalancer.ingress[0].ipMode: Required value: must be specified when ip is set"

Which seems to indicate that this broke compatibility with a status update that previously worked


if utilfeature.DefaultFeatureGate.Enabled(features.LoadBalancerIPMode) {
if len(ingress.IP) > 0 && ingress.IPMode == nil {
allErrs = append(allErrs, field.Required(idxPath.Child("ipMode"), "must be specified when `ip` is set"))
Copy link
Member

Choose a reason for hiding this comment

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

this is what is failing in the alpha e2e job, so apparently this field is not consistently defaulted. if so, we cannot make it required.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, it was only defaulted on Service, completly missed the Ingress. Reverted in #96454 and I'll make sure to include ingress in the new one!

Sh4d1 added a commit to Sh4d1/kubernetes that referenced this pull request Nov 11, 2020
This reverts commit ef16faf, reversing
changes made to 2343b8a.
k8s-ci-robot added a commit that referenced this pull request Nov 13, 2020
Revert "Merge pull request #92312 from Sh4d1/kep_1860"
@wilsonehusin
Copy link
Contributor

@Sh4d1 hello! we'd like to remove this entry from 1.20 Release Notes since it was reverted. can you replace the release notes with NONE?

cc: @andrewsykim

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 24, 2020
@Sh4d1
Copy link
Member Author

Sh4d1 commented Nov 24, 2020

@wilsonehusin oops, yes! Done 😄

hidetatz pushed a commit to hidetatz/kubernetes that referenced this pull request Jan 12, 2021
This reverts commit ef16faf, reversing
changes made to 2343b8a.
u-bits pushed a commit to u-bits/kubernetes that referenced this pull request Jan 16, 2021
This reverts commit ef16faf, reversing
changes made to 2343b8a.
)
// jump to service firewall chain
writeLine(proxier.natRules, append(args, "-j", string(fwChain))...)
if !utilfeature.DefaultFeatureGate.Enabled(features.LoadBalancerIPMode) || *ingress.IPMode == v1.LoadBalancerIPModeVIP {
Copy link
Contributor

Choose a reason for hiding this comment

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

why we still need LB forward chain? Is there any rules can jump to LB forward chain if ingress IPMode is Proxy?

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. area/cloudprovider area/code-generation area/ipvs area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/network Categorizes an issue or PR as relevant to SIG Network. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet