mirror of https://github.com/istio/istio.io.git
159 lines
76 KiB
HTML
159 lines
76 KiB
HTML
<!doctype html><html lang=zh itemscope itemtype=https://schema.org/WebPage><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=theme-color content=#466BB0><meta name=title content="控制 Egress 流量"><meta name=description content="在 Istio 中配置从网格内访问外部服务的流量路由。"><meta name=keywords content=microservices,services,mesh,traffic-management,egress><meta property=og:title content="控制 Egress 流量"><meta property=og:type content=website><meta property=og:description content="在 Istio 中配置从网格内访问外部服务的流量路由。"><meta property=og:url content=/v1.1/zh/docs/tasks/traffic-management/egress/><meta property=og:image content=/v1.1/img/istio-whitelogo-bluebackground-framed.svg><meta property=og:image:alt content="Istio Logo"><meta property=og:image:width content=112><meta property=og:image:height content=150><meta property=og:site_name content=Istio><meta name=twitter:card content=summary><meta name=twitter:site content=@IstioMesh><title>Istioldie 1.1 / 控制 Egress 流量</title><script async src="https://www.googletagmanager.com/gtag/js?id=UA-98480406-2"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}
|
||
gtag('js',new Date());gtag('config','UA-98480406-2');</script><link rel=alternate type=application/rss+xml title="Istio Blog" href=/v1.1/feed.xml><link rel="shortcut icon" href=/v1.1/favicons/favicon.ico><link rel=apple-touch-icon href=/v1.1/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/v1.1/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/v1.1/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/v1.1/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/v1.1/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/v1.1/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/v1.1/favicons/android-96x96.png sizes=96xW96><link rel=icon type=image/png href=/v1.1/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/v1.1/favicons/android-192x192.png sizes=192x192><link rel=manifest href=/v1.1/manifest.json><meta name=apple-mobile-web-app-title content=Istio><meta name=application-name content=Istio><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Work+Sans:400|Chivo:400|Work+Sans:500,300,600,300italic,400italic,500italic,600italic|Chivo:500,300,600,300italic,400italic,500italic,600italic"><link rel=stylesheet href=/v1.1/css/all.css></head><body class="language-unknown archive-site"><script src=/v1.1/js/themes_init.min.js></script><script>const branchName="release-1.1";const docTitle="控制 Egress 流量";const iconFile="\/v1.1/img/icons.svg";const buttonCopy='复制到剪切板';const buttonPrint='打印';const buttonDownload='下载';</script><script src="https://www.google.com/cse/brand?form=search-form" defer></script><script src=/v1.1/js/all.min.js data-manual defer></script><header><nav><a id=brand href=/v1.1/zh/><span class=logo><svg viewBox="0 0 300 300"><circle cx="150" cy="150" r="146" stroke-width="2" /><path d="M65 240H225L125 270z"/><path d="M65 230l60-10V110z"/><path d="M135 220l90 10L135 30z"/></svg></span><span class=name>Istioldie 1.1</span></a><div id=hamburger><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#hamburger"/></svg></div><div id=header-links><span title="了解如何部署、使用和运维 Istio。">文档</span>
|
||
<a title="关于使用 Istio 的博客文章。" href=/v1.1/zh/blog/2019/root-transition/>博客</a>
|
||
<a title="一堆帮助您部署、配置和使用 Istio 的资源。" href=/v1.1/zh/help/>帮助</a>
|
||
<a title=关于Istio的说明。 href=/v1.1/zh/about/>关于</a><div class=menu><button id=gearDropdownButton class=menu-trigger title=选项和设置 aria-label="Options and Settings" aria-controls=gearDropdownContent><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#gear"/></svg></button><div id=gearDropdownContent class=menu-content aria-labelledby=gearDropdownButton role=menu><a tabindex=-1 role=menuitem lang=en id=switch-lang-en>English</a>
|
||
<a tabindex=-1 role=menuitem lang=zh id=switch-lang-zh class=active>中文</a><div role=separator></div><a tabindex=-1 role=menuitem class=active id=light-theme-item>亮主题</a>
|
||
<a tabindex=-1 role=menuitem id=dark-theme-item>暗主题</a><div role=separator></div><a tabindex=-1 role=menuitem id=syntax-coloring-item>代码高亮</a><div role=separator></div><h6>本站的其它版本</h6><a tabindex=-1 role=menuitem onclick="navigateToUrlOrRoot('https://istio.io/docs\/tasks\/traffic-management\/egress\/');return false;">当前版本</a>
|
||
<a tabindex=-1 role=menuitem onclick="navigateToUrlOrRoot('https://preliminary.istio.io/docs\/tasks\/traffic-management\/egress\/');return false;">下个版本</a>
|
||
<a tabindex=-1 role=menuitem href=https://archive.istio.io>旧版本</a></div></div><button id=search-show title=搜索istio.io aria-label=Search><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#magnifier"/></svg></button></div><form id=search-form name=cse role=search><input type=hidden name=cx value=013699703217164175118:iwwf17ikgf4>
|
||
<input type=hidden name=ie value=utf-8>
|
||
<input type=hidden name=hl value=en>
|
||
<input type=hidden id=search-page-url value=/v1.1/search.html>
|
||
<input id=search-textbox class=form-control name=q type=search aria-label=搜索istio.io>
|
||
<button id=search-close title="Cancel search" type=reset aria-label="Cancel search"><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#cancel-x"/></svg></button></form></nav></header><main class=primary><div id=sidebar-container class="sidebar-container sidebar-offcanvas"><nav id=sidebar aria-label="Section Navigation"><div class=directory><div class=card><button class="header dynamic" id=card28 title="一些概念,理解它们有助于您更好地了解 Istio 系统的不同部分及其使用的抽象。" aria-controls=card28-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#concepts"/></svg>概念</button><div class=body aria-labelledby=card28 role=region id=card28-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card28><li role=none><a role=treeitem title="介绍 Istio 及其要解决的问题、顶层架构和设计目标。" href=/v1.1/zh/docs/concepts/what-is-istio/>Istio 是什么?</a></li><li role=none><a role=treeitem title="介绍 Istio 中关于流量路由与控制的各项功能。" href=/v1.1/zh/docs/concepts/traffic-management/>流量管理</a></li><li role=none><a role=treeitem title="描述 Istio 的授权与鉴权功能。" href=/v1.1/zh/docs/concepts/security/>安全</a></li><li role=none><a role=treeitem title=描述策略实施和遥测机制。 href=/v1.1/zh/docs/concepts/policies-and-telemetry/>策略与遥测</a></li><li role=none><a role=treeitem title="介绍 Istio 组件的性能与可伸缩性。" href=/v1.1/zh/docs/concepts/performance-and-scalability/>性能与可伸缩性</a></li><li role=none><a role=treeitem title=描述如何配置服务网格以包含来自多个集群的服务。 href=/v1.1/zh/docs/concepts/multicluster-deployments/>多集群部署</a></li></ul></div></div><div class=card><button class="header dynamic" id=card41 title="在不同的环境下(例如 Kubernetes、Consul 等)如何部署和升级 Istio。" aria-controls=card41-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#setup"/></svg>安装</button><div class=body aria-labelledby=card41 role=region id=card41-body><ul role=tree aria-expanded=true aria-labelledby=card41><li role=treeitem aria-label=Kubernetes><button aria-hidden=true></button><a title="关于如何在 Kubernetes 集群中安装 Istio 控制平面和添加虚拟机到 mesh 中的说明。" href=/v1.1/zh/docs/setup/kubernetes/>Kubernetes</a><ul role=group aria-expanded=false><li role=none><a role=treeitem title="关于 Istio 发布包下载过程的说明。" href=/v1.1/zh/docs/setup/kubernetes/download/>下载 Istio 发布包</a></li><li role=treeitem aria-label=准备><button aria-hidden=true></button><a title="为 Istio 做准备。" href=/v1.1/zh/docs/setup/kubernetes/prepare/>准备</a><ul role=group aria-expanded=false><li role=treeitem aria-label=平台搭建><button aria-hidden=true></button><a title="在安装 Istio 前,如何准备各种 Kubernetes 平台。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/>平台搭建</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="为 Istio 设置阿里云 Kubernetes 集群的说明。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/alicloud/>阿里云</a></li><li role=none><a role=treeitem title="对 Azure 集群进行配置以便安装运行 Istio。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/azure/>Azure</a></li><li role=none><a role=treeitem title="使用桌面版 Docker 安装 Istio 的说明。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/docker/>桌面版 Docker</a></li><li role=none><a role=treeitem title="对 Google Kubernetes Engine(GKE)集群进行配置以便安装运行 Istio。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/gke/>Google Kubernetes Engine</a></li><li role=none><a role=treeitem title="为 IBM Cloud 集群设置 Istio 的说明。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/ibm/>IBM Cloud</a></li><li role=none><a role=treeitem title="对 Minikube 集群进行配置以便安装运行 Istio。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/minikube/>Minikube</a></li><li role=none><a role=treeitem title="对 OpenShift 集群进行配置以便安装运行 Istio。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/openshift/>OpenShift</a></li><li role=none><a role=treeitem title="为 Istio 对 OKE 集群环境进行配置。" href=/v1.1/zh/docs/setup/kubernetes/prepare/platform-setup/oci/>Oracle Cloud Infrastructure</a></li></ul></li></ul></li><li role=treeitem aria-label=安装方案><button aria-hidden=true></button><a title=选择最适合您需求和平台的方案。 href=/v1.1/zh/docs/setup/kubernetes/install/>安装方案</a><ul role=group aria-expanded=false><li role=none><a role=treeitem title="在 Kubernetes 集群中快速安装 Istio 服务网格的说明。" href=/v1.1/zh/docs/setup/kubernetes/install/kubernetes/>在 Kubernetes 中快速开始</a></li><li role=none><a role=treeitem title="使用内含的 Helm chart 安装 Istio。" href=/v1.1/zh/docs/setup/kubernetes/install/helm/>使用 Helm 进行安装</a></li><li role=treeitem aria-label=多集群安装><button aria-hidden=true></button><a title="配置跨越多个 Kubernetes 集群的 Istio 服务网格。" href=/v1.1/zh/docs/setup/kubernetes/install/multicluster/>多集群安装</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="使用 Istio Gateway 跨越多个 Kubernetes 集群安装 Istio 网格以访问远程 pod。" href=/v1.1/zh/docs/setup/kubernetes/install/multicluster/gateways/>Gateway 连接</a></li><li role=none><a role=treeitem title="通过直连远程 pods 实现多 Kubernetes 集群安装 Istio 网格。" href=/v1.1/zh/docs/setup/kubernetes/install/multicluster/vpn/>VPN 连接</a></li></ul></li><li role=treeitem aria-label=特定平台安装说明><button aria-hidden=true></button><a title="支持的 Kubernetes 平台的额外安装流程。" href=/v1.1/zh/docs/setup/kubernetes/install/platform/>特定平台安装说明</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="如何使用阿里云 Kubernetes 容器服务快速安装 Istio。" href=/v1.1/zh/docs/setup/kubernetes/install/platform/alicloud/>阿里云</a></li><li role=none><a role=treeitem title="在 Google Kubernetes Engine (GKE) 上快速搭建 Istio 服务。" href=/v1.1/zh/docs/setup/kubernetes/install/platform/gke/>Google Kubernetes Engine</a></li><li role=none><a role=treeitem title="如何使用 IBM 公有云或 IBM 私有云快速安装 Istio。" href=/v1.1/zh/docs/setup/kubernetes/install/platform/ibm/>IBM Cloud</a></li></ul></li></ul></li><li role=treeitem aria-label=升级><button aria-hidden=true></button><a title="升级 Istio 的相关信息。" href=/v1.1/zh/docs/setup/kubernetes/upgrade/>升级</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="在升级到 Istio 1.1 之前,运维人员必须了解的重要更改。" href=/v1.1/zh/docs/setup/kubernetes/upgrade/notice/>1.1 升级通知</a></li><li role=none><a role=treeitem title="演示如何独立升级 Istio 控制平面和数据平面。" href=/v1.1/zh/docs/setup/kubernetes/upgrade/steps/>升级步骤</a></li></ul></li><li role=treeitem aria-label=更多指南><button aria-hidden=true></button><a title=有关其他设置任务的更多信息。 href=/v1.1/zh/docs/setup/kubernetes/additional-setup/>更多指南</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="Istio 内置的安装配置文件介绍。" href=/v1.1/zh/docs/setup/kubernetes/additional-setup/config-profiles/>安装配置</a></li><li role=none><a role=treeitem title="介绍两种将 Istio sidecar 注入应用 Pod 的方法:使用 Sidecar 注入 Webhook 自动完成,或使用 istioctl 客户端工具手工完成。" href=/v1.1/zh/docs/setup/kubernetes/additional-setup/sidecar-injection/>注入 Istio sidecar</a></li><li role=none><a role=treeitem title="这里讲述了 Istio 对 Kubernetes 中 Pod 和服务的要求。" href=/v1.1/zh/docs/setup/kubernetes/additional-setup/requirements/>Istio 对 Pod 和服务的要求</a></li><li role=none><a role=treeitem title="Istio CNI 插件的安装和使用 Istio,该插件让运维人员可以用较低的权限来完成网格服务的部署工作。" href=/v1.1/zh/docs/setup/kubernetes/additional-setup/cni/>Istio CNI 插件的安装和使用 Istio</a></li><li role=none><a role=treeitem title="部署在 Kubernetes 之中的 Istio 服务网格,将虚拟机和物理机集成进入到服务网格的方法。" href=/v1.1/zh/docs/setup/kubernetes/additional-setup/mesh-expansion/>网格扩展</a></li></ul></li></ul></li><li role=treeitem aria-label="Nomad & Consul"><button aria-hidden=true></button><a title="基于 Consul 和 Nomad 安装 Istio 控制平面。" href=/v1.1/zh/docs/setup/consul/>Nomad & Consul</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="通过 Docker Compose 快速安装 Istio service mesh。" href=/v1.1/zh/docs/setup/consul/quick-start/>通过 Docker 快速安装</a></li><li role=none><a role=treeitem title="基于 Consul 和 Nomad 安装 Istio 控制平面。" href=/v1.1/zh/docs/setup/consul/install/>安装</a></li></ul></li></ul></div></div><div class=card><button class="header dynamic" id=card49 title="如何用 Istio 系统实现特定目标的行为。" aria-controls=card49-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#tasks"/></svg>任务</button><div class="body default" aria-labelledby=card49 role=region id=card49-body><ul role=tree aria-expanded=true aria-labelledby=card49><li role=treeitem aria-label=流量管理><button class=show aria-hidden=true></button><a title="演示 Istio 流量路由功能的任务。" href=/v1.1/zh/docs/tasks/traffic-management/>流量管理</a><ul role=group aria-expanded=true><li role=none><a role=treeitem title=此任务将说明如何将请求动态路由到多个版本的微服务。 href=/v1.1/zh/docs/tasks/traffic-management/request-routing/>配置请求路由</a></li><li role=none><a role=treeitem title=此任务说明如何注入延迟并测试应用程序的弹性。 href=/v1.1/zh/docs/tasks/traffic-management/fault-injection/>故障注入</a></li><li role=none><a role=treeitem title=向您展示如何将流量从旧版本迁移到新版本的服务。 href=/v1.1/zh/docs/tasks/traffic-management/traffic-shifting/>流量转移</a></li><li role=none><a role=treeitem title="展示如何将一个 TCP 服务的流量从老版本迁移到新版本。" href=/v1.1/zh/docs/tasks/traffic-management/tcp-traffic-shifting/>TCP 流量转移</a></li><li role=none><a role=treeitem title="本任务用于示范如何使用 Istio 在 Envoy 中设置请求超时。" href=/v1.1/zh/docs/tasks/traffic-management/request-timeouts/>设置请求超时</a></li><li role=none><a role=treeitem title="介绍在服务网格 Istio 中如何配置外部公开服务。" href=/v1.1/zh/docs/tasks/traffic-management/ingress/>控制 Ingress 流量</a></li><li role=treeitem aria-label="加密 Ingress Gateway"><button aria-hidden=true></button><a title="使用多种方法为 Gateway 控制器提供加密支持。" href=/v1.1/zh/docs/tasks/traffic-management/secure-ingress/>加密 Ingress Gateway</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="如何配置 Istio,借助 SDS(Secret 发现服务),使用 TLS 或双向 TLS 将服务开放到网格之外。" href=/v1.1/zh/docs/tasks/traffic-management/secure-ingress/sds/>使用 SDS 为 Gateway 提供 HTTPS 加密支持</a></li></ul></li><li role=none><span role=treeitem class=current title="在 Istio 中配置从网格内访问外部服务的流量路由。">控制 Egress 流量</span></li><li role=none><a role=treeitem title=用连接、请求以及外部检测来进行熔断配置的过程。 href=/v1.1/zh/docs/tasks/traffic-management/circuit-breaking/>熔断</a></li><li role=none><a role=treeitem title="此任务演示了 Istio 的流量镜像功能。" href=/v1.1/zh/docs/tasks/traffic-management/mirroring/>镜像</a></li></ul></li><li role=treeitem aria-label=安全><button aria-hidden=true></button><a title=演示对服务网格进行安全加固的方法。 href=/v1.1/zh/docs/tasks/security/>安全</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="展示为 HTTP 服务设置基于角色的访问控制方法。" href=/v1.1/zh/docs/tasks/security/authz-http/>HTTP 服务的访问控制</a></li><li role=none><a role=treeitem title="整合 Vault CA 到 Istio 中为双向 TLS 提供 支持。" href=/v1.1/zh/docs/tasks/security/vault-ca/>Istio Vault CA 集成</a></li><li role=none><a role=treeitem title="有关如何在 Istio 中配置基于组的授权和配置列表类型声明的授权的教程。" href=/v1.1/zh/docs/tasks/security/rbac-groups/>基于组和列表类型声明的授权</a></li><li role=none><a role=treeitem title="介绍如何使用 Istio 认证策略设置双向 TLS 和基本的终端用户认证。" href=/v1.1/zh/docs/tasks/security/authn-policy/>基础认证策略</a></li><li role=none><a role=treeitem title="对 Istio 的自动双向 TLS 认证功能进行体验和测试。" href=/v1.1/zh/docs/tasks/security/mutual-tls/>深入了解双向 TLS</a></li><li role=none><a role=treeitem title=展示宽容模式的的鉴权过程。 href=/v1.1/zh/docs/tasks/security/authz-permissive/>鉴权过程中的宽容模式</a></li><li role=none><a role=treeitem title="展示如何为 TCP 服务设置基于角色的访问控制。" href=/v1.1/zh/docs/tasks/security/authz-tcp/>TCP 服务的访问控制</a></li><li role=none><a role=treeitem title=展示如何在服务网格中进行基于角色的访问控制。 href=/v1.1/zh/docs/tasks/security/role-based-access-control/>基于角色的访问控制</a></li><li role=none><a role=treeitem title="运维人员如何使用现有根证书配置 Citadel 进行证书以及密钥的签发。" href=/v1.1/zh/docs/tasks/security/plugin-ca-cert/>插入外部 CA 密钥和证书</a></li><li role=none><a role=treeitem title="如何在 Kubernetes 中启用 Citadel 的健康检查。" href=/v1.1/zh/docs/tasks/security/health-check/>Citadel 的健康检查</a></li><li role=none><a role=treeitem title="展示启用 SDS 来为 Istio 提供身份服务的过程。" href=/v1.1/zh/docs/tasks/security/auth-sds/>通过 SDS 提供身份服务</a></li><li role=none><a role=treeitem title="如何渐进式的为现有 Istio 服务添加双向 TLS 支持。" href=/v1.1/zh/docs/tasks/security/mtls-migration/>双向 TLS 的迁移</a></li><li role=none><a role=treeitem title="展示如何在 HTTPS 服务上启用双向 TLS。" href=/v1.1/zh/docs/tasks/security/https-overlay/>通过 HTTPS 进行双向 TLS</a></li></ul></li><li role=treeitem aria-label=策略><button aria-hidden=true></button><a title=演示策略实施功能。 href=/v1.1/zh/docs/tasks/policy-enforcement/>策略</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="本任务讲解如何启用 Istio 策略检查功能。" href=/v1.1/zh/docs/tasks/policy-enforcement/enabling-policy/>启用策略检查</a></li><li role=none><a role=treeitem title="这一任务展示了如何使用 Istio 动态的对服务通信进行速率限制。" href=/v1.1/zh/docs/tasks/policy-enforcement/rate-limiting/>启用速率限制</a></li><li role=none><a role=treeitem title="展示使用简单的 Denier 适配器或黑白名单对服务进行访问控制的方法。" href=/v1.1/zh/docs/tasks/policy-enforcement/denial-and-list/>Denier 适配器以及黑白名单</a></li><li role=none><a role=treeitem title="显示如何使用策略适配器修改请求 header 和路由。" href=/v1.1/zh/docs/tasks/policy-enforcement/control-headers/>控制 header 和路由</a></li></ul></li><li role=treeitem aria-label=遥测><button aria-hidden=true></button><a title=演示从服务网格收集遥测信息的方法。 href=/v1.1/zh/docs/tasks/telemetry/>遥测</a><ul role=group aria-expanded=false><li role=treeitem aria-label=指标度量><button aria-hidden=true></button><a title="演示 Istio 网格指标度量的配置、收集和处理。" href=/v1.1/zh/docs/tasks/telemetry/metrics/>指标度量</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="这一任务讲述如何配置 Istio,进行指标和日志的收集工作。" href=/v1.1/zh/docs/tasks/telemetry/metrics/collecting-metrics/>收集指标和日志</a></li><li role=none><a role=treeitem title="本任务展示了如何配置 Istio 进行 TCP 服务的指标收集。" href=/v1.1/zh/docs/tasks/telemetry/metrics/tcp-metrics/>获取 TCP 服务指标</a></li><li role=none><a role=treeitem title="此任务说明如何使用 Prometheus 查询 Istio 指标。" href=/v1.1/zh/docs/tasks/telemetry/metrics/querying-metrics/>查询 Prometheus 的指标</a></li><li role=none><a role=treeitem title="这个任务向您展示了如何设置和使用 Istio 仪表盘来监视网格流量。" href=/v1.1/zh/docs/tasks/telemetry/metrics/using-istio-dashboard/>使用 Grafana 可视化指标度量</a></li></ul></li><li role=treeitem aria-label=日志><button aria-hidden=true></button><a title="演示 Istio 网格日志的配置、收集和处理。" href=/v1.1/zh/docs/tasks/telemetry/logs/>日志</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="这一任务讲述如何配置 Istio,进行日志的收集工作。" href=/v1.1/zh/docs/tasks/telemetry/logs/collecting-logs/>收集日志</a></li><li role=none><a role=treeitem title="此任务向您展示如何配置 Envoy 代理将访问日志打印到其标准输出。" href=/v1.1/zh/docs/tasks/telemetry/logs/access-log/>获取 Envoy 访问日志</a></li><li role=none><a role=treeitem title="此任务说明如何配置 Istio 以将日志输出到 Fluentd 守护程序。" href=/v1.1/zh/docs/tasks/telemetry/logs/fluentd/>使用 Fluentd 记录日志</a></li></ul></li><li role=treeitem aria-label=分布式追踪><button aria-hidden=true></button><a title="该任务展示了如何为启用了 Istio 支持的应用进行追踪。" href=/v1.1/zh/docs/tasks/telemetry/distributed-tracing/>分布式追踪</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="Istio 分布式追踪概述。" href=/v1.1/zh/docs/tasks/telemetry/distributed-tracing/overview/>概述</a></li><li role=none><a role=treeitem title="了解如何配置代理以向 Jaeger 发送追踪请求。" href=/v1.1/zh/docs/tasks/telemetry/distributed-tracing/jaeger/>Jaeger</a></li><li role=none><a role=treeitem title="了解如何配置代理以向 Zipkin 发送追踪请求。" href=/v1.1/zh/docs/tasks/telemetry/distributed-tracing/zipkin/>Zipkin</a></li><li role=none><a role=treeitem title="如何配置代理以发送请求至 LightStep [𝑥]PM." href=/v1.1/zh/docs/tasks/telemetry/distributed-tracing/lightstep/>使用 LightStep [𝑥]PM 进行分布式追踪</a></li></ul></li><li role=none><a role=treeitem title="本任务展示了在 Istio 网格中对服务进行可视化的过程。" href=/v1.1/zh/docs/tasks/telemetry/kiali/>网格可视化</a></li><li role=none><a role=treeitem title="本任务展示了为 Istio 遥测插件配置外部访问的过程。" href=/v1.1/zh/docs/tasks/telemetry/gateways/>遥测插件的远程访问</a></li></ul></li></ul></div></div><div class=card><button class="header dynamic" id=card84 title="这里包括多个可供 Istio 使用的可完整工作的示例,你可以用来亲自部署和体验这些示例。" aria-controls=card84-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#examples"/></svg>示例</button><div class=body aria-labelledby=card84 role=region id=card84-body><ul role=tree aria-expanded=true aria-labelledby=card84><li role=none><a role=treeitem title="部署一个用于演示多种 Istio 特性的应用,由四个单独的微服务构成。" href=/v1.1/zh/docs/examples/bookinfo/>Bookinfo 应用</a></li><li role=none><a role=treeitem title="如何在 Istio 服务网格中使用多种流量管理功能。" href=/v1.1/zh/docs/examples/intelligent-routing/>智能路由</a></li><li role=none><a role=treeitem title="演示如何使用 Istio Mixer 和 Istio sidecar 获取指标和日志,并在不同的服务间进行追踪。" href=/v1.1/zh/docs/examples/telemetry/>深入遥测</a></li><li role=none><a role=treeitem title="说明如何在谷歌云 Endpoints 服务中手动整合 Istio。" href=/v1.1/zh/docs/examples/endpoints/>在谷歌云 Endpoints 服务中安装 Istio</a></li><li role=none><a role=treeitem title="在单一服务网格中,如何使用 Istio 对 Kubernetes 集群以及虚拟机进行控制。" href=/v1.1/zh/docs/examples/integrating-vms/>虚拟机集成</a></li><li role=treeitem aria-label=边缘流量控制><button aria-hidden=true></button><a title="用于管理 Istio 服务网格的边缘流量(即 Ingress 和 Egress 流量)的各种高级示例。" href=/v1.1/zh/docs/examples/advanced-gateways/>边缘流量控制</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="介绍如何为入口网关配置 SNI 直通。" href=/v1.1/zh/docs/examples/advanced-gateways/ingress-sni-passthrough/>没有 TLS 的 Ingress gateway</a></li><li role=none><a role=treeitem title="描述如何通过专用网关服务将流量定向到外部服务来配置 Istio。" href=/v1.1/zh/docs/examples/advanced-gateways/egress-gateway/>配置 Egress gateway</a></li><li role=none><a role=treeitem title="描述了配置 Egress 网关来发起对外部服务进行 TLS 通信的过程。" href=/v1.1/zh/docs/examples/advanced-gateways/egress-gateway-tls-origination/>Egress 网关的 TLS 发起过程</a></li><li role=none><a role=treeitem title="此任务描述 Istio 如何配置出口流量的 TLS。" href=/v1.1/zh/docs/examples/advanced-gateways/egress-tls-origination/>出口流量的 TLS</a></li><li role=none><a role=treeitem title="介绍如何为公共域中的一组主机启用 Egress 流量,而不是单独配置每个主机。" href=/v1.1/zh/docs/examples/advanced-gateways/wildcard-egress-hosts/>使用通配符主机配置 Egress 流量</a></li><li role=none><a role=treeitem title="如何为 Egress TLS 流量配置 SNI 监控并应用策略。" href=/v1.1/zh/docs/examples/advanced-gateways/egress_sni_monitoring_and_policies/>Egress TLS 流量中的 SNI 监控及策略</a></li><li role=none><a role=treeitem title="描述如何配置 Istio 以允许应用程序使用外部 HTTPS 代理。" href=/v1.1/zh/docs/examples/advanced-gateways/http-proxy/>连接到外部 HTTPS 代理</a></li><li role=none><a role=treeitem title="展示使用 cert-Manager 为 Kubernetes Ingress 获取 Let's Encrypt TLS 证书的过程。" href=/v1.1/zh/docs/examples/advanced-gateways/ingress-certmgr/>使用 cert-manager 加密 Kubernetes Ingress</a></li></ul></li><li role=treeitem aria-label=单一三层网络的多集群网格><button aria-hidden=true></button><a title="您可以尝试各种基于 VPN 的 Istio 多集群示例。" href=/v1.1/zh/docs/examples/multicluster/>单一三层网络的多集群网格</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title=在一个使用网关进行连接的多集群网格中配置远程服务。 href=/v1.1/zh/docs/examples/multicluster/gateways/>通过网关进行连接的多集群</a></li><li role=none><a role=treeitem title="基于 GKE 的 Istio 多集群安装。" href=/v1.1/zh/docs/examples/multicluster/gke/>Google Kubernetes Engine</a></li><li role=none><a role=treeitem title="多 IBM Cloud Private 集群安装 Istio 示例。" href=/v1.1/zh/docs/examples/multicluster/icp/>IBM Cloud Private</a></li><li role=none><a role=treeitem title="IBM Cloud Kubernetes Service 和 IBM Cloud Private 之间的多集群示例。" href=/v1.1/zh/docs/examples/multicluster/iks-icp/>IBM Cloud Kubernetes Service & IBM Cloud Private</a></li><li role=none><a role=treeitem title="利用 Istio 的水平分割 EDS 来创建多集群网格。" href=/v1.1/zh/docs/examples/multicluster/split-horizon-eds/>集群感知的服务路由</a></li></ul></li></ul></div></div><div class=card><button class="header dynamic" id=card114 title="参考部分包含详细的权威参考资料,如命令行选项、配置选项和 API 调用参数。" aria-controls=card114-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#reference"/></svg>参考</button><div class=body aria-labelledby=card114 role=region id=card114-body><ul role=tree aria-expanded=true aria-labelledby=card114><li role=treeitem aria-label=配置><button aria-hidden=true></button><a title=关于配置选项的详细信息。 href=/v1.1/zh/docs/reference/config/>配置</a><ul role=group aria-expanded=false><li role=treeitem aria-label=流量管理><button aria-hidden=true></button><a title="描述如何配置 HTTP/TCP 路由功能。" href=/v1.1/zh/docs/reference/config/networking/>流量管理</a><ul role=group aria-expanded=false class=leaf-section></ul></li><li role=none><a role=treeitem title="描述了使用 Helm chart 安装 Istio 时可以使用的选项。" href=/v1.1/zh/docs/reference/config/installation-options/>安装选项</a></li><li role=none><a role=treeitem title="详细描述 release-1.0 和 release-1.1 之间 Helm chart 安装选项的差异。" href=/v1.1/zh/docs/reference/config/installation-options-changes/>安装选项的变更</a></li><li role=treeitem aria-label=授权><button aria-hidden=true></button><a title=关于如何配置Istio授权特性的描述。 href=/v1.1/zh/docs/reference/config/authorization/>授权</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title=描述所支持的约束和属性。 href=/v1.1/zh/docs/reference/config/authorization/constraints-and-properties/>约束和属性</a></li><li role=none><a role=treeitem title=配置基于角色的访问控制。 href=/v1.1/zh/docs/reference/config/authorization/istio.rbac.v1alpha1/>RBAC</a></li></ul></li><li role=treeitem aria-label=策略和遥测><button aria-hidden=true></button><a title="描述如何配置 Istio 的策略和遥测功能。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/>策略和遥测</a><ul role=group aria-expanded=false><li role=none><a role=treeitem title=介绍策略和控制中会用到的一些基础属性词汇。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/attribute-vocabulary/>属性词汇</a></li><li role=none><a role=treeitem title="Mixer 的配置表达式语言参考。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/expression-language/>表达式语言</a></li><li role=treeitem aria-label=适配器><button aria-hidden=true></button><a title="Mixer 适配器能够让 Istio 连接各种基础设施后端以完成类似指标和日志这样的功能。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/>适配器</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="Apigee 的分布式策略检查以及分析适配器。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/apigee/>Apigee</a></li><li role=none><a role=treeitem title="适用于 circonus.com 的监控解决方案。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/circonus/>Circonus</a></li><li role=none><a role=treeitem title="CloudMonitor 适配器使 Istio 可以向 AliCloud CloudMonitor 提供指标。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/cloudmonitor/>CloudMonitor</a></li><li role=none><a role=treeitem title=始终返回按前提条件拒绝的适配器。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/denier/>Denier</a></li><li role=none><a role=treeitem title="用于将日志发送给 Fluentd 守护进程的适配器。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/fluentd/>Fluentd</a></li><li role=none><a role=treeitem title="将指标发送到 SignalFx 的适配器。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/signalfx/>SignalFx</a></li><li role=none><a role=treeitem title="从 Kubernetes 环境中获取集群信息。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/kubernetesenv/>Kubernetes Env</a></li><li role=none><a role=treeitem title=用于执行黑名单或白名单检测的适配器。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/list/>List</a></li><li role=none><a role=treeitem title=简单内存配额管理系统适配器。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/memquota/>Memory quota</a></li><li role=none><a role=treeitem title="基于 Redis 的配额管理系统。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/redisquota/>Redis Quota</a></li><li role=none><a role=treeitem title="用于向 Google Service Control 发送日志和指标的适配器。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/servicecontrol/>Service Control</a></li><li role=none><a role=treeitem title="该适配器用于向 statsd 后端发送指标数据。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/statsd/>statsd</a></li><li role=none><a role=treeitem title=该适配器可以在本地输出日志和指标。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/adapters/stdio/>Stdio</a></li></ul></li><li role=treeitem aria-label=模板><button aria-hidden=true></button><a title="Mixer 模板用于将数据发送到各个适配器。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/>模板</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="该模板用于表达一个 API Key。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/apikey/>API Key</a></li><li role=none><a role=treeitem title="Analytics 模板用于向 Apigee 发送运行时遥测数据。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/analytics/>Analytics</a></li><li role=none><a role=treeitem title=该模版用于访问控制查询。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/authorization/>Authorization</a></li><li role=none><a role=treeitem title=该模板不包含任何数据,用于测试。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/checknothing/>Check Nothing</a></li><li role=none><a role=treeitem title="用于生成 Kubernetes 的特定属性。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/kubernetes/>Kubernetes</a></li><li role=none><a role=treeitem title=该模板用于执行列表检查操作。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/listentry/>List Entry</a></li><li role=none><a role=treeitem title=该模板用于表达一条运行时日志项。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/logentry/>Log Entry</a></li><li role=none><a role=treeitem title=该模板用于表达一个运行时产生的监控指标数据。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/metric/>Metric</a></li><li role=none><a role=treeitem title=该模板用于表达占用配额的请求。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/quota/>Quota</a></li><li role=none><a role=treeitem title=该模板不包含数据,用于测试。 href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/reportnothing/>Report Nothing</a></li><li role=none><a role=treeitem title="用于 Google Service Control 适配器的模板。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/servicecontrolreport/>Service Control Report</a></li><li role=none><a role=treeitem title="该模板用于表达分布式追踪数据中的一个 Span。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/templates/tracespan/>Trace Span</a></li></ul></li><li role=none><a role=treeitem title="通过 Mixer 从 Istio 导出的默认监控指标。" href=/v1.1/zh/docs/reference/config/policy-and-telemetry/metrics/>默认监控指标</a></li></ul></li><li role=none><a role=treeitem title=流量路由配置。 href=/v1.1/zh/docs/reference/config/istio.networking.v1alpha3/>通信路由</a></li></ul></li><li role=treeitem aria-label=命令><button aria-hidden=true></button><a title="描述 Istio 命令和工具的用法及选项。" href=/v1.1/zh/docs/reference/commands/>命令</a><ul role=group aria-expanded=false class=leaf-section><li role=none><a role=treeitem title="Galley 为 Istio 提供配置管理服务。" href=/v1.1/zh/docs/reference/commands/galley/>galley</a></li><li role=none><a role=treeitem title="自动注入 Istio sidecar 的 Kubernetes webhook。" href=/v1.1/zh/docs/reference/commands/sidecar-injector/>sidecar-injector</a></li><li role=none><a role=treeitem title="Istio 控制界面。" href=/v1.1/zh/docs/reference/commands/istioctl/>istioctl</a></li><li role=none><a role=treeitem title="Istio 证书颁发(CA)。" href=/v1.1/zh/docs/reference/commands/istio_ca/>istio_ca</a></li><li role=none><a role=treeitem title="用于触发直接调用 Mixer API 的实用程序。" href=/v1.1/zh/docs/reference/commands/mixc/>mixc</a></li><li role=none><a role=treeitem title="Mixer 是 Istio 在后端基础设施之上的抽象。" href=/v1.1/zh/docs/reference/commands/mixs/>mixs</a></li><li role=none><a role=treeitem title="节点一级的 Istio 安全代理。" href=/v1.1/zh/docs/reference/commands/node_agent/>node_agent</a></li><li role=none><a role=treeitem title="Istio Pilot。" href=/v1.1/zh/docs/reference/commands/pilot-discovery/>pilot-discovery</a></li></ul></li></ul></div></div></div></nav></div><div class=article-container><button tabindex=-1 id=sidebar-toggler title=折叠导航栏><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#pull"/></svg></button><nav aria-label=Breadcrumb><ol><li><a href=/v1.1/zh/>Istio</a></li><li><a href=/v1.1/zh/docs/ title="了解如何部署、使用和运维 Istio。">文档</a></li><li><a href=/v1.1/zh/docs/tasks/ title="如何用 Istio 系统实现特定目标的行为。">任务</a></li><li><a href=/v1.1/zh/docs/tasks/traffic-management/ title="演示 Istio 流量路由功能的任务。">流量管理</a></li><li>控制 Egress 流量</li></ol></nav><article aria-labelledby=title><div class=title-area><div><h1 id=title>控制 Egress 流量</h1><p class=byline><span title="1061 字"><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#clock"/></svg><span> </span>阅读大约需要 5 分钟</span></p></div></div><nav class=toc-inlined aria-label="Table of Contents"><div><hr><ol><li role=none aria-label=开始之前><a href=#%e5%bc%80%e5%a7%8b%e4%b9%8b%e5%89%8d>开始之前</a><li role=none aria-label="Envoy 配置外部服务"><a href=#envoy-%e9%85%8d%e7%bd%ae%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>Envoy 配置外部服务</a><ol><li role=none aria-label=控制外部服务><a href=#%e6%8e%a7%e5%88%b6%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>控制外部服务</a><li role=none aria-label=修改为默认阻止策略><a href=#%e4%bf%ae%e6%94%b9%e4%b8%ba%e9%bb%98%e8%ae%a4%e9%98%bb%e6%ad%a2%e7%ad%96%e7%95%a5>修改为默认阻止策略</a><li role=none aria-label="访问外部 HTTP 服务"><a href=#%e8%ae%bf%e9%97%ae%e5%a4%96%e9%83%a8-http-%e6%9c%8d%e5%8a%a1>访问外部 HTTP 服务</a><li role=none aria-label="配置外部 HTTPS 服务"><a href=#%e9%85%8d%e7%bd%ae%e5%a4%96%e9%83%a8-https-%e6%9c%8d%e5%8a%a1>配置外部 HTTPS 服务</a><li role=none aria-label=管理外部服务的流量><a href=#%e7%ae%a1%e7%90%86%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e6%b5%81%e9%87%8f>管理外部服务的流量</a><li role=none aria-label=清除对外部服务的受控访问><a href=#%e6%b8%85%e9%99%a4%e5%af%b9%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e5%8f%97%e6%8e%a7%e8%ae%bf%e9%97%ae>清除对外部服务的受控访问</a></ol></li><li role=none aria-label=直接调用外部服务><a href=#%e7%9b%b4%e6%8e%a5%e8%b0%83%e7%94%a8%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>直接调用外部服务</a><ol><li role=none aria-label="确定平台的内部 IP 范围"><a href=#%e7%a1%ae%e5%ae%9a%e5%b9%b3%e5%8f%b0%e7%9a%84%e5%86%85%e9%83%a8-ip-%e8%8c%83%e5%9b%b4>确定平台的内部 IP 范围</a><ol><li role=none aria-label="IBM Cloud Private"><a href=#ibm-cloud-private>IBM Cloud Private</a><li role=none aria-label="IBM Cloud Kubernetes Service"><a href=#ibm-cloud-kubernetes-service>IBM Cloud Kubernetes Service</a><li role=none aria-label="Google Container Engine (GKE)"><a href=#google-container-engine-gke>Google Container Engine (GKE)</a><li role=none aria-label="Azure Container Service(ACS)"><a href=#azure-container-service-acs>Azure Container Service(ACS)</a><li role=none aria-label="Minikube, Docker For Desktop, Bare Metal"><a href=#minikube-docker-for-desktop-bare-metal>Minikube, Docker For Desktop, Bare Metal</a></ol></li><li role=none aria-label=配置代理绕过><a href=#%e9%85%8d%e7%bd%ae%e4%bb%a3%e7%90%86%e7%bb%95%e8%bf%87>配置代理绕过</a><li role=none aria-label=访问外部服务><a href=#%e8%ae%bf%e9%97%ae%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>访问外部服务</a><li role=none aria-label=清除对外部服务的直接访问><a href=#%e6%b8%85%e9%99%a4%e5%af%b9%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e7%9b%b4%e6%8e%a5%e8%ae%bf%e9%97%ae>清除对外部服务的直接访问</a></ol></li><li role=none aria-label=理解原理><a href=#%e7%90%86%e8%a7%a3%e5%8e%9f%e7%90%86>理解原理</a><li role=none aria-label=安全说明><a href=#%e5%ae%89%e5%85%a8%e8%af%b4%e6%98%8e>安全说明</a><li role=none aria-label=清理><a href=#%e6%b8%85%e7%90%86>清理</a><li role=none aria-label=相关内容><a href=#see-also>相关内容</a></li></ol><hr></div></nav><p>缺省情况下,Istio 服务网格内的 Pod,由于其 iptables 将所有外发流量都透明的转发给了 Sidecar,所以这些集群内的服务无法访问集群之外的 URL,而只能处理集群内部的目标。</p><p>本文的任务描述了如何将外部服务暴露给 Istio 集群中的客户端。你将会学到如何通过定义 <a href=/v1.1/zh/docs/reference/config/istio.networking.v1alpha3/#serviceentry><code>ServiceEntry</code></a> 来调用外部服务;或者简单的对 Istio 进行配置,要求其直接放行对特定 IP 范围的访问。</p><h2 id=开始之前>开始之前</h2><ul><li><p>根据<a href=/v1.1/zh/docs/setup>安装指南</a>的内容,部署 Istio。</p></li><li><p>启动 <a href=https://github.com/istio/istio/tree/release-1.1/samples/sleep>sleep</a> 示例应用,我们将会使用这一应用来完成对外部服务的调用过程。</p><p>如果启用了 <a href=/v1.1/zh/docs/setup/kubernetes/additional-setup/sidecar-injection/#sidecar-的自动注入>Sidecar 的自动注入功能</a>,运行:</p><div><a data-skipendnotes=true style=display:none href=https://raw.githubusercontent.com/istio/istio/release-1.1/samples/sleep/sleep.yaml>Zip</a><pre><code class=language-bash data-expandlinks=true>$ kubectl apply -f @samples/sleep/sleep.yaml@
|
||
</code></pre></div><p>否则在部署 <code>sleep</code> 应用之前,就需要手工注入 Sidecar:</p><div><a data-skipendnotes=true style=display:none href=https://raw.githubusercontent.com/istio/istio/release-1.1/samples/sleep/sleep.yaml>Zip</a><pre><code class=language-bash data-expandlinks=true>$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@)
|
||
</code></pre></div><div><aside class="callout tip"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-tip"/></svg></div><div class=content>实际上任何可以 <code>curl</code> 的 Pod 都可以用来完成这一任务。</div></aside></div></li><li><p>将 <code>SOURCE_POD</code> 环境变量设置为已部署的 <code>sleep</code> pod:</p><pre><code class=language-bash data-expandlinks=true>$ export SOURCE_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
||
</code></pre></li></ul><h2 id=envoy-配置外部服务>Envoy 配置外部服务</h2><p>Istio 有一个<a href=/v1.1/zh/docs/reference/config/installation-options/>安装选项</a> <code>global.outboundTrafficPolicy.mode</code>,配置了 Sidecar 对外部服务的处理方式,所谓外部服务就是没有在 Istio 内部服务注册表中进行注册的服务。
|
||
如果此选项设置为 <code>ALLOW_ANY</code>,则 Istio 代理允许调用未知服务。
|
||
如果该选项设置为 <code>REGISTRY_ONLY</code>,则 Istio 代理会阻止任何没有 HTTP 服务的主机或网格中定义的服务条目。
|
||
<code>ALLOW_ANY</code> 是默认值,允许您快速开始评估 Istio,而无需控制对外部服务的访问。
|
||
然后后面你可以决定<a href=#控制外部服务>配置对外部服务的访问</a> .</p><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-warning"/></svg></div><div class=content>在 Istio 1.1.4 之前的版本中,<code>ALLOW_ANY</code> 仅适用于没有在网格中定义的 HTTP 服务或服务条目的端口。
|
||
使用与任何内部 HTTP 服务相同的端口的外部主机回退到默认阻止行为。
|
||
由于某些端口(例如端口 80 )默认情况下在 Istio 内部具有 HTTP 服务,因此在 Istio 1.1.3 之前,您无法在那些端口上调用外部服务。</div></aside></div><ol><li><p>要查看此方法,您需要确保将 <code>global.outboundTrafficPolicy.mode</code> 选项设置为 <code>ALLOW_ANY</code> 来配置 Istio 安装。除非您在安装 Istio 时将其明确设置为 <code>REGISTRY_ONLY</code> 模式,否则默认情况下可能会启用它。</p><p>运行以下命令以确认配置正确:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl get configmap istio -n istio-system -o yaml | grep -o "mode: ALLOW_ANY"
|
||
mode: ALLOW_ANY
|
||
</code></pre><p>如果启用了 <code>mode: ALLOW_ANY</code>,它应出现在输出中。</p><div><aside class="callout tip"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-tip"/></svg></div><div class=content><p>如果已显式配置 <code>REGISTRY_ONLY</code> 模式,则可以运行以下命令进行更改:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl get configmap istio -n istio-system -o yaml | sed 's/mode: REGISTRY_ONLY/mode: ALLOW_ANY/g' | kubectl replace -n istio-system -f -
|
||
configmap "istio" replaced
|
||
</code></pre></div></aside></div></li><li><p>从 <code>SOURCE_POD</code> 向外部 HTTPS 服务发出几个请求以确认成功的 <code>200</code> 响应:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep -- curl -I https://www.google.com | grep "HTTP/"; kubectl exec -it $SOURCE_POD -c sleep -- curl -I https://edition.cnn.com | grep "HTTP/"
|
||
HTTP/2 200
|
||
HTTP/2 200
|
||
</code></pre></li></ol><p>恭喜!您已成功从网格中发送出口流量。</p><p>这种访问外部服务的简单方法的缺点是您失去了对外部服务流量的监控和控制;例如,调用外部服务不会出现在 Mixer 日志中。
|
||
下一节将向您展示如何监视和控制网格对外部服务的访问。</p><h3 id=控制外部服务>控制外部服务</h3><p>使用 Istio <code>ServiceEntry</code> 配置,您可以从 Istio 集群中访问任何可公开访问的服务。本节介绍如何配置对外部 HTTP 服务的访问,
|
||
<a href=http://httpbin.org>httpbin.org</a>, 以及外部 HTTPS 服务,
|
||
<a href=https://www.google.com>www.google.com</a> 并且已久有 Istio 的流量监控和控制功能。</p><h3 id=修改为默认阻止策略>修改为默认阻止策略</h3><p>要演示启用对外部服务的访问的受控方式,您需要将 <code>global.outboundTrafficPolicy.mode</code> 选项从 <code>ALLOW_ANY</code> 模式更改为 <code>REGISTRY_ONLY</code> 模式。</p><div><aside class="callout tip"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-tip"/></svg></div><div class=content>您可以添加对已在 <code>ALLOW_ANY</code> 模式下可访问的服务的受控访问。
|
||
这样,您就可以开始在某些外部服务上使用 Istio 功能而不会阻止任何其他服务。
|
||
一旦配置了所有服务,就可以将模式切换为 <code>REGISTRY_ONLY</code> 以阻止任何其他无意访问。</div></aside></div><ol><li><p>运行以下命令将 <code>global.outboundTrafficPolicy.mode</code> 选项改为 <code>REGISTRY_ONLY</code>:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl get configmap istio -n istio-system -o yaml | sed 's/mode: ALLOW_ANY/mode: REGISTRY_ONLY/g' | kubectl replace -n istio-system -f -
|
||
configmap "istio" replaced
|
||
</code></pre></li><li><p>从 <code>SOURCE_POD</code> 向外部 HTTPS 服务发出一些请求,以验证它们现在是否被阻止:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep -- curl -I https://www.google.com | grep "HTTP/"; kubectl exec -it $SOURCE_POD -c sleep -- curl -I https://edition.cnn.com | grep "HTTP/"
|
||
command terminated with exit code 35
|
||
command terminated with exit code 35
|
||
</code></pre><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-warning"/></svg></div><div class=content>(因为缓存)配置更改可能需要一段时间才能应用成功,因此您仍可能获得成功的连接。
|
||
等待几秒钟,然后重试最后一个命令。</div></aside></div></li></ol><h3 id=访问外部-http-服务>访问外部 HTTP 服务</h3><ol><li><p>创建一个 <code>ServiceEntry</code> 对象,放行对一个外部 HTTP 服务的访问:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl apply -f - <<EOF
|
||
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
|
||
EOF
|
||
</code></pre></li><li><p>从 <code>SOURCE_POD</code> 向外部 HTTP 服务发出请求:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep -- curl http://httpbin.org/headers
|
||
{
|
||
"headers": {
|
||
"Accept": "*/*",
|
||
"Connection": "close",
|
||
"Host": "httpbin.org",
|
||
"User-Agent": "curl/7.60.0",
|
||
...
|
||
"X-Envoy-Decorator-Operation": "httpbin.org:80/*",
|
||
}
|
||
}
|
||
</code></pre><p>注意由 Istio sidecar 代理添加的标题:<code>X-Envoy-Decorator-Operation</code>。</p></li><li><p>检查 <code>SOURCE_POD</code> 的 sidecar 代理的日志:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl logs $SOURCE_POD -c istio-proxy | tail
|
||
[2019-01-24T12:17:11.640Z] "GET /headers HTTP/1.1" 200 - 0 599 214 214 "-" "curl/7.60.0" "17fde8f7-fa62-9b39-8999-302324e6def2" "httpbin.org" "35.173.6.94:80" outbound|80||httpbin.org - 35.173.6.94:80 172.30.109.82:55314 -
|
||
</code></pre><p>请注意与您对 <code>httpbin.org/headers</code> 的 HTTP 请求相关的条目。</p></li><li><p>检查 Mixer 日志。如果 Istio 部署在 <code>istio-system</code> 命名空间中,则打印日志的命令是:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl -n istio-system logs -l istio-mixer-type=telemetry -c mixer | grep 'httpbin.org'
|
||
{"level":"info","time":"2019-01-24T12:17:11.855496Z","instance":"accesslog.logentry.istio-system","apiClaims":"","apiKey":"","clientTraceId":"","connection_security_policy":"unknown","destinationApp":"","destinationIp":"I60GXg==","destinationName":"unknown","destinationNamespace":"default","destinationOwner":"unknown","destinationPrincipal":"","destinationServiceHost":"httpbin.org","destinationWorkload":"unknown","grpcMessage":"","grpcStatus":"","httpAuthority":"httpbin.org","latency":"214.661667ms","method":"GET","permissiveResponseCode":"none","permissiveResponsePolicyID":"none","protocol":"http","receivedBytes":270,"referer":"","reporter":"source","requestId":"17fde8f7-fa62-9b39-8999-302324e6def2","requestSize":0,"requestedServerName":"","responseCode":200,"responseSize":599,"responseTimestamp":"2019-01-24T12:17:11.855521Z","sentBytes":806,"sourceApp":"sleep","sourceIp":"AAAAAAAAAAAAAP//rB5tUg==","sourceName":"sleep-88ddbcfdd-rgk77","sourceNamespace":"default","sourceOwner":"kubernetes://apis/apps/v1/namespaces/default/deployments/sleep","sourcePrincipal":"","sourceWorkload":"sleep","url":"/headers","userAgent":"curl/7.60.0","xForwardedFor":"0.0.0.0"}
|
||
</code></pre><p>请注意,<code>destinationServiceHost</code> 属性等于 <code>httpbin.org</code>。 还要注意 HTTP 相关的属性:<code>method</code>,<code>url</code>,<code>responseCode</code> 等。使用 Istio 出口流量控制,您可以监控对外部 HTTP 服务的访问,包括每次访问的 HTTP 相关信息。</p></li></ol><h3 id=配置外部-https-服务>配置外部 HTTPS 服务</h3><ol><li><p>创建一个 <code>ServiceEntry</code> 以允许访问外部 HTTPS 服务。</p><pre><code class=language-bash data-expandlinks=true>$ kubectl apply -f - <<EOF
|
||
apiVersion: networking.istio.io/v1alpha3
|
||
kind: ServiceEntry
|
||
metadata:
|
||
name: google
|
||
spec:
|
||
hosts:
|
||
- www.google.com
|
||
ports:
|
||
- number: 443
|
||
name: https
|
||
protocol: HTTPS
|
||
resolution: DNS
|
||
location: MESH_EXTERNAL
|
||
EOF
|
||
</code></pre></li><li><p>从 <code>SOURCE_POD</code> 向外部 HTTPS 服务发出请求:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep -- curl -I https://www.google.com | grep "HTTP/"
|
||
HTTP/2 200
|
||
</code></pre></li><li><p>检查 <code>SOURCE_POD</code> 的 sidecar 代理的日志:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl logs $SOURCE_POD -c istio-proxy | tail
|
||
[2019-01-24T12:48:54.977Z] "- - -" 0 - 601 17766 1289 - "-" "-" "-" "-" "172.217.161.36:443" outbound|443||www.google.com 172.30.109.82:59480 172.217.161.36:443 172.30.109.82:59478 www.google.com
|
||
</code></pre><p>请注意与您对 <code>www.google.com</code> 的 HTTPS 请求相关的条目。</p></li><li><p>检查 Mixer 日志。如果 Istio 部署在 <code>istio-system</code> 命名空间中,则打印日志的命令是:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl -n istio-system logs -l istio-mixer-type=telemetry -c mixer | grep 'www.google.com'
|
||
{"level":"info","time":"2019-01-24T12:48:56.266553Z","instance":"tcpaccesslog.logentry.istio-system","connectionDuration":"1.289085134s","connectionEvent":"close","connection_security_policy":"unknown","destinationApp":"","destinationIp":"rNmhJA==","destinationName":"unknown","destinationNamespace":"default","destinationOwner":"unknown","destinationPrincipal":"","destinationServiceHost":"www.google.com","destinationWorkload":"unknown","protocol":"tcp","receivedBytes":601,"reporter":"source","requestedServerName":"www.google.com","sentBytes":17766,"sourceApp":"sleep","sourceIp":"rB5tUg==","sourceName":"sleep-88ddbcfdd-rgk77","sourceNamespace":"default","sourceOwner":"kubernetes://apis/apps/v1/namespaces/default/deployments/sleep","sourcePrincipal":"","sourceWorkload":"sleep","totalReceivedBytes":601,"totalSentBytes":17766}
|
||
</code></pre><p>请注意,<code>requestedServerName</code> 属性等于 <code>www.google.com</code>。 使用 Istio 出口流量控制,您可以监控对外部 HTTPS 服务的访问,特别是 <a href=https://en.wikipedia.org/wiki/Server_Name_Indication>SNI</a> 以及发送和接收的字节数。 请注意,在 HTTPS 中,所有与 HTTP 相关的信息(如方法,URL 路径,响应代码)都已加密,因此 Istio 无法查看,也无法监控 HTTPS 的信息。 如果您需要在访问外部时监视与 HTTP 相关的信息
|
||
HTTPS 服务,您可能希望让您的应用程序发出 HTTP 请求
|
||
<a href=/v1.1/docs/examples/advanced-gateways/egress-tls-origination/>配置 Istio 以执行 TLS</a>。</p></li></ol><h3 id=管理外部服务的流量>管理外部服务的流量</h3><p>通过 <code>ServiceEntry</code> 访问外部服务的流量,和网格内流量类似,都可以进行 Istio <a href=/v1.1/zh/docs/concepts/traffic-management/#规则配置>路由规则</a> 的配置。下面我们使用 <a href=/v1.1/zh/docs/reference/commands/istioctl/><code>istioctl</code></a> 为 httpbin.org 服务设置一个超时规则。</p><ol><li><p>在测试 Pod 内部,使用 <code>curl</code> 调用 httpbin.org 这一外部服务的 <code>/delay</code> 端点:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep sh
|
||
$ time curl -o /dev/null -s -w "%{http_code}\n" http://httpbin.org/delay/5
|
||
200
|
||
|
||
real 0m5.024s
|
||
user 0m0.003s
|
||
sys 0m0.003s
|
||
</code></pre><p>这个请求会在大概五秒钟左右返回一个内容为 <code>200 (OK)</code> 的响应。</p></li><li><p>退出测试 Pod,使用 <code>kubectl</code> 为 httpbin.org 外部服务的访问设置一个 3 秒钟的超时:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl apply -f - <<EOF
|
||
apiVersion: networking.istio.io/v1alpha3
|
||
kind: VirtualService
|
||
metadata:
|
||
name: httpbin-ext
|
||
spec:
|
||
hosts:
|
||
- httpbin.org
|
||
http:
|
||
- timeout: 3s
|
||
route:
|
||
- destination:
|
||
host: httpbin.org
|
||
weight: 100
|
||
EOF
|
||
</code></pre></li><li><p>等待几秒钟之后,再次发起 <em>curl</em> 请求:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl exec -it $SOURCE_POD -c sleep sh
|
||
$ time curl -o /dev/null -s -w "%{http_code}\n" http://httpbin.org/delay/5
|
||
504
|
||
|
||
real 0m3.149s
|
||
user 0m0.004s
|
||
sys 0m0.004s
|
||
</code></pre><p>这一次会在 3 秒钟之后收到一个内容为 <code>504 (Gateway Timeout)</code> 的响应。虽然 httpbin.org 还在等待他的 5 秒钟,Istio 却在 3 秒钟的时候切断了请求。</p></li></ol><h3 id=清除对外部服务的受控访问>清除对外部服务的受控访问</h3><pre><code class=language-bash data-expandlinks=true>$ kubectl delete serviceentry httpbin-ext google
|
||
$ kubectl delete virtualservice httpbin-ext --ignore-not-found=true
|
||
</code></pre><h2 id=直接调用外部服务>直接调用外部服务</h2><p>如果想要跳过 Istio,直接访问某个 IP 范围内的外部服务,就需要对 Envoy sidecar 进行配置,阻止 Envoy 对外部请求的<a href=/v1.1/zh/docs/concepts/traffic-management/#服务之间的通讯>劫持</a>。可以在 <a href=/v1.1/zh/docs/reference/config/installation-options/>Helm</a> 中设置 <code>global.proxy.includeIPRanges</code> 变量,然后使用 <code>kubectl apply</code> 命令来更新名为 <code>istio-sidecar-injector</code> 的 <code>Configmap</code>。在 <code>istio-sidecar-injector</code> 更新之后,<code>global.proxy.includeIPRanges</code> 会在所有未来部署的 Pod 中生效。</p><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-warning"/></svg></div><div class=content>与<a href=#Envoy-配置外部服务>Envoy 配置外部服务</a>不同,它使用 <code>ALLOW_ANY</code> 流量策略指示 Istio sidecar 代理通过对未知服务的调用,这种方法完全绕过了 sidecar,基本上禁用指定 IP 的所有 Istio 功能。
|
||
您无法使用 <code>ALLOW_ANY</code> 方法逐步添加特定目标的服务条目。
|
||
因此,此配置方法仅建议作为最后的手段当出于性能或其他原因,无法使用 sidecar 配置外部访问。</div></aside></div><p>排除所有外部 IP 重定向到 sidecar 代理的一种简单方法是将 <code>global.proxy.includeIPRanges</code> 配置选项设置为用于内部集群服务的 IP 范围。这些 IP 范围值取决于群集运行的平台。</p><h3 id=确定平台的内部-ip-范围>确定平台的内部 IP 范围</h3><p>根据集群部署情况为 <code>global.proxy.includeIPRanges</code> 赋值。</p><h4 id=ibm-cloud-private>IBM Cloud Private</h4><ol><li><p>从 IBM Cloud Private 配置文件(<code>cluster/config.yaml</code>)中获取 <code>service_cluster_ip_range</code>。</p><pre><code class=language-bash data-expandlinks=true>$ cat cluster/config.yaml | grep service_cluster_ip_range
|
||
</code></pre><p>会输出类似内容:</p><pre><code class=language-plain data-expandlinks=true>service_cluster_ip_range: 10.0.0.1/24
|
||
</code></pre></li><li><p>使用 <code>--set global.proxy.includeIPRanges="10.0.0.1/24"</code></p></li></ol><h4 id=ibm-cloud-kubernetes-service>IBM Cloud Kubernetes Service</h4><p>使用 <code>--set global.proxy.includeIPRanges="172.30.0.0/16\,172.21.0.0/16\,10.10.10.0/24"</code></p><h4 id=google-container-engine-gke>Google Container Engine (GKE)</h4><p>这个范围是不确定的,所以需要运行 <code>gcloud container clusters describe</code> 命令来获取范围的具体定义,例如:</p><pre><code class=language-bash data-expandlinks=true>$ gcloud container clusters describe XXXXXXX --zone=XXXXXX | grep -e clusterIpv4Cidr -e servicesIpv4Cidr
|
||
clusterIpv4Cidr: 10.4.0.0/14
|
||
servicesIpv4Cidr: 10.7.240.0/20
|
||
</code></pre><p>使用 <code>--set global.proxy.includeIPRanges="10.4.0.0/14\,10.7.240.0/20"</code></p><h4 id=azure-container-service-acs>Azure Container Service(ACS)</h4><p>使用 <code>--set global.proxy.includeIPRanges="10.244.0.0/16\,10.240.0.0/16</code></p><h4 id=minikube-docker-for-desktop-bare-metal>Minikube, Docker For Desktop, Bare Metal</h4><p>它没有固定值,但默认值为 10.96.0.0/12 。要确定您的实际值:</p><pre><code class=language-bash data-expandlinks=true>$ kubectl describe pod kube-apiserver -n kube-system | grep 'service-cluster-ip-range'
|
||
--service-cluster-ip-range=10.96.0.0/12
|
||
</code></pre><p>使用 <code>--set global.proxy.includeIPRanges="10.96.0.0/12"</code></p><h3 id=配置代理绕过>配置代理绕过</h3><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-warning"/></svg></div><div class=content>删除以前在本指南中部署的服务条目和虚拟服务。</div></aside></div><p>使用特定于您平台的 IP 范围更新 <code>istio-sidecar-injector</code> configmap。
|
||
例如,假设范围是 10.0.0.1/24,请使用以下命令:</p><pre><code class=language-bash data-expandlinks=true>$ helm template install/kubernetes/helm/istio <the flags you used to install Istio> --set global.proxy.includeIPRanges="10.0.0.1/24" -x templates/sidecar-injector-configmap.yaml | kubectl apply -f -
|
||
</code></pre><p>使用您以前使用的相同 Helm 命令<a href=/v1.1/docs/setup/kubernetes/install/helm>安装 Istio</a>,
|
||
特别,确保为 <code>--namespace</code> 标志使用相同的值
|
||
添加这些标志: <code>--set global.proxy.includeIPRanges="10.0.0.1/24" -x templates/sidecar-injector-configmap.yaml</code>。</p><h3 id=访问外部服务>访问外部服务</h3><p>由于旁路配置仅影响新部署,因此需要按照<a href=#开始之前>开始之前</a>部分中的说明重新部署 <code>sleep</code> 应用程序。</p><p>更新了 <code>ConfigMap</code> <code>istio-sidecar-injector</code> 并且重新部署了 <code>sleep</code> 应用之后,Istio sidecar 就应该只劫持和管理集群内部的请求了。任意的外部请求都会简单的绕过 Sidecar,直接访问目的地址。</p><pre><code class=language-bash data-expandlinks=true>$ export SOURCE_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
||
$ kubectl exec -it $SOURCE_POD -c sleep curl http://httpbin.org/headers
|
||
{
|
||
"headers": {
|
||
"Accept": "*/*",
|
||
"Connection": "close",
|
||
"Host": "httpbin.org",
|
||
"User-Agent": "curl/7.60.0"
|
||
}
|
||
}
|
||
</code></pre><p>与通过 HTTP 或 HTTPS 访问外部服务不同,您看不到与 Istio sidecar 相关的任何 header ,并且发送到外部服务的请求既不出现在 sidecar 的日志中,也不出现在 Mixer 日志中。
|
||
绕过 Istio sidecar 意味着您无法再监控对外部服务的访问。</p><h3 id=清除对外部服务的直接访问>清除对外部服务的直接访问</h3><p>更新 <code>istio-sidecar-injector.configmap.yaml</code> configmap 以将所有出站流量重定向到 sidecar 代理:</p><pre><code class=language-bash data-expandlinks=true>$ helm template install/kubernetes/helm/istio <the flags you used to install Istio> -x templates/sidecar-injector-configmap.yaml | kubectl apply -f -
|
||
</code></pre><h2 id=理解原理>理解原理</h2><p>这个任务中,我们使用两种方式从 Istio 服务网格内部来完成对外部服务的调用:</p><ol><li><p>使用 <code>ServiceEntry</code> (推荐方式)</p></li><li><p>配置 Istio sidecar,从它的重定向 IP 表中排除外部服务的 IP 范围</p></li></ol><p>第一种方式(<code>ServiceEntry</code>)中,网格内部的服务不论是访问内部还是外部的服务,都可以使用同样的 Istio 服务网格的特性。我们通过为外部服务访问设置超时规则的例子,来证实了这一优势。</p><p>第二种方式越过了 Istio sidecar proxy,让服务直接访问到对应的外部地址。然而要进行这种配置,需要了解云供应商特定的知识和配置。</p><h2 id=安全说明>安全说明</h2><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.1/img/icons.svg#callout-warning"/></svg></div><div class=content>请注意,此任务中的配置示例<strong>不会在 Istio 中启用安全出口流量控制</strong>。
|
||
恶意应用程序可以绕过 Istio sidecar 代理并在没有 Istio 控制的情况下访问任何外部服务。</div></aside></div><p>要以更安全的方式实施出口流量控制,您必须<a href=/v1.1/docs/examples/advanced-gateways/egress-gateway>通过出口网关指示出口流量</a>,并查看本节中描述的安全性<a href=/v1.1/docs/examples/advanced-gateways/egress-gateway#additional-security-considerations>附加安全性考虑因素</a>。</p><h2 id=清理>清理</h2><p>停止 <a href=https://github.com/istio/istio/tree/release-1.1/samples/sleep>sleep</a> 服务:</p><div><a data-skipendnotes=true style=display:none href=https://raw.githubusercontent.com/istio/istio/release-1.1/samples/sleep/sleep.yaml>Zip</a><pre><code class=language-bash data-expandlinks=true>$ kubectl delete -f @samples/sleep/sleep.yaml@
|
||
</code></pre></div><nav id=see-also><h2>相关内容</h2><div class=see-also><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/blog/2019/egress-performance/>Egress gateway 性能测试</a></p><p class=desc>评估加入 Egress gateway 对性能造成的影响。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/blog/2018/egress-mongo/>使用外部 MongoDB 服务</a></p><p class=desc>描述了一个基于 Istio 的 Bookinfo 示例的简单场景。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/blog/2018/egress-monitoring-access-control/>HTTP Egress 流量监控和访问策略</a></p><p class=desc>描述如何配置 Istio 进行 HTTP Egress 流量监控和访问策略。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/blog/2018/egress-tcp/>使用外部 TCP 服务</a></p><p class=desc>描述基于 Istio 的 Bookinfo 示例的简单场景。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/blog/2018/egress-https/>使用外部 Web 服务</a></p><p class=desc>描述基于 Istio Bookinfo 示例的简单场景。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/examples/advanced-gateways/egress_sni_monitoring_and_policies/>Egress TLS 流量中的 SNI 监控及策略</a></p><p class=desc>如何为 Egress TLS 流量配置 SNI 监控并应用策略。</p></div></div></nav></article><nav class=pagenav><div class=left><a title="介绍在服务网格 Istio 中如何配置外部公开服务。" href=/v1.1/zh/docs/tasks/traffic-management/ingress/><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#left-arrow"/></svg>控制 Ingress 流量</a></div><div class=right><a title=用连接、请求以及外部检测来进行熔断配置的过程。 href=/v1.1/zh/docs/tasks/traffic-management/circuit-breaking/>熔断<svg class="icon"><use xlink:href="/v1.1/img/icons.svg#right-arrow"/></svg></a></div></nav><div id=endnotes-container aria-hidden=true><h2>链接</h2><ol id=endnotes></ol></div></div><div class=toc-container><nav class=toc aria-label="Table of Contents"><div id=toc><ol><li role=none aria-label=开始之前><a href=#%e5%bc%80%e5%a7%8b%e4%b9%8b%e5%89%8d>开始之前</a><li role=none aria-label="Envoy 配置外部服务"><a href=#envoy-%e9%85%8d%e7%bd%ae%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>Envoy 配置外部服务</a><ol><li role=none aria-label=控制外部服务><a href=#%e6%8e%a7%e5%88%b6%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>控制外部服务</a><li role=none aria-label=修改为默认阻止策略><a href=#%e4%bf%ae%e6%94%b9%e4%b8%ba%e9%bb%98%e8%ae%a4%e9%98%bb%e6%ad%a2%e7%ad%96%e7%95%a5>修改为默认阻止策略</a><li role=none aria-label="访问外部 HTTP 服务"><a href=#%e8%ae%bf%e9%97%ae%e5%a4%96%e9%83%a8-http-%e6%9c%8d%e5%8a%a1>访问外部 HTTP 服务</a><li role=none aria-label="配置外部 HTTPS 服务"><a href=#%e9%85%8d%e7%bd%ae%e5%a4%96%e9%83%a8-https-%e6%9c%8d%e5%8a%a1>配置外部 HTTPS 服务</a><li role=none aria-label=管理外部服务的流量><a href=#%e7%ae%a1%e7%90%86%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e6%b5%81%e9%87%8f>管理外部服务的流量</a><li role=none aria-label=清除对外部服务的受控访问><a href=#%e6%b8%85%e9%99%a4%e5%af%b9%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e5%8f%97%e6%8e%a7%e8%ae%bf%e9%97%ae>清除对外部服务的受控访问</a></ol></li><li role=none aria-label=直接调用外部服务><a href=#%e7%9b%b4%e6%8e%a5%e8%b0%83%e7%94%a8%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>直接调用外部服务</a><ol><li role=none aria-label="确定平台的内部 IP 范围"><a href=#%e7%a1%ae%e5%ae%9a%e5%b9%b3%e5%8f%b0%e7%9a%84%e5%86%85%e9%83%a8-ip-%e8%8c%83%e5%9b%b4>确定平台的内部 IP 范围</a><ol><li role=none aria-label="IBM Cloud Private"><a href=#ibm-cloud-private>IBM Cloud Private</a><li role=none aria-label="IBM Cloud Kubernetes Service"><a href=#ibm-cloud-kubernetes-service>IBM Cloud Kubernetes Service</a><li role=none aria-label="Google Container Engine (GKE)"><a href=#google-container-engine-gke>Google Container Engine (GKE)</a><li role=none aria-label="Azure Container Service(ACS)"><a href=#azure-container-service-acs>Azure Container Service(ACS)</a><li role=none aria-label="Minikube, Docker For Desktop, Bare Metal"><a href=#minikube-docker-for-desktop-bare-metal>Minikube, Docker For Desktop, Bare Metal</a></ol></li><li role=none aria-label=配置代理绕过><a href=#%e9%85%8d%e7%bd%ae%e4%bb%a3%e7%90%86%e7%bb%95%e8%bf%87>配置代理绕过</a><li role=none aria-label=访问外部服务><a href=#%e8%ae%bf%e9%97%ae%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1>访问外部服务</a><li role=none aria-label=清除对外部服务的直接访问><a href=#%e6%b8%85%e9%99%a4%e5%af%b9%e5%a4%96%e9%83%a8%e6%9c%8d%e5%8a%a1%e7%9a%84%e7%9b%b4%e6%8e%a5%e8%ae%bf%e9%97%ae>清除对外部服务的直接访问</a></ol></li><li role=none aria-label=理解原理><a href=#%e7%90%86%e8%a7%a3%e5%8e%9f%e7%90%86>理解原理</a><li role=none aria-label=安全说明><a href=#%e5%ae%89%e5%85%a8%e8%af%b4%e6%98%8e>安全说明</a><li role=none aria-label=清理><a href=#%e6%b8%85%e7%90%86>清理</a><li role=none aria-label=相关内容><a href=#see-also>相关内容</a></li></ol></div></nav></div></main><footer><div class=user-links><a class=channel title="Go download Istio 1.1.9 now" href=https://github.com/istio/istio/releases/tag/1.1.9 aria-label="Download Istio"><span>download</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#download"/></svg>
|
||
</a><a class=channel title="加入 Istio discussion board 参与讨论获取帮助" href=https://discuss.istio.io aria-label="Istio discussion board"><span>discuss</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#discourse"/></svg></a>
|
||
<a class=channel title="Stack Overflow 中列举了针对实际问题以及部署、配置和使用 Istio 的各项回答" href=https://stackoverflow.com/questions/tagged/istio aria-label="Stack Overflow"><span>stack overflow</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#stackoverflow"/></svg></a>
|
||
<a class=channel title="关注我们的 Twitter 来获取最新信息" href=https://twitter.com/IstioMesh aria-label=Twitter><span>twitter</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#twitter"/></svg></a><div class=tag>对于用户</div></div><div class=info><p class=copyright>中文内容由 ServiceMesher 社区维护,部分文档可能稍微滞后于英文版本,同步工作持续进行中<br>Istio 归档
|
||
1.1.9<br>© 2019 Istio Authors, <a href=https://policies.google.com/privacy>隐私政策</a><br>归档于 2019年6月18日</p></div><div class=dev-links><a class=channel title="Istio 的代码在 GitHub 上开发" href=https://github.com/istio/community aria-label=GitHub><span>github</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#github"/></svg></a>
|
||
<a class=channel title="在 Slack 上与 Istio 社区交互讨论开发问题(仅限邀请)" href=https://istio.slack.com aria-label=slack><span>slack</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#slack"/></svg></a>
|
||
<a class=channel title="如果您想深入了解 Istio 的技术细节,请查看我们日益完善的设计文档" href=https://groups.google.com/forum/#!forum/istio-team-drive-access aria-label="team drive"><span>drive</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#drive"/></svg></a>
|
||
<a class=channel title="如果您想为 Istio 项目做出贡献,请考虑加入我们的工作组" href=https://github.com/istio/community/blob/master/WORKING-GROUPS.md aria-label="working groups"><span>working groups</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#working-groups"/></svg></a><div class=tag>对于开发者</div></div></footer><div id=scroll-to-top-container aria-hidden=true><button id=scroll-to-top title=回到顶部><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#top"/></svg></button></div></body></html> |