设置:
gke: 1.13.7-gke.8
istio: 1.1.7-gke.0 with ingress and egress gateways
Istio mTLS: Strict
我有2个名称空间:
我所拥有的:
development
kubernetes.default.svc.cluster.local
没有政策,我可以访问kubernetes.default.svc.cluster.local
/app # curl -I kubernetes.default.svc.cluster.local:443
curl: (8) Weird server reply
/app # curl -I example.com
HTTP/1.1 200 OK
Default
标签为default-namespace=true
的命名空间
我的政策
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: egress-policy
namespace: development
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kube-system: 'true'
ports:
- protocol: UDP
port: 53
- to:
- namespaceSelector:
matchLabels:
istio: system
- to:
- namespaceSelector:
matchLabels:
environment: development
- to:
- namespaceSelector:
matchLabels:
default-namespace: 'true'
应用此政策后:
/app # curl -I kubernetes.default.svc.cluster.local:443
curl: (56) Recv failure: Connection reset by peer
/app # curl -I example.com
HTTP/1.1 200 OK
可以访问default
命名空间中的其他服务。
如何通过istio出口和限制性出口网络策略使kubernetes.default.svc.cluster.local工作?
已添加
:kubectl get ns --show-labels
NAME STATUS AGE LABELS
default Active 42d default-namespace=true,istio-injection=enabled
development Active 2d2h environment=development,istio-injection=enabled
istio-system Active 2d2h addonmanager.kubernetes.io/mode=Reconcile,istio-injection=disabled,istio=system,k8s-app=istio
kube-public Active 42d <none>
kube-system Active 42d kube-system=true
将Istio mTLS (beta)
设置为Permissive
并没有帮助