背景:
Istio有一个安装选项meshConfig.outboundTrafficPolicy.mode,用于配置外部服务的sidecar处理,即那些未在Istio的内部服务注册表中定义的服务。如果此选项设置为ALLOW_ANY,则Istio代理允许对未知服务的调用通过。如果该选项设置为REGISTRY_ONLY,那么Istio代理将阻止没有在mesh中定义HTTP服务或服务条目的任何主机。ALLOW_ANY是默认值,无需控制对外部服务的访问。
实验
ALLOW_ANY情况下允许外部服务直接访问
REGISTRY_ONLY会down掉请求
此时需要创建serviceentry
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: httpbin-ext
spec:
hosts:
- httpbin.org
ports:
- number: 80
name: http
protocol: HTTP
resolution: DNS
location: MESH_EXTERNAL
再次访问服务正常