15 Commits

Author SHA1 Message Date
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