-
Notifications
You must be signed in to change notification settings - Fork 301
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
Firewall Sync: Allow entire nodeport range #122
Conversation
pkg/controller/cluster_manager.go
Outdated
@@ -131,7 +131,7 @@ func (c *ClusterManager) Checkpoint(lbs []*loadbalancers.L7RuntimeInfo, nodeName | |||
return igs, err | |||
} | |||
|
|||
if err := c.firewallPool.Sync(firewallPorts, nodeNames); err != nil { | |||
if err := c.firewallPool.Sync(nodeNames); err != 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.
Should we keep the existing behavior but as optional if the range is not set?
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.
Actually on second thought, let's remove the old code -- it's a lot more complex.
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.
On second thought, we'll need to pass in the list of ports used for NEG and merge them with the node port range.
pkg/firewalls/firewalls.go
Outdated
for _, aAllow := range allowListA { | ||
matchSet.Insert(firewallAllowedToString(aAllow)) | ||
} | ||
|
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.
why not use sets for both and call the set Equal?
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.
Oops
pkg/firewalls/firewalls.go
Outdated
|
||
func firewallAllowedToString(allowed *compute.FirewallAllowed) string { | ||
sort.Sort(sort.StringSlice(allowed.Ports)) | ||
return strings.ToUpper(allowed.IPProtocol) + strings.Join(allowed.Ports, ",") |
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 colon in the middle so if someone logs the result it looks ok to a human
return strings.ToUpper(allowed.IPProtocol) + ":" + strings.Join(allowed.Ports, ",")
pkg/controller/cluster_manager.go
Outdated
@@ -226,6 +227,6 @@ func NewClusterManager( | |||
|
|||
// L7 pool creates targetHTTPProxy, ForwardingRules, UrlMaps, StaticIPs. | |||
cluster.l7Pool = loadbalancers.NewLoadBalancerPool(cloud, defaultBackendPool, defaultBackendNodePort, cluster.ClusterNamer) | |||
cluster.firewallPool = firewalls.NewFirewallPool(cloud, cluster.ClusterNamer) | |||
cluster.firewallPool = firewalls.NewFirewallPool(cloud, cluster.ClusterNamer, gce.LoadBalancerSrcRanges(), nodePortRanges) |
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 just access these as a global -- it is more like a constant than a parameter.
pkg/firewalls/fakes.go
Outdated
func copyFirewall(f *compute.Firewall) *compute.Firewall { | ||
enc, err := f.MarshalJSON() | ||
if err != nil { | ||
panic(fmt.Sprintf("Failed to encode to json: %v", 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.
return error instead of panic.
pkg/firewalls/firewalls.go
Outdated
@@ -190,3 +160,35 @@ type FirewallSyncError struct { | |||
func (f *FirewallSyncError) Error() string { | |||
return f.Message | |||
} | |||
|
|||
func firewallsEqual(expected *compute.Firewall, existing *compute.Firewall) bool { |
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.
can just call this equal (firewalls.equal)
pkg/firewalls/firewalls.go
Outdated
return true | ||
} | ||
|
||
func firewallAllowedToString(allowed []*compute.FirewallAllowed) []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.
same, firewall prefix is not needed
pkg/flags/flags.go
Outdated
@@ -92,11 +103,41 @@ the pod secrets for creating a Kubernetes client.`) | |||
`Print the version of the controller and exit`) | |||
flag.StringVar(&F.IngressClass, "ingress-class", "", | |||
`If set, overrides what ingress classes are managed by the controller.`) | |||
flag.Var(&F.NodePortRanges, "node-port-ranges", `Node port/port-ranges whitelisted for the | |||
L7 load balancing`) |
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.
might want to document the with an example
pkg/firewalls/fakes.go
Outdated
ff.fw[f.Name] = f | ||
cf, err := copyFirewall(f) | ||
if err != nil { | ||
return fmt.Errorf("Failed to copy firewall: %v", 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.
why not propagate err directly?
pkg/firewalls/fakes.go
Outdated
ff.fw[f.Name] = f | ||
cf, err := copyFirewall(f) | ||
if err != nil { | ||
return fmt.Errorf("Failed to copy firewall: %v", 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.
same here
24b9c63
to
93f9a0a
Compare
84c306e
to
b43352e
Compare
I believe we have three options to handle NEG endpoints.
|
I need to update the static-ip E2E test. |
Changes
gce.LoadBalancerSourceRanges()
static func for specifying the GCE source ranges. This is definable via flag.