This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
NetworkPolicy blocking traffic #3302
Closed
Description
Hi,
I'm having problems to apply following, quite simple NetworkPolicy:
---
# Block all ingress traffic by default
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: default-deny-ingress
namespace: kube-system
spec:
podSelector: {}
policyTypes:
- Ingress
---
# Allow pod-to-pod in same namespace
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: namespace-internal-ingress-allow
namespace: kube-system
spec:
podSelector: {}
ingress:
- from:
- namespaceSelector:
matchLabels:
name: kube-system
---
# Allow ingress traffic to coredns
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: coredns-ingress-allow
namespace: kube-system
spec:
podSelector:
matchLabels:
k8s-app: coredns
ingress:
# Allow access from any namespace and pod inside Kubernetes, not outside
- from:
- namespaceSelector: {}
- podSelector: {}
ports:
- protocol: UDP
port: 53
What you expected to happen?
Able to connect from any pod in any namespace to the coredns UDP 53.
What happened?
In some cases I was able to connect, and in some other cases not.
Tested nslookup google.com <ip of the coredns pod>
following:
- From same host: YES
- From pod in same host and in same namespace: YES
- From pod in same host and different namespace: NO (no logging about blocking)
- From different host: NO (blocked by NPC)
- From pod in different host and in same namespace: NO (blocked by NPC)
- From pod in different host and different namespace: NO (blocked by NPC)
When running from another node, I can see from the weave-npc
logs that it's blocking the access.
WARN: 2018/05/17 05:04:08.917079 UDP connection from 10.2.32.0:55996 to 10.2.96.1:53 blocked by Weave NPC.
But if in same host, but in pod which is in different namespace, wasn't able to connect and also did not get any blocked by Weave NPC
warning message.
If I remove all the above NetworkPolicies, all above test cases passes.
How to reproduce it?
- setup pretty basic Kubernetes cluster
- apply above rules for
kube-system
- exec in some other pod
nslookup google.com <ip of the coredns pod>
Versions:
$ weave version
2.2.1
$ docker -v
Docker version 17.12.1-ce, build 7390fc6
$ kubectl version
v1.9.5
Activity