-
Notifications
You must be signed in to change notification settings - Fork 304
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
Add support for L7-ILB (take 2) #789
Add support for L7-ILB (take 2) #789
Conversation
Hi @spencerhance. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
45048ab
to
bc5d8ee
Compare
/cc @freehan |
@spencerhance Can you squash commits so that it's easier to see which commits are from the parent PR? |
bc5d8ee
to
be2aca1
Compare
@rramkumar1 good call, should be good now |
pkg/controller/utils.go
Outdated
@@ -88,3 +88,15 @@ func nodePorts(svcPorts []utils.ServicePort) []int64 { | |||
} | |||
return ports | |||
} | |||
|
|||
func UpdateServicePortsForILB(ingSvcPorts []utils.ServicePort, ing *extensions.Ingress) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there is a better way to do this. You should probably fail at validation if there is service backend that does not have NEG enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I do need to also handle the default backend case
@@ -78,6 +78,7 @@ func (fr *FirewallRules) Sync(nodeNames, additionalPorts []string) error { | |||
sort.Strings(targetTags) | |||
|
|||
ports := sets.NewString(additionalPorts...) | |||
fr.srcRanges = append(fr.srcRanges, additionalRanges...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to have a separate firewall rule for ILB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a separate firewall rule, rather adding the ILB range to the firewall rule since that is a requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think I misunderstood your question. It's possible to add another rule but I'm not sure if that would make much of a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could make the features more error independent. For instance, you could get an error updating ILB ranges, but still successfully update NEG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good point, I'll look at adding this today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it will require non-trivial refactoring since we currently only support one firewall. It's still possible, but it might make more sense to just update the src ranges separately to catch two different errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like we need more unit tests?
b5c84d4
to
2872362
Compare
20b3584
to
3592c71
Compare
/hold cancel |
versions := []meta.Version{meta.VersionGA} | ||
keys := []*meta.Key{key1} | ||
versions := []meta.Version{meta.VersionGA, meta.VersionAlpha} | ||
keys := []*meta.Key{key1, key2} | ||
|
||
for i := range versions { | ||
list, err := ListBackendServices(gceCloud, keys[i], versions[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems quite strange to me that the list operation takes a key that it then only looks @ the scope for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, there's a TODO in pkg/composite/gen/main.go from when we last discussed it. I can update here or in another PR depending on your preference
pkg/loadbalancers/features/l7ilb.go
Outdated
return subnet.IpCidrRange, nil | ||
} | ||
} | ||
return "", fmt.Errorf("L7 ILB Subnet not found in region: %s", region) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do
var ErrSubnetNotFound = errors.New(""primary subnet not found")
9e4afb7
to
d5a2cbf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the remaining issues and we can merge this. There are a lot of TODOs, but should pick them up in follow on PRs.
pkg/annotations/ingress.go
Outdated
@@ -54,6 +54,7 @@ const ( | |||
IngressClassKey = "kubernetes.io/ingress.class" | |||
GceIngressClass = "gce" | |||
GceMultiIngressClass = "gce-multi-cluster" | |||
GceL7ILBIngressClass = "gce-l7-ilb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this "gce-ilb". L7 is already implicit in the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to "gce-internal," which I believe was the original name fwiw
pkg/backends/backends.go
Outdated
} | ||
|
||
if err != nil || len(hs.HealthStatus) == 0 || hs.HealthStatus[0] == nil { | ||
return "Unknown" | ||
return "Unknown", fmt.Errorf("error getting health for backend %s: %v", name, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for strings that come from input, use %q
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if flags.F.EnableL7Ilb { | ||
backends, err = composite.ListAllBackendServices(b.cloud) | ||
} else { | ||
backends, err = composite.ListBackendServices(b.cloud, meta.GlobalKey(""), meta.VersionGA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO that this needs to be changed to not take a key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/composite/utils.go
Outdated
func ListAllUrlMaps(gceCloud *gce.Cloud) ([]*UrlMap, error) { | ||
resultMap := map[string]*UrlMap{} | ||
key1, err := CreateKey(gceCloud, "", meta.Global) | ||
if err != nil { | ||
return nil, err | ||
} | ||
key2, err := CreateKey(gceCloud, "", meta.Regional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO(shance): this all needs to be replaced with `scope` and not key.
globalKey, err := CreateKey(gceCloud, "", meta.Global)
if err != nil {
return nil, err
}
regionalKey, err := ...
for _, vk := range []struct {
v meta.Version
k meta.Key // TODO: change this to scope
} {
{meta.VersionGA, GlobalKey},
{meta.VersionAlpha, RegionalKey},
} {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/firewalls/controller.go
Outdated
@@ -163,9 +170,13 @@ func (fwc *FirewallController) sync(key string) error { | |||
return err | |||
} | |||
negPorts := fwc.translator.GatherEndpointPorts(gceSvcPorts) | |||
additionalRanges, err := fwc.ilbFirewallSrcRanges(gceIngresses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag gate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/firewalls/controller.go
Outdated
@@ -123,7 +126,11 @@ func (fwc *FirewallController) ToSvcPorts(ings []*extensions.Ingress) []utils.Se | |||
var knownPorts []utils.ServicePort | |||
for _, ing := range ings { | |||
urlMap, _ := fwc.translator.TranslateIngress(ing, fwc.ctx.DefaultBackendSvcPortID) | |||
knownPorts = append(knownPorts, urlMap.AllServicePorts()...) | |||
svcPorts := urlMap.AllServicePorts() | |||
if utils.IsGCEL7ILBIngress(ing) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be if enableILBL7 && utils.IsGCEL7Ingress(ing)
so it's completely disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/firewalls/controller.go
Outdated
for _, ing := range gceIngresses { | ||
if utils.IsGCEL7ILBIngress(ing) { | ||
ilbEnabled = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/firewalls/controller.go
Outdated
func (fwc *FirewallController) ilbFirewallSrcRanges(gceIngresses []*extensions.Ingress) ([]string, error) { | ||
var additionalRanges []string | ||
ilbEnabled := false | ||
if flags.F.EnableL7Ilb { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like hiding the enablement inside the function. Then when we unit test this, it has different behavior based on a global variable flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/firewalls/controller.go
Outdated
if err != nil { | ||
return nil, fmt.Errorf("error unable to get ILB subnet source ranges: %v", err) | ||
} | ||
additionalRanges = append(additionalRanges, L7ILBSrcRange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to append if we are not in a loop
return L7ILBSrcRange, nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -46,10 +48,37 @@ var ( | |||
meta.Zonal: {fakeZonalFeature}, | |||
} | |||
|
|||
fakeVersionToFeatures = map[meta.Version][]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reduce verbosity here:
makeEntry := func(ga, alpha, beta meta.Version) {
return &map[meta.Version]{ meta.VersionGA: {ga}, meta.VersionAlpha:{alpha}, meta.VersionBeta:{beta} }
}
...
UrlMap: ...,
ForwardingRule: makeEntry(fakeGaFeature, fakeAlphaFeature, fakeBetaFeature),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
d5a2cbf
to
9831d0b
Compare
afae10b
to
2de3d93
Compare
@@ -94,6 +94,7 @@ func (l *instanceGroupLinker) Link(sp utils.ServicePort, groups []GroupKey) erro | |||
} | |||
|
|||
// ig_linker only supports L7 HTTP(s) External Load Balancer | |||
// Hardcoded here since IGs are not supported for non GA-Global right now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add a TODO here so we can find this later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Intiial support for L7-ILB and corresponding ingress class "gce-internal." Functionality is flag-gated with "--enable-l7-ilb".
2de3d93
to
596af29
Compare
ForNEG bool | ||
// ForILB designates whether the health check is for an ILB | ||
// This means that the HC should be alpha + regional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to remove the comment?
desc: "foo ingress class", | ||
ingress: &v1beta1.Ingress{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Annotations: map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either do
{ ... }
or
&blah{\n
...\n
},\n
don't do
&blah{\n
...},
/lgtm there are a ton of TODOs, but let's merge this for now and handle things in addons. The github UI is not handling PRs of this size very easily. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, spencerhance 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 |
Is there a way to get this working on Google Kubernetes Engine? I added the annotation Do I have to manually deploy ingress-gce to the cluster, and disable the built-in version? |
For anyone trying to get this working on Google Kubernetes Engine, you need to:
|
@hach-que I'm glad you were able to to get it working! As you figured out, the feature hasn't been released to GKE yet but can be used if you deploy the controller yourself. As for step 3, you can actually avoid enabling CSM by adding the enable NEG annotation to your k8s service. Here is an example service yaml: apiVersion: v1
kind: Service
metadata:
name: internal-lb-svc
namespace: default
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
ports:
- name: host1
port: 80
protocol: TCP
targetPort: 9376
selector:
run: internal-lb-app
type: ClusterIP Also feel free to file issues if you notice any bugs 😃 |
This PR supersedes #773
Adds support for the L7 Internal Load Balancer to the controller. A follow up PR with e2e tests will be added.
In the interest of time, I've added the L7-ILB work on top of #788 so that it can be reviewed in tandem. Unless you foresee gigantic changes in that PR, I would review this as well so it can be merged shortly after. The first commit on this PR is from that branch.
Currently, the feature is flag-gated with the '--enable-l7-ilb' flag. Enabling the flag will require resolving #767