I have a Kubernetes cluster running behind a NAT. Now I want to forbid the pods to communicate with the network in which my Kubernetes nodes / servers are. The network has the CIRD: 10.12.12.0/27
.
I've already tried the Kubernetes NetworkPolicy, but I haven't figured out how to prohibit communication with certain IPs. Instead, I have limited the Konnunikation to these IP's. Here is my previous NetworkPolicy:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: block-net-kubernetes
namespace: default
spec:
podSelector:
matchLabels:
namespace: default
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 10.12.12.0/27
Many thanks in advance! Kind regards Niclas
2条答案
按热度按时间uqxowvwt1#
您可以使用
expect
块来过滤掉一些IP。7y4bm7vi2#
感谢P...!它工作了!但是有一个小小的格式错误:
except:
语句需要再缩进一次,如下所示: