1039 Commits

Author SHA1 Message Date
Kartik Raval
2a57d6c163 Adding FoU encapsulation over IPIP tunnel : added checks for restart and multi-node cases 2023-10-07 08:52:31 -05:00
Kartik Raval
6ce37e6167 Support for FoU encapsulation for IPIP tunnel 2023-10-07 08:52:31 -05:00
Aaron U'Ren
4861021797 fix(NPC): update IPBlocks to be ipFamily specific
Previously, IPBlocks (like srcIPBlocks) only contained a single IP
Family which meant that a len() > 0 would indicate that an IP block had
been defined in the NetworkPolicy. However, now the IPBlocks structs are
IP family specific which means that they will always contain 2 entries,
one for the IPv4 family and one of the IPv6 family. Which means that
this condition will evaluate to true for all NetworkPolicies and waste
system resources creating empty ipsets and bad iptables rules.
2023-10-07 08:52:31 -05:00
Boleyn Su
f0d7f1e17a netpol: Fix ipset only containing one IP when port name is used. 2023-10-07 08:52:31 -05:00
Aaron U'Ren
384ed97a76 fix(bgp_policy): allow for statement add / remove
The previous version of the bgp_policies code only allowed for creating
a policy when the policy didn't exist already. However, with the advent
of dual-stack we need to be able to add / remove statements if we add or
lose a specific IP family (e.g. IPv4 or IPv6) since they are handled in
different statements.

Given that the owner of GoBGP has let us know that policies are
idempotent, this now involves quite a bit of work. We need to follow the
following procedure:

add statements if missing -> add them to a policy -> if policy doesn't
  equal the one already in GoBGP -> create the new policy and associate
  it -> de-associate the old policy -> remove the old policy
2023-10-07 08:52:31 -05:00
Aaron U'Ren
1d5c9ce25c fix(ecmp_vip): update VIPs based on svc change
Previously we used to do an idempotent sync all active VIPs any time we
got a service or endpoint update. However, this only worked when we
assumed a single-stack deployment model where IPs were never deleted
unless the whole service was deleted.

In a dual-stack model, we can add / remove LoadBalancer IPs and Cluster
IPs on updates. Given this, we need to take into account the finite
change that happens, and not just revert to sync-all because we'll never
stop advertising IPs that should be removed.

As a fall-back, we still have the outer Run loop that syncs all active
routes every X amount of seconds (configured by user CLI parameter). So
on that timer we'll still have something that syncs all active VIPs and
works as an outer control loop to ensure that desired state eventually
becomes active state if we accidentally remove a VIP that should have
been there.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
f5ac980b23 fix(bgp_policies.go): return -> continue on family set evaluation
When a single IP family's set looks to be equal, switch to continue
instead of return so that other families can still be evaluated as those
might have changes.
2023-10-07 08:52:31 -05:00
Erik Larsson
3387f5c1c6 use JoinHostPort for GRPC listen address
Signed-off-by: Erik Larsson <who+github@cnackers.org>
2023-10-07 08:52:31 -05:00
Erik Larsson
76ffcbdb13 add generation of router id based on hash of primary IP
When enabled, generate the router id by hashing the primary IP.
With this no explicit router id has to be provided on IPv6-only clusters.

Signed-off-by: Erik Larsson <who+github@cnackers.org>
2023-10-07 08:52:31 -05:00
Aaron U'Ren
57c9b08643 fix(ecmp_vip.go): ClusterIP -> ClusterIPs
Use ClusterIPs rather than ClusterIP so that we get all of the possible
IP addresses rather than just one.

Fixes #1443
2023-10-07 08:52:31 -05:00
Aaron U'Ren
fe939782c6 feat(bgp_policies_test.go): use different IP ranges
Use different IP ranges in BGP Policies unit test so that it becomes
more obvious when there are unit test failures resulting from
multi-processing of unit tests.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
31c22ff634 fix(bgp_policies.go): don't get BGP peers twice
Fixes a problem where a user would end up with redundant external peers
in their BGP policies because getting peers is IP family agnostic and
yet is run twice on the same list.

This also ruined unit test consistency.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
06f5f8babf feat(go): update package version to /v2
Do the necessary to update kube-router to a new major version following
upstream documentation: https://go.dev/doc/modules/major-version
2023-10-07 08:52:31 -05:00
Aaron U'Ren
e51ee3ae71 fix(NPC): add warning for unsupported family
Rather than just silently not adding policies for controllers that don't
support a given address family, emit a warning so that it is more
obvious in the logs that kube-router isn't able to add a policy for a
given family when the controller doesn't have that family enabled.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
4e1679f03b fix(NPC): don't add chains for missing family
On dual-stack nodes there can still be pods that are single stack. When
this happens there won't be a pod IP for a given family and if
kube-router tries to add rules with a missing pod IP the iptables rules
won't be formatted correctly (because it won't have a valid source or
destination for that family).

So rather than breaking the whole iptables-restore we warn in the logs
and skip the pod policy chains for that family.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
a2bb2ba880 doc(bgp.md): clean up grammar and syntax 2023-10-07 08:52:31 -05:00
Aaron U'Ren
0ecb51de3e fix(NPC/pod): check drop policy on ipv4 & ipv6
Change return to continue so that both IPv4 and IPv6 are checked for
drop policy not just the first one.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
367aedf846 fix(bgp_policies): add empty DS set checking
Without this logic, it appears that sometimes GoBGP is inclined to match
unintentional routes in policy because of the MATCHSET_ANY declaration
and the way that it interacts with empty sets.

In my testing, without this logic I found that it often resulted in
various routes not being advertised correctly and not even showing up in
GoBGP itself. My current guess is that policy keeps GoBGP from importing
the route into the RIB even from the Protobuf socket connection that
kube-router establishes directly.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
aeb51ba697 fact(bgp_policies): rename clusterIPPrefixSet -> serviceVIPIPPrefixSet 2023-10-07 08:52:31 -05:00
Aaron U'Ren
6e03836081 fact(bgp_policies): abstract get DS for GoBGP
We do a lot of getting defined sets for GoBGP and are planning to do
more of it in the future. This commit centralizes the logic for this and
reduces repetition.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
67254ad22d fix(ecmp_vip): handle ipv4 & ipv6 protocols 2023-10-07 08:52:31 -05:00
Aaron U'Ren
5f952e0f28 test(bgp_policies_test): add local address 2023-10-07 08:52:31 -05:00
Aaron U'Ren
ec12fda820 fix(node): do nil checking on FindBestIP util funcs 2023-10-07 08:52:31 -05:00
Aaron U'Ren
5d7f62c5b3 fix(NRC): ensure local addr IP is bindable early 2023-10-07 08:52:31 -05:00
Aaron U'Ren
67abc4b80e fix(bgp_peers): adv. AfiSafi based on capabability
Advertise IPv4 / IPv6 AfiSafi capability based upon node's capabilities
rather than limiting to the node's configured protocol.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
c491bcb48d fix(bgp_peers): do peer only if IP protos match
For configured BGP peers only attempt peering if IP protos match,
otherwise skip and log warning
2023-10-07 08:52:31 -05:00
Aaron U'Ren
0023dedc4d fix(NRC): error when nec. host IP not found
If we can't find an appropriate IP to add for nextHop to injectRoute or
overlay tunnel, raise error rather than trying to continue.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
4f284be53e fix(NRC): add IPv6 logic to bgp-local-addresses 2023-10-07 08:52:31 -05:00
Aaron U'Ren
51f4696417 feat(ci): run CI on version prep branches and MRs 2023-10-07 08:52:31 -05:00
Aaron U'Ren
b3e0768281 fix(options): make clusterIP specification similar to other options 2023-10-07 08:52:31 -05:00
Aaron U'Ren
a31511d987 fix(NPC): actually separate chain indices for ipv4 / ipv6 2023-10-07 08:52:31 -05:00
Aaron U'Ren
096da81f92 fact(NPC): pluralize newIPTablesHandler 2023-10-07 08:52:31 -05:00
Aaron U'Ren
ddb0e63c46 feat(NRC): make NRC dual stack 2023-10-07 08:52:31 -05:00
Aaron U'Ren
01f2ff2aa1 fact(NRC): convert BGP set names to const
Convert all BGP set names to constants and then refer to them via the
constant across the code base so that we reduce the effect of typos.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
85cecb6e61 feat(pod_cidr): handle multiple pod CIDRs 2023-10-07 08:52:31 -05:00
Aaron U'Ren
c18d811f4f fix(kube-router.go): metric message -> not error
Running kube-router without metrics is a perfectly valid way to run
kube-router and as such it shouldn't emit an error message when a user
has not set that flag. Move the message down to Info.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
3db482be3b fix(NPC): separate chain indices for ipv4 / ipv6
Without this, kube-router would end up sharing the index between ipv4
and ipv6 which would cause it to error out when one incremented beyond
the number of rules that actually existed in the chain.
2023-10-07 08:52:31 -05:00
Aaron U'Ren
9d2b3c72ea fix(node.go): make node address errors more helpful 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
d7e2a146f3 fix golangci issues 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
12561f9faa fix test compilation error 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
e5f272e972 go mod 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
76e5d20c5a use createGenericHashIPSet 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
b3dcaa0878 rename utilsnet import to netutils 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
4256a60705 syncPodFirewallChains: loop on all NodeIp
to find the pods running on a given Node
- Load PodIp in podInfo struct and use it instead of pod.ips[0].IP
2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
92e91df9d2 refactor whitelisting of cluster IP Range 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
6fea9c2d19 Validate that ClusterIP service range type matches the configuration
and update documentation
2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
16d3cd1867 godoc update 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
d1f3839bc6 remove redundant default value 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
d6dcf76759 rename Adresses 2023-10-07 08:52:31 -05:00
Thomas Ferrandiz
26d06c40aa Turn IPTablesSaveRestore into an interface 2023-10-07 08:52:31 -05:00