NetworkPolicy not applying #7632
Unanswered
JonathanWilbur
asked this question in
Q&A
Replies: 1 comment
-
I'm 90% sure that the bullet point you quoted is the answer. In particular, limiting traffic from the resident node is problematic because the k8s ready/live/startup probes are coming from Service meshes that do mTLS need to work around that, for example see: linkerd/linkerd2#7050 It's easier to handle when you can do authz at the L7, because then you can allow the external traffic only to the probe endpoints. With NetworkPolicies you can only work at L3/L4, so it would only make sense for containers that expose probes on dedicated ports. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Environmental Info:
K3s Version:
Node(s) CPU architecture, OS, and Version:
Cluster Configuration:
Single node: my Xubuntu workstation. Modern, powerful hardware. Normal x86-64 processor.
Describe the bug:
If I create a NetworkPolicy that blocks the CNI IP (representing external traffic that is inbound into the cluster), nothing is blocked. Specifically, my testing works by reading the logs of an Nginx server and manually blocking the specific IP address recorded in the logs like so:
Here is my CNI interface:
And for thoroughness, here is my service:
I have tested this technique on Azure Kubernetes Service (AKS) and it works there, but the big difference is that AKS just uses your real IP address, not a CNI bridge. I think I also tested this on Minikube, but I am not sure.
This might not be a bug. Maybe I'm not supposed to be able to block this IP, since it does seem to represent all traffic from the outside world. Is it even possible to do this in K3s? Again, it seems to work in Azure AKS.
Steps To Reproduce:
except
IP address with the IP of your CNI interface.Additional testing
externalTrafficPolicy: Local
toexternalTrafficPolicy: Cluster
(the default). (I originally changed it to the former, because the former preserves external IP addresses, but oddly, that does not seem to matter in K3s. Everything still shows up as10.42.0.1
for me.)Expected behavior:
I kind of expect to be blocked from accessing the Nginx service. However, I could reasonably see this exclusion being governed by this bullet point:
So, again, I'm not sure this is a bug or not. I'd just like clarification.
Actual behavior:
I can still make requests that reach the Nginx server.
Additional context / logs:
Nginx logs sample:
Beta Was this translation helpful? Give feedback.
All reactions