我试图了解当outboundTrafficPolicy
模式设置为 REGISTRY_ONLY 时 Istio envoy 代理如何工作。通过下面定义的设置,我预计inside
Pod 将被阻止访问outside
Pod,因为sidecar.istio.inject
标签设置"false"
为外部 Pod 和"true"
内部 Pod。但是,当我执行到inside
pod 并发出curl 命令时,我获得了成功。
kubectl -n istio-test exec -it inside-85f794ff76-7x44s -c sleep -- curl http://outside
<html><body><h1>It works!</h1></body></html>
配置设置
---
apiVersion: v1
kind: Service
metadata:
labels:
app: outside
name: outside
namespace: istio-test
spec:
ports:
- name: 80-80
port: 80
protocol: TCP
targetPort: 80
selector:
app: outside
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
labels:
app: inside
name: inside
namespace: istio-test
spec:
ports:
- name: 80-80
port: 80
protocol: TCP
targetPort: 80
selector:
app: inside
clusterIP: None
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: outside
name: outside
namespace: istio-test
spec:
replicas: 1
selector:
matchLabels:
app: outside
template:
metadata:
labels:
app: outside
version: v1
sidecar.istio.io/inject: "false"
spec:
containers:
- image: httpd
name: httpd
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: inside
name: inside
namespace: istio-test
spec:
replicas: 1
selector:
matchLabels:
app: inside
template:
metadata:
labels:
app: inside
version: v1
sidecar.istio.io/inject: "true"
spec:
containers:
- image: curlimages/curl
name: sleep
command:
- /bin/sleep
- infinity
---
apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: default
namespace: istio-test
spec:
workloadSelector:
labels:
app: inside
outboundTrafficPolicy:
mode: REGISTRY_ONLY
我期望需要一个ServiceEntry
来注册外部 Pod。为什么情况似乎并非如此?
如何阻止从inside
pod 到outside
pod 的流量?