kubernetes网络政策 - 出口政策不阻止流量到外面

问题描述 投票:3回答:1

this is my network policy:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny
  namespace: openstack
spec:
  podSelector:
    matchLabels: {} 
  policyTypes:
  - Egress
  - Ingress

我应用此政策并登录到1个广告连播,它仍然可以连接到google.com。

-

-2018-08-29 11:36:33--  http://google.com/
Resolving google.com (google.com)... 172.217.4.46, 2607:f8b0:4009:804::200e
Connecting to google.com (google.com)|172.217.4.46|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.com/ [following]
--2018-08-29 11:36:33--  http://www.google.com/
Resolving www.google.com (www.google.com)... 172.217.4.36, 2607:f8b0:4009:804::2004
Connecting to www.google.com (www.google.com)|172.217.4.36|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.85’

index.html.85                                      [ <=>                                                                                              ]  11.09K  --.-KB/s    in 0.001s  

2018-08-29 11:36:33 (7.77 MB/s) - ‘index.html.85’ saved [11355]

有谁能解释为什么出口不起作用?谢谢

kubernetes kubernetes-networkpolicy
1个回答
1
投票

在使用NetworkPolicy之前,您需要安装支持网络策略的CNI插件。

我使用Weave Net,但你可以使用其他一些:

https://kubernetes.io/docs/tasks/administer-cluster/network-policy-provider/weave-network-policy/

https://kubernetes.io/docs/tasks/administer-cluster/declare-network-policy/

© www.soinside.com 2019 - 2024. All rights reserved.