mirror of https://github.com/istio/istio.io.git
125 lines
44 KiB
HTML
125 lines
44 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="Istio 的软性多租户支持"><meta name=description content="使用 Kubernetes 命名空间和 RBAC 为 Istio 构建软性多租户环境。"><meta name=author content="John Joyce 和 Rich Curran"><meta name=keywords content="microservices,services,mesh,tenancy"><meta property="og:title" content="Istio 的软性多租户支持"><meta property="og:type" content="website"><meta property="og:description" content="使用 Kubernetes 命名空间和 RBAC 为 Istio 构建软性多租户环境。"><meta property="og:url" content="/v1.5/zh/blog/2018/soft-multitenancy/"><meta property="og:image" content="/v1.5/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.5 / Istio 的软性多租户支持</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.5/blog/feed.xml><link rel=alternate type=application/rss+xml title="Istio News" href=/v1.5/news/feed.xml><link rel=alternate type=application/rss+xml title="Istio Blog and News" href=/v1.5/feed.xml><link rel="shortcut icon" href=/v1.5/favicons/favicon.ico><link rel=apple-touch-icon href=/v1.5/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/v1.5/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/v1.5/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/v1.5/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/v1.5/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/v1.5/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/v1.5/favicons/android-96x96.png sizes=96xW96><link rel=icon type=image/png href=/v1.5/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/v1.5/favicons/android-192x192.png sizes=192x192><link rel=manifest href=/v1.5/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.5/css/all.css><script src=/v1.5/js/themes_init.min.js></script></head><body class="language-unknown archive-site"><script>const branchName="release-1.5";const docTitle="Istio 的软性多租户支持";const iconFile="\/v1.5/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.5/js/all.min.js data-manual defer></script><header><nav><a id=brand href=/v1.5/zh/><span class=logo><svg viewBox="0 0 300 300"><circle cx="150" cy="150" r="146" stroke-width="2"/><polygon points="65 240 225 240 125 270"/><polygon points="65 230 125 220 125 110"/><polygon points="135 220 225 230 135 30"/></svg></span><span class=name>Istioldie 1.5</span></a><div id=hamburger><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#hamburger"/></svg></div><div id=header-links><a title="了解如何部署、使用和运维 Istio。" href=/v1.5/zh/docs/>文档</a>
|
||
<a class=current title="关于使用 Istio 的博客文章。" href=/v1.5/zh/blog/2020/>博客<i class=dot data-prefix=/blog></i></a>
|
||
<a title="关于 Istio 项目的最新报道。" href=/v1.5/zh/news/>新闻<i class=dot data-prefix=/news></i></a>
|
||
<a title="关于 Istio 的常见问题。" href=/v1.5/zh/faq/>FAQ</a>
|
||
<a title="关于 Istio 项目的说明。" href=/v1.5/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.5/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/blog\/2018\/soft-multitenancy\/');return false;">当前版本</a>
|
||
<a tabindex=-1 role=menuitem onclick="navigateToUrlOrRoot('https://preliminary.istio.io/blog\/2018\/soft-multitenancy\/');return false;">下个版本</a>
|
||
<a tabindex=-1 role=menuitem href=https://istio.io/archive>旧版本</a></div></div><button id=search-show title="搜索 istio.io" aria-label=搜索><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#magnifier"/></svg></button></div><form id=search-form name=cse role=search><input type=hidden name=cx value=002184991200833970123: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.5/search>
|
||
<input id=search-textbox class=form-control name=q type=search aria-label="搜索 istio.io">
|
||
<button id=search-close title=取消搜索 type=reset aria-label=取消搜索><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#cancel-x"/></svg></button></form></nav></header><div class=banner-container></div><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=card0 title="2020 年的博客文章。" aria-controls=card0-body><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#blog"/></svg>2020 年的博客文章</button><div class=body aria-labelledby=card0 role=region id=card0-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card0><li role=none><a role=treeitem title="Istio 的扩展中使用 WASM 的前景。 (2020年3月5日)" href=/v1.5/zh/blog/2020/wasm-announce/>重新定义代理的扩展性:Envoy 和 Istio 引入 WebAssembly</a></li><li role=none><a role=treeitem title="Istio 在 2020 年的愿景声明及路线图。 (2020年3月3日)" href=/v1.5/zh/blog/2020/tradewinds-2020/>Istio 2020——为了商用</a></li><li role=none><a role=treeitem title="一种更安全的秘密管理方式。 (2020年2月20日)" href=/v1.5/zh/blog/2020/istio-agent/>移除跨 pod Unix domain socket</a></li><li role=none><a role=treeitem title="为 Istio deployment(cluster)提供自动化 Istio 配置,并让其像单个网格一样工作。 (2020年1月5日)" href=/v1.5/zh/blog/2020/multi-cluster-mesh-automation/>使用 Admiral 管理 Istio 多集群的配置和服务发现</a></li></ul></div></div><div class=card><button class="header dynamic" id=card1 title="2019 年的博客文章。" aria-controls=card1-body><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#blog"/></svg>2019 年的博客文章</button><div class=body aria-labelledby=card1 role=region id=card1-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card1><li role=none><a role=treeitem title="一种更安全管理 Istio webhook 的方法。 (2019年11月14日)" href=/v1.5/zh/blog/2019/webhook/>安全管理 Webhook</a></li><li role=none><a role=treeitem title="关于 Istio 基于 operator 的安装和控制平面管理特性的介绍。 (2019年11月14日)" href=/v1.5/zh/blog/2019/introducing-istio-operator/>Istio Operator 简介</a></li><li role=none><a role=treeitem title="Istio v1beta1 授权策略的设计原则、基本概述及迁移操作。 (2019年11月14日)" href=/v1.5/zh/blog/2019/v1beta1-authorization-policy/>Istio v1beta1 授权策略概述</a></li><li role=none><a role=treeitem title="通过分析 Istio 配置来发现潜在问题和一般问题。 (2019年11月14日)" href=/v1.5/zh/blog/2019/introducing-istioctl-analyze/>istioctl analyze 介绍</a></li><li role=none><a role=treeitem title="在 Istio 中配置和管理 DNS 证书。 (2019年11月14日)" href=/v1.5/zh/blog/2019/dns-cert/>DNS 证书管理</a></li><li role=none><a role=treeitem title="正式启用访问 Istio 资源。 (2019年11月14日)" href=/v1.5/zh/blog/2019/announcing-istio-client-go/>Istio client-go 发布公告</a></li><li role=none><a role=treeitem title="把 Istio 入口网关配置为外部服务的代理。 (2019年10月15日)" href=/v1.5/zh/blog/2019/proxy/>把 Istio 作为外部服务的代理</a></li><li role=none><a role=treeitem title="将需要隔离的环境部署到单独的网格中,并通过网格联邦启用网格间通信。 (2019年10月2日)" href=/v1.5/zh/blog/2019/isolated-clusters/>用于隔离和边界保护的多网格部署</a></li><li role=none><a role=treeitem title="如何使用 Istio 去监控被阻止的和透传的外部服务流量。 (2019年9月28日)" href=/v1.5/zh/blog/2019/monitoring-external-service-traffic/>监控被阻止的和透传的外部服务流量</a></li><li role=none><a role=treeitem title="本文演示 Mixer 进程外适配器实现 Knative scale-from-zero 逻辑的具体过程。 (2019年9月18日)" href=/v1.5/zh/blog/2019/knative-activator-adapter/>适用于 Knative 的 Mixer 适配器</a></li><li role=none><a role=treeitem title="使用 Istio 实现零代码改动保护多云 Kubernetes 应用。 (2019年9月18日)" href=/v1.5/zh/blog/2019/app-identity-and-access-adapter/>APP 身份和访问适配器</a></li><li role=none><a role=treeitem title="利用 Kubernetes 可信任的 JWT 来更安全地为工作负载实例颁发证书。 (2019年9月10日)" href=/v1.5/zh/blog/2019/trustworthy-jwt-sds/>Istio 1.3 Secret 服务发现的更改</a></li><li role=none><a role=treeitem title="Istio API 的设计原则和这些 API 是如何演变的。 (2019年8月5日)" href=/v1.5/zh/blog/2019/evolving-istios-apis/>Istio API 的演变</a></li><li role=none><a role=treeitem title="管控出口流量的备选方案比较,包括性能因素。 (2019年7月22日)" href=/v1.5/zh/blog/2019/egress-traffic-control-in-istio-part-3/>Istio 中安全管控出口流量,第三部分</a></li><li role=none><a role=treeitem title="使用 Istio 的出口流量管控来阻止相关出口流量攻击。 (2019年7月10日)" href=/v1.5/zh/blog/2019/egress-traffic-control-in-istio-part-2/>Istio 中的安全管控出口流量,第二部分</a></li><li role=none><a role=treeitem title="评估 Istio 数据平面性能的工具和指南。 (2019年7月9日)" href=/v1.5/zh/blog/2019/performance-best-practices/>最佳实践:Service Mesh 基准性能测试</a></li><li role=none><a role=treeitem title="了解如何延长 Istio 自签名根证书的有效期。 (2019年6月7日)" href=/v1.5/zh/blog/2019/root-transition/>延长 Istio 自签名根证书的有效期</a></li><li role=none><a role=treeitem title="涉及出口流量攻击和出口流量管控要求。 (2019年5月22日)" href=/v1.5/zh/blog/2019/egress-traffic-control-in-istio-part-1/>Istio 中的安全管控出口流量,第一部分</a></li><li role=none><a role=treeitem title="Istio 1.1 性能概览。 (2019年3月19日)" href=/v1.5/zh/blog/2019/istio1.1_perf/>为性能而设计的 Istio 1.1</a></li><li role=none><a role=treeitem title="在多集群服务网格环境中配置 Istio 的路由规则。 (2019年2月7日)" href=/v1.5/zh/blog/2019/multicluster-version-routing/>多集群服务网格中的分版本路由</a></li><li role=none><a role=treeitem title="宣布新的博客策略。 (2019年2月5日)" href=/v1.5/zh/blog/2019/sail-the-blog/>博客策略更新!</a></li><li role=none><a role=treeitem title="揭秘 Istio 是如何将其数据平面组件添加到现有 deployment。 (2019年1月31日)" href=/v1.5/zh/blog/2019/data-plane-setup/>揭开 Istio Sidecar 注入模型的神秘面纱</a></li><li role=none><a role=treeitem title="评估加入 Egress gateway 对性能造成的影响。 (2019年1月31日)" href=/v1.5/zh/blog/2019/egress-performance/>Egress gateway 性能测试</a></li><li role=none><a role=treeitem title="使用 AppSwitch 解决应用程序启动顺序和启动延迟。 (2019年1月14日)" href=/v1.5/zh/blog/2019/appswitch/>使用 AppSwitch 进行 Sidestepping 依赖性排序</a></li><li role=none><a role=treeitem title="Istio 有了一个新的论坛。 (2019年1月10日)" href=/v1.5/zh/blog/2019/announcing-discuss.istio.io/>Istio 论坛成立</a></li><li role=none><a role=treeitem title="如何使用 cert-manager 手工部署一个自定义 Ingress 网关。 (2019年1月10日)" href=/v1.5/zh/blog/2019/custom-ingress-gateway/>使用 Cert-Manager 部署一个自定义 Ingress 网关</a></li></ul></div></div><div class=card><button class="header dynamic" id=card2 title="2018 年的博客文章。" aria-controls=card2-body><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#blog"/></svg>2018 年的博客文章</button><div class="body default" aria-labelledby=card2 role=region id=card2-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card2><li role=none><a role=treeitem title="如何在不部署 Sidecar 代理的情况下使用 Istio 进行流量管理。 (2018年11月21日)" href=/v1.5/zh/blog/2018/incremental-traffic-management/>增量式应用 Istio 第一部分,流量管理</a></li><li role=none><a role=treeitem title="描述了一个基于 Istio 的 Bookinfo 示例的简单场景。 (2018年11月16日)" href=/v1.5/zh/blog/2018/egress-mongo/>使用外部 MongoDB 服务</a></li><li role=none><a role=treeitem title="Istio 在 Twitch 举办了为期一天的直播庆祝 1.0 的发布。 (2018年8月3日)" href=/v1.5/zh/blog/2018/istio-twitch-stream/>Istio 在 Twitch 上全天直播</a></li><li role=none><a role=treeitem title="惠普如何在 Istio 上构建其下一代鞋类个性化平台。 (2018年7月31日)" href=/v1.5/zh/blog/2018/hp/>Istio 是惠普 FitStation 平台的改变者</a></li><li role=none><a role=treeitem title="使用 AppSwitch 自动接入应用并降低延迟。 (2018年7月30日)" href=/v1.5/zh/blog/2018/delayering-istio/>使用 AppSwitch 精简 Istio 层次</a></li><li role=none><a role=treeitem title="描述 Istio 的授权功能以及如何在各种用例中使用它。 (2018年7月20日)" href=/v1.5/zh/blog/2018/istio-authorization/>基于 Istio 授权的 Micro-Segmentation</a></li><li role=none><a role=treeitem title="如何通过 Stackdriver 将 Istio 访问日志导出到 BigQuery、GCS、Pub/Sub 等不同的接收器。 (2018年7月9日)" href=/v1.5/zh/blog/2018/export-logs-through-stackdriver/>通过 Stackdriver 将日志导出到 BigQuery、GCS、Pub/Sub</a></li><li role=none><a role=treeitem title="描述如何配置 Istio 进行 HTTP Egress 流量监控和访问策略。 (2018年6月22日)" href=/v1.5/zh/blog/2018/egress-monitoring-access-control/>HTTP Egress 流量监控和访问策略</a></li><li role=none><a role=treeitem title="Istio v1alpha3 路由 API 介绍, 动机及其设计原则。 (2018年4月25日)" href=/v1.5/zh/blog/2018/v1alpha3-routing/>Istio v1aplha3 路由 API 介绍</a></li><li role=none><a role=treeitem title="描述如何在 AWS 上使用网络负载均衡器配置 Istio Ingress。 (2018年4月20日)" href=/v1.5/zh/blog/2018/aws-nlb/>使用 AWS NLB 配置 Istio Ingress</a></li><li role=none><span role=treeitem class=current title="使用 Kubernetes 命名空间和 RBAC 为 Istio 构建软性多租户环境。 (2018年4月19日)">Istio 的软性多租户支持</span></li><li role=none><a role=treeitem title="介绍更安全,低风险的部署和发布到生产。 (2018年2月8日)" href=/v1.5/zh/blog/2018/traffic-mirroring/>用于在生产环境进行测试的 Istio 流量镜像功能</a></li><li role=none><a role=treeitem title="描述基于 Istio 的 Bookinfo 示例的简单场景。 (2018年2月6日)" href=/v1.5/zh/blog/2018/egress-tcp/>使用外部 TCP 服务</a></li><li role=none><a role=treeitem title="描述基于 Istio Bookinfo 示例的简单场景。 (2018年1月31日)" href=/v1.5/zh/blog/2018/egress-https/>使用外部 Web 服务</a></li></ul></div></div><div class=card><button class="header dynamic" id=card3 title="2017 年的博客文章。" aria-controls=card3-body><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#blog"/></svg>2017 年的博客文章</button><div class=body aria-labelledby=card3 role=region id=card3-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card3><li role=none><a role=treeitem title="提高可用,降低延迟。 (2017年12月7日)" href=/v1.5/zh/blog/2017/mixer-spof-myth/>Mixer 和 SPOF 神话</a></li><li role=none><a role=treeitem title="概要说明 Mixer 的插件架构。 (2017年11月3日)" href=/v1.5/zh/blog/2017/adapter-model/>Mixer 适配器模型</a></li><li role=none><a role=treeitem title="Istio 的策略如何关联 Kubernetes 的网络策略 。 (2017年8月10日)" href=/v1.5/zh/blog/2017/0.1-using-network-policy/>Istio 使用网络策略</a></li><li role=none><a role=treeitem title="使用 Istio 创建自动缩放的金丝雀部署。 (2017年6月14日)" href=/v1.5/zh/blog/2017/0.1-canary/>使用 Istio 进行金丝雀部署</a></li><li role=none><a role=treeitem title="Istio Auth 0.1 公告。 (2017年5月25日)" href=/v1.5/zh/blog/2017/0.1-auth/>使用 Istio 增强端到端安全</a></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.5/img/icons.svg#pull"/></svg></button><nav aria-label=Breadcrumb><ol><li><a href=/v1.5/zh/ title=用于连接、保护、控制和观测服务。>Istio</a></li><li><a href=/v1.5/zh/blog/ title="关于使用 Istio 的博客文章。">博客</a></li><li><a href=/v1.5/zh/blog/2018/ title="2018 年的博客文章。">2018 年的博客文章</a></li><li>Istio 的软性多租户支持</li></ol></nav><article aria-labelledby=title><div class=title-area><div style=width:100%><h1 id=title>Istio 的软性多租户支持</h1><p class=subtitle>使用多个 Istio 控制平面和 RBAC 提供多租户支持</p><p class=byline><span>作者</span>
|
||
<span class=attribution>John Joyce 和 Rich Curran</span><span> | </span><span><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#calendar"/></svg><span> </span>2018年4月19日</span><span> | </span><span title="681 字"><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#clock"/></svg><span> </span>阅读大约需要 4 分钟</span></p></div></div><nav class=toc-inlined aria-label="Table of Contents"><div><hr><ol><li role=none aria-label=软性多租户><a href=#soft-multi-tenancy>软性多租户</a><li role=none aria-label=部署><a href=#deployment>部署</a><ol><li role=none aria-label="多个 Istio 控制面"><a href=#multiple-Istio-control-planes>多个 Istio 控制面</a><li role=none aria-label=区分通用资源和命名空间资源><a href=#split-common-and-namespace-specific-resources>区分通用资源和命名空间资源</a><li role=none aria-label="Istio 控制面的 Kubernetes RBAC 设置"><a href=#Kubernetes-rbac-for-Istio-control-plane-resources>Istio 控制面的 Kubernetes RBAC 设置</a><li role=none aria-label=关注特定命名空间进行服务发现><a href=#watching-specific-namespaces-for-service-discovery>关注特定命名空间进行服务发现</a><li role=none aria-label=在特定命名空间中部署租户应用><a href=#deploying-the-tenant-application-in-a-namespace>在特定命名空间中部署租户应用</a><li role=none aria-label="在多租户环境中使用 istioctl"><a href=#using-in-a-multi-tenant-environment>在多租户环境中使用 <code>istioctl</code></a><li role=none aria-label=测试结果><a href=#test-results>测试结果</a></ol></li><li role=none aria-label=结语><a href=#conclusion>结语</a><li role=none aria-label=问题><a href=#issues>问题</a><li role=none aria-label=其他多租户模型的挑战><a href=#challenges-with-other-multi-tenancy-models>其他多租户模型的挑战</a><li role=none aria-label=未来><a href=#future-work>未来</a><li role=none aria-label=参考><a href=#references>参考</a><li role=none aria-label=相关内容><a href=#see-also>相关内容</a></li></ol><hr></div></nav><div><aside class="callout warning"><div class=type><svg class="large-icon"><use xlink:href="/v1.5/img/icons.svg#callout-warning"/></svg></div><div class=content>该博客文章是在 Istio 0.7 的版本下编写的,因此其中某些内容现在可能已过时。</div></aside></div><p>多租户是一个在各种环境和各种应用中都得到了广泛应用的概念,但是不同环境中,为每租户提供的具体实现和功能性都是有差异的。<a href=https://github.com/kubernetes/community/blob/master/wg-multitenancy/README.md>Kubernetes 多租户工作组</a>致力于在 Kubernetes 中定义多租户用例和功能。然而根据他们的工作进展来看,恶意容器和负载对于其他租户的 Pod 和内核资源的访问无法做到完全控制,因此只有”软性多租户”支持是可行的。</p><h2 id=soft-multi-tenancy>软性多租户</h2><p>文中提到的”软性多租户”的定义指的是单一 Kubernetes 控制平面和多个 Istio 控制平面以及多个服务网格相结合;每个租户都有自己的一个控制平面和一个服务网格。集群管理员对所有 Istio 控制面都有控制和监控的能力,而租户管理员仅能得到指定 Istio 的控制权。使用 Kubernetes 的命名空间和 RBAC 来完成不同租户的隔离。</p><p>这种模式的一个用例就是企业内部共享的基础设施中,虽然预计不会发生恶意行为,但租户之间的清晰隔离仍然是很有必要的。</p><p>本文最后会对 Istio 未来的多租户模型进行一些描述。</p><div><aside class="callout tip"><div class=type><svg class="large-icon"><use xlink:href="/v1.5/img/icons.svg#callout-tip"/></svg></div><div class=content>这里仅就在有限多租户环境中部署 Istio 做一些概要描述。当官方多租户支持实现之后,会在<a href=/v1.5/zh/docs/>文档</a>中具体阐述。</div></aside></div><h2 id=deployment>部署</h2><h3 id=multiple-Istio-control-planes>多个 Istio 控制面</h3><p>要部署多个 Istio 控制面,首先要在 Istio 清单文件中对所有的 <code>namespace</code> 引用进行替换。以 <code>istio.yaml</code> 为例:如果需要两个租户级的 Istio 控制面,那么第一个租户可以使用 <code>istio.yaml</code> 中的缺省命名空间也就是 <code>istio-system</code>;而第二个租户就要生成一个新的 yaml 文件,并在其中使用不同的命名空间。例如使用下面的命令创建一个使用 <code>istio-system1</code> 命名空间的 yaml 文件:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ cat istio.yaml | sed s/istio-system/istio-system1/g > istio-system1.yaml
|
||
</code></pre><p><code>istio.yaml</code> 文件包含了 Istio 控制面的部署细节,包含组成控制面的 Pod(Mixer、Pilot、Ingress 以及 CA)。部署这两个控制面 yaml 文件:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl apply -f install/kubernetes/istio.yaml
|
||
$ kubectl apply -f install/kubernetes/istio-system1.yaml
|
||
</code></pre><p>会在两个命名空间生成两个 Istio 控制面</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods --all-namespaces
|
||
NAMESPACE NAME READY STATUS RESTARTS AGE
|
||
istio-system istio-ca-ffbb75c6f-98w6x 1/1 Running 0 15d
|
||
istio-system istio-ingress-68d65fc5c6-dnvfl 1/1 Running 0 15d
|
||
istio-system istio-mixer-5b9f8dffb5-8875r 3/3 Running 0 15d
|
||
istio-system istio-pilot-678fc976c8-b8tv6 2/2 Running 0 15d
|
||
istio-system1 istio-ca-5f496fdbcd-lqhlk 1/1 Running 0 15d
|
||
istio-system1 istio-ingress-68d65fc5c6-2vldg 1/1 Running 0 15d
|
||
istio-system1 istio-mixer-7d4f7b9968-66z44 3/3 Running 0 15d
|
||
istio-system1 istio-pilot-5bb6b7669c-779vb 2/2 Running 0 15d
|
||
</code></pre><p>如果需要 Istio <a href=/v1.5/zh/docs/setup/additional-setup/sidecar-injection/>Sidecar 注入组件</a>以及<a href=/v1.5/zh/docs/tasks/observability/>遥测组件</a>,也需要根据租户的命名空间定义,修改所需的 yaml 文件。</p><p>需要由集群管理员、而不是租户自己的管理员来加载这两组 yaml 文件。另外,要把租户管理员的操作权限限制在各自的命名空间内,还需要额外的 RBAC 配置。</p><h3 id=split-common-and-namespace-specific-resources>区分通用资源和命名空间资源</h3><p>Istio 仓库中的清单文件中会创建两种资源,一种是能够被所有 Istio 控制面访问的通用资源,另一种是每个控制平面一份的专属资源。上面所说的在 yaml 文件中替换 <code>istio-system</code> 命名空间的方法自然是很简单的,更好的一种方法就是把 yaml 文件拆分为两块,一块是所有租户共享的通用部分;另一块就是租户自有的部分。根据 <a href=https://kubernetes.io/docs/concepts/api-extension/custom-resources/#customresourcedefinitions>CRD 资源定义(Custom Resource Definitions)</a> 中的说法,角色和角色绑定资源需要从 Istio 文件中进行剥离。另外,清单文件中提供的角色和角色绑定的定义可能不适合多租户环境,还需要进一步的细化和定制。</p><h3 id=Kubernetes-rbac-for-Istio-control-plane-resources>Istio 控制面的 Kubernetes RBAC 设置</h3><p>租户管理员应该被限制在单独的 Istio 命名空间中,要完成这个限制,集群管理员需要创建一个清单,其中至少要包含一个 <code>Role</code> 和 <code>RoleBinding</code> 的定义,类似下面的文件所示。例子中定义了一个租户管理员,命名为 *sales-admin*,他被限制在命名空间 <code>istio-system1</code> 之中。完整的清单中可能要在 <code>Role</code> 中包含更多的 <code>apiGroups</code> 条目,来定义租户管理员的资源访问能力。</p><pre><code class=language-yaml data-expandlinks=true data-repo=istio>kind: Role
|
||
apiVersion: rbac.authorization.k8s.io/v1
|
||
metadata:
|
||
namespace: istio-system1
|
||
name: ns-access-for-sales-admin-istio-system1
|
||
rules:
|
||
- apiGroups: [""] # "" 代表核心 API 资源组
|
||
resources: ["*"]
|
||
verbs: ["*"]
|
||
---
|
||
kind: RoleBinding
|
||
apiVersion: rbac.authorization.k8s.io/v1
|
||
metadata:
|
||
name: access-all-istio-system1
|
||
namespace: istio-system1
|
||
subjects:
|
||
- kind: User
|
||
name: sales-admin
|
||
apiGroup: rbac.authorization.k8s.io
|
||
roleRef:
|
||
kind: Role
|
||
name: ns-access-for-sales-admin-istio-system1
|
||
apiGroup: rbac.authorization.k8s.io
|
||
</code></pre><h3 id=watching-specific-namespaces-for-service-discovery>关注特定命名空间进行服务发现</h3><p>除了创建 RBAC 规则来限制租户管理员只能访问指定 Istio 控制平面之外,Istio 清单还需要为 Istio Pilot 指定一个用于应用程序的命名空间,以便生成 xDS 缓存。Pilot 组件提供了命令行参数 <code>--appNamespace, ns-1</code> 可以完成这一任务。<em>ns-1</em> 就是租户用来部署自己应用的命名空间。<code>istio-system1.yaml</code> 中包含的相关代码大致如下:</p><pre><code class=language-yaml data-expandlinks=true data-repo=istio>apiVersion: extensions/v1beta1
|
||
kind: Deployment
|
||
metadata:
|
||
name: istio-pilot
|
||
namespace: istio-system1
|
||
annotations:
|
||
sidecar.istio.io/inject: "false"
|
||
spec:
|
||
replicas: 1
|
||
template:
|
||
metadata:
|
||
labels:
|
||
istio: pilot
|
||
spec:
|
||
serviceAccountName: istio-pilot-service-account
|
||
containers:
|
||
- name: discovery
|
||
image: docker.io/<user ID>/pilot:<tag>
|
||
imagePullPolicy: IfNotPresent
|
||
args: ["discovery", "-v", "2", "--admission-service", "istio-pilot", "--appNamespace", "ns-1"]
|
||
ports:
|
||
- containerPort: 8080
|
||
- containerPort: 443
|
||
</code></pre><h3 id=deploying-the-tenant-application-in-a-namespace>在特定命名空间中部署租户应用</h3><p>现在集群管理员已经给租户创建了命名空间(<code>istio-system1</code>),并且对 Istio Pilot 的服务发现进行了配置,要求它关注应用的命名空间(<code>ns-1</code>),创建应用的 yaml 文件,将其部署到租户的专属命名空间中:</p><pre><code class=language-yaml data-expandlinks=true data-repo=istio>apiVersion: v1
|
||
kind: Namespace
|
||
metadata:
|
||
name: ns-1
|
||
</code></pre><p>然后把每个资源的命名空间都指定到 <code>ns-1</code>,例如:</p><pre><code class=language-yaml data-expandlinks=true data-repo=istio>apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: details
|
||
labels:
|
||
app: details
|
||
namespace: ns-1
|
||
</code></pre><p>虽然没有展示出来,但是应用的命名空间也应该有 RBAC 设置,用来对特定资源进行访问控制。集群管理员和租户管理员都有权完成这种 RBAC 限制。</p><h3 id=using-in-a-multi-tenant-environment>在多租户环境中使用 <code>istioctl</code></h3><p>定义<a href=https://archive.istio.io/v0.7/docs/reference/config/istio.routing.v1alpha1/#RouteRule>路由规则</a>或者<a href=https://archive.istio.io/v0.7/docs/reference/config/istio.routing.v1alpha1/#DestinationPolicy>目标策略</a>时,要确认 <code>istioctl</code> 命令是针对专有的 Istio 控制面所在的命名空间运行的。另外规则自身的定义也要限制在租户的命名空间里,这样才能保证规则在租户自己的网格中生效。<em>-i</em> 选项用来在 Istio 控制面所属的命名空间中创建(get 和 describe 也一样)规则。<em>-n</em> 参数会限制规则的所在范围是租户的网格,取值就是租户应用所在的命名空间。如果 yaml 文件中的资源已经指定了范围,<em>-n</em> 参数会被跳过。</p><p>例如下面的命令会创建到 <code>istio-system1</code> 命名空间的路由规则:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl –i istio-system1 apply -n ns-1 -f route_rule_v2.yaml
|
||
</code></pre><p>用下面的命令可以查看:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl -i istio-system1 -n ns-1 get routerule
|
||
NAME KIND NAMESPACE
|
||
details-Default RouteRule.v1alpha2.config.istio.io ns-1
|
||
productpage-default RouteRule.v1alpha2.config.istio.io ns-1
|
||
ratings-default RouteRule.v1alpha2.config.istio.io ns-1
|
||
reviews-default RouteRule.v1alpha2.config.istio.io ns-1
|
||
</code></pre><p><a href=/v1.5/zh/blog/2018/soft-multitenancy/#multiple-Istio-control-planes>Multiple Istio control planes</a> 中讲述了更多多租户环境下 <code>命名空间</code> 的相关问题。</p><h3 id=test-results>测试结果</h3><p>根据前文的介绍,一个集群管理员能够创建一个受限于 RBAC 和命名空间的环境,租户管理员能在其中进行部署。</p><p>完成部署后,租户管理员就可以访问指定的 Istio 控制平面的 Pod 了。</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods -n istio-system
|
||
NAME READY STATUS RESTARTS AGE
|
||
grafana-78d649479f-8pqk9 1/1 Running 0 1d
|
||
istio-ca-ffbb75c6f-98w6x 1/1 Running 0 1d
|
||
istio-ingress-68d65fc5c6-dnvfl 1/1 Running 0 1d
|
||
istio-mixer-5b9f8dffb5-8875r 3/3 Running 0 1d
|
||
istio-pilot-678fc976c8-b8tv6 2/2 Running 0 1d
|
||
istio-sidecar-injector-7587bd559d-5tgk6 1/1 Running 0 1d
|
||
prometheus-cf8456855-hdcq7 1/1 Running 0 1d
|
||
</code></pre><p>然而无法访问全部命名空间的 Pod:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods --all-namespaces
|
||
Error from server (Forbidden): pods is forbidden: User "dev-admin" cannot list pods at the cluster scope
|
||
</code></pre><p>访问其他租户的命名空间也是不可以的:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods -n istio-system1
|
||
Error from server (Forbidden): pods is forbidden: User "dev-admin" cannot list pods in the namespace "istio-system1"
|
||
</code></pre><p>租户管理员能够在租户指定的应用命名空间中进行应用部署。例如可以修改一下 <a href=/v1.5/zh/docs/examples/bookinfo/>Bookinfo</a> 的 yaml 然后部署到租户的命名空间 <em>ns-0</em> 中,然后租户管理员就可以在这一命名空间中列出 Pod 了:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods -n ns-0
|
||
NAME READY STATUS RESTARTS AGE
|
||
details-v1-64b86cd49-b7rkr 2/2 Running 0 1d
|
||
productpage-v1-84f77f8747-rf2mt 2/2 Running 0 1d
|
||
ratings-v1-5f46655b57-5b4c5 2/2 Running 0 1d
|
||
reviews-v1-ff6bdb95b-pm5lb 2/2 Running 0 1d
|
||
reviews-v2-5799558d68-b989t 2/2 Running 0 1d
|
||
reviews-v3-58ff7d665b-lw5j9 2/2 Running 0 1d
|
||
</code></pre><p>同样也是不能访问其他租户的应用程序命名空间:</p><pre><code class=language-bash data-expandlinks=true data-repo=istio>$ kubectl get pods -n ns-1
|
||
Error from server (Forbidden): pods is forbidden: User "dev-admin" cannot list pods in the namespace "ns-1"
|
||
</code></pre><p>如果部署了<a href=/v1.5/zh/docs/tasks/observability/>遥测组件</a>, 例如
|
||
<a href=/v1.5/zh/docs/tasks/observability/metrics/querying-metrics/>Prometheus</a>(限制在 Istio 的 <code>namespace</code>),其中获得的统计结果展示的也只是租户应用命名空间的私有数据。</p><h2 id=conclusion>结语</h2><p>上面的一些尝试表明 Istio 有足够的能力和安全性,符合少量多租户的用例需求。另外也很明显的,Istio 和 Kubernetes <strong>无法</strong>提供足够的能力和安全性来满足其他的用例,尤其是在租户之间要求完全的安全性和隔离的要求的用例。只有等容器技术(例如 Kubernetes )能够提供更好的安全模型以及隔离能力,我们才能进一步的增强这方面的支持,Istio 的支持并不是很重要。</p><h2 id=issues>问题</h2><ul><li>一个租户(例如, <code>istio-system</code> 命名空间)的 CA(Certificate Authority) 和 Mixer 的 Pod 中产生的 Log 包含了另一个租户(例如, <code>istio-system1</code> 命名空间)的控制面的 <code>info</code> 信息。</li></ul><h2 id=challenges-with-other-multi-tenancy-models>其他多租户模型的挑战</h2><p>还有其他值得考虑的多租户部署模型:</p><ol><li><p>一个网格中运行多个应用程序,每个租户一个应用。集群管理员能控制和监控网格范围内的所有应用,租户管理员只能控制一个特定应用。</p></li><li><p>单独的 Istio 控制平面控制多个网格,每个租户一个网格。集群管理员控制和监控整个 Istio 控制面以及所有网格,租户管理员只能控制特定的网格。</p></li><li><p>一个云环境(集群控制),多个 Kubernetes 控制面(租户控制)</p></li></ol><p>这些选项,有的需要改写代码才能支持,有的无法满足用户要求。</p><p>目前的 Istio 能力不适合第一种方案,这是因为其 RBAC 能力无法覆盖这种租户操作。另外在当前的网格模型中,Istio 的配置信息需要传递给 Envoy 代理服务器,多个租户在同一网格内共存的做法非常不安全。</p><p>再看看第二个方式,目前的 Istio 假设每个 Istio 控制面对应一个网格。要支持这种模型需要大量改写。这种情况需要更好的对资源的范围限制进行调整,同时根据命名空间进行安全限制,此外还需要调整 Istio 的 RBAC 模型。这种模式未来可能会支持,但目前来说是不可能的。</p><p>第三个方式对多数案例都是不合适的,毕竟多数集群管理员倾向于将同一个 Kubernetes 控制面作为 <a href=https://en.wikipedia.org/wiki/Platform_as_a_service>PaaS</a> 提供给他们的租户。</p><h2 id=future-work>未来</h2><p>很明显,单一 Istio 控制面控制多个网格可能是下一个功能。还有可能就是在同一个网格中支持多个租户,并提供某种程度的隔离和安全保障。要完成这样的能力,就需要像 Kubernetes 中对命名空间的的操作那样,在一个单独的控制平面中进行分区,社区中发出了<a href=https://docs.google.com/document/d/14Hb07gSrfVt5KX9qNi7FzzGwB_6WBpAnDpPG6QEEd9Q>这篇文档</a>来定义其他的用例,以及要支持这些用例所需要的 Istio 功能。</p><h2 id=references>参考</h2><ul><li>视频:<a href="https://www.youtube.com/watch?v=ahwCkJGItkU">用 RBAC 和命名空间支持的多租户功能及安全模型</a>, <a href=https://schd.ws/hosted_files/kccncna17/21/Multi-tenancy%20Support%20%26%20Security%20Modeling%20with%20RBAC%20and%20Namespaces.pdf>幻灯片</a>.</li><li><code>Kubecon</code> 讨论,关于对“协同软性多租户”的支持 <a href="https://www.youtube.com/watch?v=YRR-kZub0cA">Building for Trust: How to Secure Your Kubernetes</a>.</li><li>Kubernetes <a href=https://kubernetes.io/docs/reference/access-authn-authz/rbac/>RBAC 文档</a>以及<a href=https://kubernetes.io/docs/tasks/administer-cluster/namespaces-walkthrough/>命名空间文档</a>.</li><li><code>Kubecon</code> 幻灯片 <a href=https://schd.ws/hosted_files/kccncna17/a9/kubecon-multitenancy.pdf>Multi-tenancy Deep Dive</a>.</li><li>Google 文档 <a href=https://docs.google.com/document/d/15w1_fesSUZHv-vwjiYa9vN_uyc--PySRoLKTuDhimjc>Multi-tenancy models for Kubernetes</a>. (需要授权)</li><li>Cloud Foundry 提出的文档:<a href=https://docs.google.com/document/d/14Hb07gSrfVt5KX9qNi7FzzGwB_6WBpAnDpPG6QEEd9Q>Multi-cloud and Multi-tenancy</a></li><li><a href=https://docs.google.com/document/d/12F183NIRAwj2hprx-a-51ByLeNqbJxK16X06vwH5OWE>Istio Auto Multi-Tenancy 101</a></li></ul><nav id=see-also><h2>相关内容</h2><div class=see-also><div class=entry><p class=link><a data-skipendnotes=true href=/v1.5/zh/docs/ops/deployment/deployment-models/>部署模型</a></p><p class=desc>描述 Istio 部署中的选择和建议。</p></div></div></nav></article><nav class=pagenav><div class=left><a title="描述如何在 AWS 上使用网络负载均衡器配置 Istio Ingress。" href=/v1.5/zh/blog/2018/aws-nlb/><svg class="icon"><use xlink:href="/v1.5/img/icons.svg#left-arrow"/></svg>使用 AWS NLB 配置 Istio Ingress</a></div><div class=right><a title=介绍更安全,低风险的部署和发布到生产。 href=/v1.5/zh/blog/2018/traffic-mirroring/>用于在生产环境进行测试的 Istio 流量镜像功能<svg class="icon"><use xlink:href="/v1.5/img/icons.svg#right-arrow"/></svg></a></div></nav><div id=feedback><div id=feedback-initial>这些信息有用吗?<br><button class="btn feedback" onclick="sendFeedback('zh',1)">是的</button>
|
||
<button class="btn feedback" onclick="sendFeedback('zh',0)">没有</button></div><div id=feedback-comment>Do you have any suggestions for improvement?<br><br><input id=feedback-textbox type=text placeholder="Help us improve..." data-lang=zh></div><div id=feedback-thankyou>Thanks for your feedback!</div></div><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=#soft-multi-tenancy>软性多租户</a><li role=none aria-label=部署><a href=#deployment>部署</a><ol><li role=none aria-label="多个 Istio 控制面"><a href=#multiple-Istio-control-planes>多个 Istio 控制面</a><li role=none aria-label=区分通用资源和命名空间资源><a href=#split-common-and-namespace-specific-resources>区分通用资源和命名空间资源</a><li role=none aria-label="Istio 控制面的 Kubernetes RBAC 设置"><a href=#Kubernetes-rbac-for-Istio-control-plane-resources>Istio 控制面的 Kubernetes RBAC 设置</a><li role=none aria-label=关注特定命名空间进行服务发现><a href=#watching-specific-namespaces-for-service-discovery>关注特定命名空间进行服务发现</a><li role=none aria-label=在特定命名空间中部署租户应用><a href=#deploying-the-tenant-application-in-a-namespace>在特定命名空间中部署租户应用</a><li role=none aria-label="在多租户环境中使用 istioctl"><a href=#using-in-a-multi-tenant-environment>在多租户环境中使用 <code>istioctl</code></a><li role=none aria-label=测试结果><a href=#test-results>测试结果</a></ol></li><li role=none aria-label=结语><a href=#conclusion>结语</a><li role=none aria-label=问题><a href=#issues>问题</a><li role=none aria-label=其他多租户模型的挑战><a href=#challenges-with-other-multi-tenancy-models>其他多租户模型的挑战</a><li role=none aria-label=未来><a href=#future-work>未来</a><li role=none aria-label=参考><a href=#references>参考</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="立刻下载 Istio 1.5.4" href=/v1.5/docs/setup/getting-started/#download aria-label="Download Istio"><span>download</span><svg class="icon"><use xlink:href="/v1.5/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.5/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.5/img/icons.svg#stackoverflow"/></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.5/img/icons.svg#slack"/></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.5/img/icons.svg#twitter"/></svg></a><div class=tag>对于用户</div></div><div class=info><p class=copyright>中文内容由 ServiceMesher 社区维护,部分文档可能稍微滞后于英文版本,同步工作持续进行中<br>Istio 归档
|
||
1.5.4<br>© 2020 Istio Authors, <a href=https://policies.google.com/privacy>隐私政策</a><br>归档于 2020年5月21日</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.5/img/icons.svg#github"/></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.5/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.5/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.5/img/icons.svg#top"/></svg></button></div></body></html> |