zh-translation: blog/2020/workload-entry/index.md (#9762)

* zh-translation: blog/2020/workload-entry/index.md

* lint

* Update content/zh/blog/2020/workload-entry/index.md

Co-authored-by: Kebe <mail@kebe7jun.com>
This commit is contained in:
orangegzx 2021-08-19 17:02:25 +08:00 committed by GitHub
parent 2512a7f790
commit 8357d20bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,99 @@
---
title: 介绍工作负载条目
subtitle: 桥接 Kubernetes 和 VM
description: 描述了工作负载条目的新功能。
publishdate: 2020-05-21
attribution: Cynthia Coan (Tetrate), Shriram Rajagopalan (Tetrate), Tia Louden (Tetrate), John Howard (Google), Sven Mawson (Google)
keywords: [vm, workloadentry, migration, '1.6', baremetal, serviceentry, discovery]
---
## 工作负载条目简介:桥接 Kubernetes 和 VM{#introducing-workload-entries-bridging-Kubernetes-and-VMs}
从历史上看Istio 为在 Kubernetes 上运行的工作负载提供了很好的体验但对于其他类型的工作负载如虚拟机VM和裸机则不太顺利。这些差距包括无法在 VM 上以声明方式指定 Sidecar 的属性,无法正确响应工作负载的生命周期变化(例如,从启动到未准备就绪,或健康检查),以及在工作负载迁移到 Kubernetes 时繁琐的 DNS 解决方法,仅此而已。
Istio 1.6 在如何管理非 Kubernetes 工作负载方面引入了一些变化,其驱动力是希望在容器之外的用例中更容易获得 Istio 的好处,比如在 Kubernetes 之外的平台上运行传统数据库,或者在不重写现有应用的情况下采用 Istio 的功能。
### 背景{#background}
在 Istio 1.6 之前,非容器化工作负载可以简单地配置为 `ServiceEntry` 中的一个IP地址这意味着它们只作为服务的一部分存在。Istio 缺乏对这些非容器化工作负载的一流抽象,类似于 Kubernetes 将 Pod 视为计算的基本单位--一个命名对象,作为与工作负载相关的所有事物的集合点--名称、标签、安全属性、生命周期状态事件等。输入 `WorkloadEntry`
考虑下面的 `ServiceEntry`,描述一个由几十个有 IP 地址的虚拟机实现的服务:
{{< text yaml >}}
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: svc1
spec:
hosts:
- svc1.internal.com
ports:
- number: 80
name: http
protocol: HTTP
resolution: STATIC
endpoints:
- address: 1.1.1.1
- address: 2.2.2.2
....
{{< /text >}}
如果您想以主动-主动的方式将这个服务迁移到 Kubernetes 中--即启动一堆 Pod通过 Istio 双向 TLSmTLS将一部分流量发送到 Pod并将其余的流量发送到没有 Sidecar 的 VM 上--您会怎么做?您需要使用 Kubernetes 服务、虚拟服务和目标规则的组合来实现这一行为。现在,假设您决定将 Sidecar 逐一添加到这些 VM 上,这样您就希望只有到有 Sidecar 的 VM 的流量才会使用 Istio mTLS。如果任何其他服务条目碰巧在其地址中包括相同的 VM事情就开始变得非常复杂和容易出错。
这些复杂情况的主要来源是 Istio 缺乏对非容器化工作负载的一流定义,其工作负载的属性可以独立于其所属的服务来描述。
{{< image
link="./workload-entry-first-example.svg"
alt="Service Entries Pointing to Workload Entries"
caption="The Internal of Service Entries Pointing to Workload Entries"
>}}
### 工作负载条目{#workload-entry-a-non-Kubernetes-endpoint}
`WorkloadEntry` 是专门为解决这个问题而创建的。`WorkloadEntry` 允许您描述非 Pod 端点,这些端点应该仍然是网格的一部分,并将其与 Pod 同等对待。从这里开始,一切都变得简单了,比如在工作负载之间启用 `MUTUAL_TLS`,无论它们是否是容器化的。
要创建一个 [`WorkloadEntry`](/zh/docs/reference/config/networking/workload-entry/) 并将其附加到一个 [`ServiceEntry`](/zh/docs/reference/config/networking/service-entry/)上,您可以这样做:
{{< text yaml >}}
---
apiVersion: networking.istio.io/v1alpha3
kind: WorkloadEntry
metadata:
name: vm1
namespace: ns1
spec:
address: 1.1.1.1
labels:
app: foo
instance-id: vm-78ad2
class: vm
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: svc1
namespace: ns1
spec:
hosts:
- svc1.internal.com
ports:
- number: 80
name: http
protocol: HTTP
resolution: STATIC
workloadSelector:
labels:
app: foo
{{< /text >}}
这将创建一个带有一组标签和地址的新 `WorkloadEntry`,以及使用 `WorkloadSelector` 来选择所有带有所需标签的端点的 `ServiceEntry`,在这种情况下包括为 VM 创建的 `WorkloadEntry`
{{< image width="75%"
link="./workload-entry-final.svg"
alt="Service Entries Pointing to Workload Entries"
caption="The Internal of Service Entries Pointing to Workload Entries"
>}}
注意 `ServiceEntry` 可以同时引用 Pod 和 `WorkloadEntry`,使用相同的选择器。现在 Istio 可以对 VM 和 Pod 进行相同的处理,而不是将它们分开。
如果要将一些工作负载迁移到 Kubernetes且选择保留大量的 VM`WorkloadSelector` 可以同时选择 Pod 和 VMIstio 会自动在它们之间进行负载平衡。1.6 的变化还意味着 `WorkloadSelector` 可以在 Pod 和 VM 之间同步配置并且无需手动要求以重复的策略例如mTLS和授权将两个基础结构作为目标。Istio 1.6 版本为 Istio 的未来发展提供了一个伟大的起点。能够像描述 Pod 那样描述网状结构之外的东西,会带来更多的好处,比如改善启动体验。然而,这些好处仅仅是副作用。核心的好处是您现在可以让 VM 和 Pod 共存,而不需要任何配置来将两者连接起来。

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" x="0" y="0" version="1.1" viewBox="0 0 640 480" xml:space="preserve" style="enable-background:new 0 0 640 480"><style type="text/css">.st0,.st1{fill:#d8d8d8;stroke:#000;stroke-miterlimit:10}.st1{fill:none}.st2{font-family:&apos;ArialMT&apos;}.st3{font-size:18px}.st4{fill:#efefef;stroke:#020000;stroke-miterlimit:10}.st5{font-size:24px}.st6{font-size:14px}.st7{fill:none;stroke:#020000;stroke-width:.75;stroke-miterlimit:10}.st8{fill:#020000}.st9{fill:none;stroke:#020000;stroke-miterlimit:10}</style><path d="M381.2,166.5H265.5c-6.6,0-12-5.4-12-12V38.8c0-6.6,5.4-12,12-12h115.7c6.6,0,12,5.4,12,12v115.7 C393.2,161.1,387.8,166.5,381.2,166.5z" class="st0"/><g><g><line x1="47" x2="247.5" y1="95.9" y2="95.9" class="st1"/><g><path d="M253.5,95.9c-2.8,1.1-6.4,2.9-8.5,4.8l1.7-4.8l-1.7-4.8C247.2,93,250.7,94.8,253.5,95.9z"/></g></g></g><text class="st2 st3" transform="matrix(1 0 0 1 16.7588 86.617)">Mesh traffic</text><text class="st2 st3" transform="matrix(1 0 0 1 269.2493 101.2239)">Service Entry</text><path d="M190,363H86.8c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12H190c6.6,0,12,5.4,12,12V351 C202,357.6,196.6,363,190,363z" class="st4"/><path d="M201.9,375.2H98.7c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C213.9,369.8,208.5,375.2,201.9,375.2z" class="st4"/><path d="M213.8,384.9H110.6c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C225.8,379.5,220.4,384.9,213.8,384.9z" class="st4"/><text class="st2 st5" transform="matrix(1 0 0 1 136.0748 352.3823)">Pods</text><path d="M528.2,364.2H425c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C540.2,358.8,534.8,364.2,528.2,364.2z" class="st4"/><path d="M540.1,376.4H436.9c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C552.1,371,546.7,376.4,540.1,376.4z" class="st4"/><path d="M552,386.1H448.8c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12H552c6.6,0,12,5.4,12,12v49.5 C564,380.7,558.6,386.1,552,386.1z" class="st4"/><text class="st2 st5" transform="matrix(1 0 0 1 476.5728 352.382)">VMs</text><text transform="matrix(1 0 0 1 74.7761 413.4272)"><tspan x="0" y="0" class="st2 st6">Kubernetes Pods</tspan><tspan x="0" y="16.8" class="st2 st6">labels:</tspan><tspan x="0" y="33.6" class="st2 st6"> app: foo</tspan><tspan x="0" y="50.4" class="st2 st6"> class: pod</tspan></text><text transform="matrix(1 0 0 1 412.9753 413.4275)"><tspan x="0" y="0" class="st2 st6">Istio WorkloadEntries</tspan><tspan x="0" y="16.8" class="st2 st6">labels:</tspan><tspan x="0" y="33.6" class="st2 st6"> app: foo</tspan><tspan x="0" y="50.4" class="st2 st6"> class: vm</tspan></text><text transform="matrix(1 0 0 1 418.3678 86.6168)"><tspan x="0" y="0" class="st2 st6">ServiceEntry</tspan><tspan x="0" y="16.8" class="st2 st6">selector:</tspan><tspan x="0" y="33.6" class="st2 st6"> app: foo</tspan></text><g><g><line x1="274.2" x2="156.2" y1="166.5" y2="298.3" class="st7"/><g><path d="M153.2,301.7c0.8-2.1,1.6-5,1.6-7.2l1.8,3.3l3.5,1.4C157.9,299.6,155.2,300.6,153.2,301.7z" class="st8"/></g></g></g><g><g><line x1="368.1" x2="484.5" y1="166.5" y2="298.4" class="st9"/><g><path d="M488.5,302.9c-2.7-1.4-6.3-2.9-9.2-3.3l4.7-1.9l2.4-4.4C486.4,296.2,487.4,300.1,488.5,302.9z" class="st8"/></g></g></g></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" x="0" y="0" version="1.1" viewBox="0 0 720 540" xml:space="preserve" style="enable-background:new 0 0 720 540"><style type="text/css">.st0{fill:#d9d9d9;stroke:#000;stroke-miterlimit:10}.st1{font-family:&apos;ArialMT&apos;}.st2{font-size:24px}.st3,.st4{fill:#d8d8d8;stroke:#020000;stroke-miterlimit:10}.st4{fill:none}.st5{fill:#020000}.st6{fill:#d8d8d8}.st7{fill:none;stroke:#000;stroke-miterlimit:10;stroke-dasharray:11.7966,1.9661}.st8{font-size:18px}.st9{font-size:14px}</style><path d="M159.8,153.6h-127c-6.6,0-12-5.4-12-12V75.2c0-6.6,5.4-12,12-12h127c6.6,0,12,5.4,12,12v66.4 C171.8,148.2,166.4,153.6,159.8,153.6z" class="st0"/><text class="st1 st2" transform="matrix(1 0 0 1 46.4789 98.179)">K8S</text><text class="st1 st2" transform="matrix(1 0 0 1 46.4789 126.9791)">service</text><path d="M153.2,402.7H50c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C165.2,397.3,159.8,402.7,153.2,402.7z" class="st3"/><path d="M165,414.9H61.9c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12h103.2c6.6,0,12,5.4,12,12v49.5 C177,409.5,171.6,414.9,165,414.9z" class="st3"/><path d="M177,424.6H73.8c-6.6,0-12-5.4-12-12v-49.5c0-6.6,5.4-12,12-12H177c6.6,0,12,5.4,12,12v49.5 C189,419.2,183.6,424.6,177,424.6z" class="st3"/><text class="st1 st2" transform="matrix(1 0 0 1 101.5514 390.8683)">Pod</text><path d="M565.3,359.6H303.5c-6.6,0-12-5.4-12-12V85.8c0-6.6,5.4-12,12-12h261.8c6.6,0,12,5.4,12,12v261.8 C577.3,354.2,571.9,359.6,565.3,359.6z" class="st3"/><g><g><line x1="101.4" x2="96.3" y1="323.2" y2="153.6" class="st4"/><g><path d="M101.6,329.2c1-2.9,2.7-6.4,4.5-8.7l-4.7,1.9l-4.8-1.6C98.5,322.9,100.4,326.4,101.6,329.2z" class="st5"/></g></g></g><text class="st1 st2" transform="matrix(1 0 0 1 308.7642 108.4531)">Istio Service Entry</text><text class="st1 st2" transform="matrix(1 0 0 1 308.7642 216.7336)">Endpoints:</text><g><path d="M428.9,285.9H320.8c-6.6,0-12-5.4-12-12v-26.2c0-6.6,5.4-12,12-12H429c6.6,0,12,5.4,12,12v26.2 C440.9,280.5,435.5,285.9,428.9,285.9z" class="st6"/><path d="M428.9,285.9H320.8c-6.6,0-12-5.4-12-12v-26.2c0-6.6,5.4-12,12-12H429c6.6,0,12,5.4,12,12v26.2 C440.9,280.5,435.5,285.9,428.9,285.9z" class="st7"/></g><g><path d="M428.9,347.5H320.8c-6.6,0-12-5.4-12-12v-26.2c0-6.6,5.4-12,12-12H429c6.6,0,12,5.4,12,12v26.2 C440.9,342.1,435.5,347.5,428.9,347.5z" class="st6"/><path d="M428.9,347.5H320.8c-6.6,0-12-5.4-12-12v-26.2c0-6.6,5.4-12,12-12H429c6.6,0,12,5.4,12,12v26.2 C440.9,342.1,435.5,347.5,428.9,347.5z" class="st7"/></g><text class="st1 st8" transform="matrix(1 0 0 1 113.4329 228.0373)">selects</text><text class="st1 st9" transform="matrix(1 0 0 1 20.8083 443.19)">A Kubernetes Service and Pods</text><text class="st1 st9" transform="matrix(1 0 0 1 20.8083 459.9901)">two seperate objects with distinct</text><text class="st1 st9" transform="matrix(1 0 0 1 20.8083 476.7901)">lifecycles.</text><text class="st1 st9" transform="matrix(1 0 0 1 275.0902 384.2793)">Before Workload Entry, a single Istio Service Entry</text><text class="st1 st9" transform="matrix(1 0 0 1 275.0902 401.0793)">object combined the lifecycle of both the service and</text><text class="st1 st9" transform="matrix(1 0 0 1 275.0902 417.8792)">the workloads implementing it, without giving a first</text><text class="st1 st9" transform="matrix(1 0 0 1 275.0902 434.6793)">class representation for the workloads themselves.</text><text class="st1 st9" transform="matrix(1 0 0 1 349.7465 266.9695)">VM 1 IP</text><text class="st1 st9" transform="matrix(1 0 0 1 349.7465 329.2209)">VM2 IP</text></svg>

After

Width:  |  Height:  |  Size: 3.5 KiB