30 Commits

Author SHA1 Message Date
Aaron U'Ren
47fe189fe6 feat(lint): update golangci-lint and fix lint errors 2024-03-02 15:45:54 -06: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
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
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
Michal Rostecki
5d04a9fd97 netpol: Add dual-stack support
This change allows to define two cluster CIDRs for compatibility with
Kubernetes dual-stack, with an assumption that two CIDRs are usually
IPv4 and IPv6.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-10-07 08:52:31 -05:00
ChristianCiach
b08827918c Fix typo in filter rule comment 2021-12-01 09:22:47 -06:00
Aaron U'Ren
6a5a296105 feat(pod.go): add conntrack invalid state drop
fixes #709
2021-10-11 11:11:51 -05:00
Aaron U'Ren
419c078c60 feat(.golangci.yml): enable unparam linter and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
85f28411dc feat(.golangci.yml): enable long lines linter and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
874a746e30 feat(.golangci.yml): enable gosec and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
d6ccc22519 feat(.golangci.yml): enable goconst and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
bffdc729cc
fix(npc): ordering of firewall / service rules (#1144) 2021-08-10 03:59:17 +05:30
Murali Reddy
c8f7daf7ce fix lint errors 2021-06-28 12:45:43 -05:00
Murali Reddy
2c4dd7d584 addressing review comments 2021-06-28 12:45:43 -05:00
Murali Reddy
4c8cfc9c27 bug fix 2021-06-28 12:45:43 -05:00
Murali Reddy
93fe004ce6 bug fixes 2021-06-28 12:45:43 -05:00
Murali Reddy
3d407dc451 make rules to ACCPET related/established traffic as first entry in pod firewall chain 2021-06-28 12:45:43 -05:00
Murali Reddy
d684ec0c65 add logic to explicitly ACCEPT traffic from/to the pod if its
permitted by applicable network policies. If there are no network
policies then by default ACCEPT the pod traffic
2021-06-28 12:45:43 -05:00
Aaron U'Ren
d90c753286 fact(NPC): refactor isPodUpdateNetPolRelevant
Refactor this logic so that it can be more easily tested and expanded
without cluttering the pod.go file. Additionally, add some safe guards
around the pod cast to ensure that we're working with pods before we
pass them.
2021-06-01 10:42:42 -05:00
Aaron U'Ren
1a82db7500 fix(NPC): check if new pod is actionable
Previously, kube-router would do a full sync on a new pod whether or not
the pod was in an actionable state. This led to needless syncs as many
pods were missing PodIP addresses or other items necessary to apply
policy.

If a pod is missing these items it is better to wait for the next
message that comes via the UpdateFunc below so that we know that the pod
has all of the necessary items to apply policy to it.
2021-06-01 10:42:42 -05:00
Aaron U'Ren
3dc5c3fbcd fix(NPC): remove HostNetwork check from OnPodUpdate
With the previous logic, if a pod changed from having HostNetwork =
False to HostNetwork = True, NPC would not trigger a refresh to clear
out the rules that once applied. Now this check has been moved lower in
the fullPolicySync() logic so that it accounts for these pods naturally.
2021-06-01 10:42:42 -05:00
Aaron U'Ren
13e0a39800 fix(NPC): check if pod is actionable
Check if the Pod is actionable before taking NetworkPolicy actions which
includes both adding KUBE-POD-FW and KUBE-NWPLCY chains for it.

Checks have now been consolidated to a single isNetPolActionable()
function which checks for pod phases that we don't want NetworkPolicy
for like: Failed, Completed, and Succeeded, missing pod IP addresses,
and pods with HostNetwork enabled.

fixes #1056
2021-06-01 10:42:42 -05:00
Murali Reddy
2460189afd skip host network pods when selecting pods to apply ingress/egress netpol 2021-04-28 16:38:55 -05:00
Murali Reddy
52551279a8 skip hostnetwok pod's from enforcing network policies 2021-04-28 16:38:55 -05:00
Manuel Rüger
7d47aefe7d Replace github.com/golang/glog with k8s.io/klog/v2
glog is effectively unmaintained and the kubernetes ecosystem is mainly
using its fork klog

Fixes: #1051
2021-04-11 13:16:03 -05:00
Aaron U'Ren
1fb0820044
fix(npc): sync npc on pod label changes (#1046)
fixes #1035
2021-03-19 01:33:35 +05:30
Aaron U'Ren
fe515d1b52 fix(pod.go): ensure traffic at end of chain is only dropped once 2021-03-18 09:21:22 -05:00
Aaron U'Ren
95299a4cb5 fix(pod.go): comment quoting issues 2021-03-18 09:21:22 -05:00
Murali Reddy
888cac9193 use iptables-save and iptables-restore commands to consolidate
individual iptables command that are run during full network
policies sync
2021-03-18 09:21:22 -05:00
Murali Reddy
e16f2077dd
npc code restructuring (#1007) 2020-12-16 18:40:00 +05:30