|
| 1 | +--- |
| 2 | +title: "Sail Operator 1.0.0 发布:使用 Operator 管理 Istio" |
| 3 | +description: 深入了解 Sail Operator 的基础知识,并查看示例,了解使用它来管理 Istio 是多么容易。 |
| 4 | +publishdate: 2025-04-03 |
| 5 | +attribution: "Francisco Herrera - Red Hat; Translated by Wilson Wu (DaoCloud)" |
| 6 | +keywords: [istio,operator,sail,incluster,istiooperator] |
| 7 | +--- |
| 8 | + |
| 9 | +[Sail Operator](https://github.com/istio-ecosystem/sail-operator) |
| 10 | +是 Red Hat 发起的一个社区项目,旨在为 Istio 构建一个现代 |
| 11 | +[operator](https://www.redhat.com/en/topics/containers/what-is-a-kubernetes-operator)。 |
| 12 | +[于 2024 年 8 月首次发布](/zh/blog/2024/introducing-sail-operator/), |
| 13 | +我们很高兴地宣布 Sail Operator 现已正式发布,其明确的使命是:简化和精简集群中的 Istio 管理。 |
| 14 | + |
| 15 | +## 简化部署和管理 {#simplified-deployment---management} |
| 16 | + |
| 17 | +Sail Operator 旨在降低安装和运行 Istio 的复杂性。 |
| 18 | +它可以自动执行手动任务,确保从初始安装到集群中 Istio 版本的持续维护和升级, |
| 19 | +都能获得一致、可靠且简单的体验。Sail Operator API 是围绕 Istio 的 Helm Chart API 构建的, |
| 20 | +这意味着所有 Istio 配置都可以通过 Sail Operator CRD 的值获得。 |
| 21 | + |
| 22 | +我们鼓励用户阅读我们的[文档](https://github.com/istio-ecosystem/sail-operator/tree/main/docs)以了解有关这种管理 Istio 环境的新方法的更多信息。 |
| 23 | + |
| 24 | +Sail Operator 的主要资源包括: |
| 25 | +* `Istio`:管理 Istio 控制平面。 |
| 26 | +* `IstioRevision`:表示控制平面的修订版本。 |
| 27 | +* `IstioRevisionTag`:表示稳定的修订版本标签,用作 Istio 控制平面修订版本的别名。 |
| 28 | +* `IstioCNI`:管理 Istio 的 CNI 节点代理。 |
| 29 | +* `ZTunnel`:管理 Ambient 模式 ztunnel DaemonSet(Alpha 功能)。 |
| 30 | + |
| 31 | +{{< idea >}} |
| 32 | +如果您正在从[自从删除 Istio 集群内 Operator](/zh/blog/2024/in-cluster-operator-deprecation-announcement/)进行迁移, |
| 33 | +您可以查看我们[文档](https://github.com/istio-ecosystem/sail-operator/tree/main/docs#migrating-from-istio-in-cluster-operator)中的此部分, |
| 34 | +我们在其中解释了资源的等价性,或者您也可以尝试我们的[资源转换器](https://github.com/istio-ecosystem/sail-operator/tree/main/docs#converter-script)轻松地将您的 |
| 35 | +`IstioOperator` 资源转换为 `Istio` 资源。 |
| 36 | +{{< /idea >}} |
| 37 | + |
| 38 | +## 主要功能和支持 {#main-features-and-support} |
| 39 | + |
| 40 | +- Istio 控制平面的每个组件都由 Sail Operator 通过专用的 Kubernetes 自定义资源 (CR) 独立管理。 |
| 41 | + Sail Operator 为 `Istio`、`IstioCNI` 和 `ZTunnel` 等组件提供单独的 CRD, |
| 42 | + 允许您单独配置、管理和升级它们。此外,还有 `IstioRevision` 和 `IstioRevisionTag` 的 CRD 来管理 Istio 控制平面修订。 |
| 43 | +- 支持多个 Istio 版本。目前 1.0.0 版本支持:1.24.3、1.24.2、1.24.1、1.23.5、1.23.4、1.23.3、1.23.0。 |
| 44 | +- 支持两种更新策略:`InPlace` 和 `RevisionBased`。查看我们的文档以获取有关支持的更新类型的更多信息。 |
| 45 | +- 支持多集群 Istio [部署模型](/zh/docs/setup/install/multicluster/): |
| 46 | + 多主、主远程、外部控制平面。更多信息和示例请参阅我们的[文档](https://github.com/istio-ecosystem/sail-operator/blob/main/docs/README.md#multi-cluster)。 |
| 47 | +- Ambient mode support is Alpha: check our specific [documentation](https://github.com/istio-ecosystem/sail-operator/blob/main/docs/common/istio-ambient-mode.md). |
| 48 | +- Ambient 模式支持处于 Alpha 阶段: |
| 49 | + 请查看我们的具体[文档](https://github.com/istio-ecosystem/sail-operator/blob/main/docs/common/istio-ambient-mode.md)。 |
| 50 | +- 插件与 Sail Operator 分开管理。它们可以轻松与 Sail Operator 集成, |
| 51 | + 请查看本节的[文档](https://github.com/istio-ecosystem/sail-operator/blob/main/docs/README.md#addons)以获取示例和更多信息。 |
| 52 | + |
| 53 | +## 为什么是现在? {#why-now} |
| 54 | + |
| 55 | +随着云原生架构的不断发展,我们认为为 Istio 提供强大且用户友好的 Operator 比以往任何时候都更加重要。 |
| 56 | +Sail Operator 为开发人员和运营团队提供了一致、安全且高效的解决方案, |
| 57 | +让那些习惯使用 Operator 的人感觉很熟悉。它的 GA 版本标志着一个成熟的解决方案,可以支持最苛刻的生产环境。 |
| 58 | + |
| 59 | +## 尝试一下 {#try-it-out} |
| 60 | + |
| 61 | +您想尝试 Sail Operator 吗?此示例将向您展示如何使用基于修订的升级策略安全地更新 Istio 控制平面。 |
| 62 | +这意味着您将同时运行两个 Istio 控制平面,让您轻松迁移工作负载,最大限度地降低流量中断的风险。 |
| 63 | + |
| 64 | +先决条件: |
| 65 | +- 运行中的集群 |
| 66 | +- Helm |
| 67 | +- Kubectl |
| 68 | +- Istioctl |
| 69 | + |
| 70 | +### 使用 Helm 安装 Sail Operator {#install-the-sail-operator-using-helm} |
| 71 | + |
| 72 | +{{< text bash >}} |
| 73 | +$ helm repo add sail-operator https://istio-ecosystem.github.io/sail-operator |
| 74 | +$ helm repo update |
| 75 | +$ kubectl create namespace sail-operator |
| 76 | +$ helm install sail-operator sail-operator/sail-operator --version 1.0.0 -n sail-operator |
| 77 | +{{< /text >}} |
| 78 | + |
| 79 | +该 Operator 现已安装在您的集群中: |
| 80 | + |
| 81 | +{{< text plain >}} |
| 82 | +NAME: sail-operator |
| 83 | +LAST DEPLOYED: Tue Mar 18 12:00:46 2025 |
| 84 | +NAMESPACE: sail-operator |
| 85 | +STATUS: deployed |
| 86 | +REVISION: 1 |
| 87 | +TEST SUITE: None |
| 88 | +{{< /text >}} |
| 89 | + |
| 90 | +检查 Operator Pod 是否正在运行: |
| 91 | + |
| 92 | +{{< text bash >}} |
| 93 | +$ kubectl get pods -n sail-operator |
| 94 | +NAME READY STATUS RESTARTS AGE |
| 95 | +sail-operator-56bf994f49-j67ft 1/1 Running 0 87s |
| 96 | +{{< /text >}} |
| 97 | + |
| 98 | +### 创建 `Istio` 和 `IstioRevisionTag` 资源 {#create-istio-and-istiorevisiontag-resources} |
| 99 | + |
| 100 | +创建一个版本为 `v1.24.2` 和 `IstioRevisionTag` 的 `Istio` 资源: |
| 101 | + |
| 102 | +{{< text bash >}} |
| 103 | +$ kubectl create ns istio-system |
| 104 | +$ cat <<EOF | kubectl apply -f- |
| 105 | +apiVersion: sailoperator.io/v1 |
| 106 | +kind: Istio |
| 107 | +metadata: |
| 108 | + name: default |
| 109 | +spec: |
| 110 | + namespace: istio-system |
| 111 | + updateStrategy: |
| 112 | + type: RevisionBased |
| 113 | + inactiveRevisionDeletionGracePeriodSeconds: 30 |
| 114 | + version: v1.24.2 |
| 115 | +--- |
| 116 | +apiVersion: sailoperator.io/v1 |
| 117 | +kind: IstioRevisionTag |
| 118 | +metadata: |
| 119 | + name: default |
| 120 | +spec: |
| 121 | + targetRef: |
| 122 | + kind: Istio |
| 123 | + name: default |
| 124 | +EOF |
| 125 | +{{< /text >}} |
| 126 | + |
| 127 | +请注意,`IstioRevisionTag` 具有对名称为 `default` 的 `Istio` 资源的目标引用 |
| 128 | + |
| 129 | +检查创建的资源的状态: |
| 130 | +- `istiod` Pod 正在运行 |
| 131 | + |
| 132 | + {{< text bash >}} |
| 133 | + $ kubectl get pods -n istio-system |
| 134 | + NAME READY STATUS RESTARTS AGE |
| 135 | + istiod-default-v1-24-2-bd8458c4-jl8zm 1/1 Running 0 3m45s |
| 136 | + {{< /text >}} |
| 137 | + |
| 138 | +- `Istio` 资源被创建 |
| 139 | + |
| 140 | + {{< text bash >}} |
| 141 | + $ kubectl get istio |
| 142 | + NAME REVISIONS READY IN USE ACTIVE REVISION STATUS VERSION AGE |
| 143 | + default 1 1 1 default-v1-24-2 Healthy v1.24.2 4m27s |
| 144 | + {{< /text >}} |
| 145 | + |
| 146 | +- `IstioRevisionTag` 资源被创建 |
| 147 | + |
| 148 | + {{< text bash >}} |
| 149 | + $ kubectl get istiorevisiontag |
| 150 | + NAME STATUS IN USE REVISION AGE |
| 151 | + default NotReferencedByAnything False default-v1-24-2 4m43s |
| 152 | + {{< /text >}} |
| 153 | + |
| 154 | +请注意,`IstioRevisionTag` 状态为 `NotReferencedByAnything`。 |
| 155 | +这是因为当前没有资源使用修订版本 `default-v1-24-2`。 |
| 156 | + |
| 157 | +### 部署示例应用程序 {#deploy-sample-application} |
| 158 | + |
| 159 | +创建命名空间并标记以启用 Istio 注入: |
| 160 | + |
| 161 | +{{< text bash >}} |
| 162 | +$ kubectl create namespace sample |
| 163 | +$ kubectl label namespace sample istio-injection=enabled |
| 164 | +{{< /text >}} |
| 165 | + |
| 166 | +标记命名空间后,您将看到 `IstioRevisionTag` 资源状态将更改为 'In Use: True', |
| 167 | +因为现在有一个资源使用修订版 `default-v1-24-2`: |
| 168 | + |
| 169 | +{{< text bash >}} |
| 170 | +$ kubectl get istiorevisiontag |
| 171 | +NAME STATUS IN USE REVISION AGE |
| 172 | +default Healthy True default-v1-24-2 6m24s |
| 173 | +{{< /text >}} |
| 174 | + |
| 175 | +部署示例应用程序: |
| 176 | + |
| 177 | +{{< text bash >}} |
| 178 | +$ kubectl apply -f {{< github_file >}}/samples/sleep/sleep.yaml -n sample |
| 179 | +{{< /text >}} |
| 180 | + |
| 181 | +确认示例应用的代理版本与控制平面版本匹配: |
| 182 | + |
| 183 | +{{< text bash >}} |
| 184 | +$ istioctl proxy-status |
| 185 | +NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION |
| 186 | +sleep-5fcd8fd6c8-q4c9x.sample Kubernetes SYNCED (78s) SYNCED (78s) SYNCED (78s) SYNCED (78s) IGNORED istiod-default-v1-24-2-bd8458c4-jl8zm 1.24.2 |
| 187 | +{{< /text >}} |
| 188 | + |
| 189 | +### 将 Istio 控制平面升级到版本 1.24.3 {#upgrade-the-istio-control-plane-to-version-1.24.3} |
| 190 | + |
| 191 | +使用新版本更新 `Istio` 资源: |
| 192 | + |
| 193 | +{{< text bash >}} |
| 194 | +$ kubectl patch istio default -n istio-system --type='merge' -p '{"spec":{"version":"v1.24.3"}}' |
| 195 | +{{< /text >}} |
| 196 | + |
| 197 | +检查 `Istio` 资源。您将看到有两个修订版本,并且它们都已 'ready': |
| 198 | + |
| 199 | +{{< text bash >}} |
| 200 | +$ kubectl get istio |
| 201 | +NAME REVISIONS READY IN USE ACTIVE REVISION STATUS VERSION AGE |
| 202 | +default 2 2 2 default-v1-24-3 Healthy v1.24.3 10m |
| 203 | +{{< /text >}} |
| 204 | + |
| 205 | +`IstioRevisiontag` 现在引用了新的修订版本: |
| 206 | + |
| 207 | +{{< text bash >}} |
| 208 | +$ kubectl get istiorevisiontag |
| 209 | +NAME STATUS IN USE REVISION AGE |
| 210 | +default Healthy True default-v1-24-3 11m |
| 211 | +{{< /text >}} |
| 212 | + |
| 213 | +有两个 `IstioRevisions`,每个 Istio 版本一个: |
| 214 | + |
| 215 | +{{< text bash >}} |
| 216 | +$ kubectl get istiorevision |
| 217 | +NAME TYPE READY STATUS IN USE VERSION AGE |
| 218 | +default-v1-24-2 True Healthy True v1.24.2 11m |
| 219 | +default-v1-24-3 True Healthy True v1.24.3 92s |
| 220 | +{{< /text >}} |
| 221 | + |
| 222 | +Sail Operator 会自动检测给定的 Istio 控制平面是否正在使用, |
| 223 | +并将此信息写入您在上面看到的“正在使用”状态条件中。目前, |
| 224 | +所有 `IstioRevisions` 和我们的 `IstioRevisionTag` 都被视为“正在使用”: |
| 225 | +* 旧修订版本 `default-v1-24-2` 被视为正在使用,因为它被示例应用程序的 Sidecar 引用。 |
| 226 | +* 新修订版本 `default-v1-24-3` 被视为正在使用,因为它被标签引用。 |
| 227 | +* 标签被视为正在使用,因为它被示例命名空间引用。 |
| 228 | + |
| 229 | +确认有两个控制平面 Pod 正在运行,每个修订版本一个: |
| 230 | + |
| 231 | +{{< text bash >}} |
| 232 | +$ kubectl get pods -n istio-system |
| 233 | +NAME READY STATUS RESTARTS AGE |
| 234 | +istiod-default-v1-24-2-bd8458c4-jl8zm 1/1 Running 0 16m |
| 235 | +istiod-default-v1-24-3-68df97dfbb-v7ndm 1/1 Running 0 6m32s |
| 236 | +{{< /text >}} |
| 237 | + |
| 238 | +确认代理 Sidecar 版本保持不变: |
| 239 | + |
| 240 | +{{< text bash >}} |
| 241 | +$ istioctl proxy-status |
| 242 | +NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION |
| 243 | +sleep-5fcd8fd6c8-q4c9x.sample Kubernetes SYNCED (6m40s) SYNCED (6m40s) SYNCED (6m40s) SYNCED (6m40s) IGNORED istiod-default-v1-24-2-bd8458c4-jl8zm 1.24.2 |
| 244 | +{{< /text >}} |
| 245 | + |
| 246 | +重启示例 Pod: |
| 247 | + |
| 248 | +{{< text bash >}} |
| 249 | +$ kubectl rollout restart deployment -n sample |
| 250 | +{{< /text >}} |
| 251 | + |
| 252 | +确认代理 Sidecar 版本已更新: |
| 253 | + |
| 254 | +{{< text bash >}} |
| 255 | +$ istioctl proxy-status |
| 256 | +NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION |
| 257 | +sleep-6f87fcf556-k9nh9.sample Kubernetes SYNCED (29s) SYNCED (29s) SYNCED (29s) SYNCED (29s) IGNORED istiod-default-v1-24-3-68df97dfbb-v7ndm 1.24.3 |
| 258 | +{{< /text >}} |
| 259 | + |
| 260 | +当 `IstioRevision` 不再使用且不是 `Istio` 资源的活动修订版本时(例如,当它不是 `spec.version` 字段中设置的版本时), |
| 261 | +Sail Operator 将在宽限期(默认为 30 秒)后将其删除。确认删除旧的控制平面和 `IstioRevision`: |
| 262 | + |
| 263 | +- 旧的控制平面 Pod 被删除 |
| 264 | + |
| 265 | + {{< text bash >}} |
| 266 | + $ kubectl get pods -n istio-system |
| 267 | + NAME READY STATUS RESTARTS AGE |
| 268 | + istiod-default-v1-24-3-68df97dfbb-v7ndm 1/1 Running 0 10m |
| 269 | + {{< /text >}} |
| 270 | + |
| 271 | +- 旧的 `IstioRevision` 被删除 |
| 272 | + |
| 273 | + {{< text bash >}} |
| 274 | + $ kubectl get istiorevision |
| 275 | + NAME TYPE READY STATUS IN USE VERSION AGE |
| 276 | + default-v1-24-3 True Healthy True v1.24.3 13m |
| 277 | + {{< /text >}} |
| 278 | + |
| 279 | +- `Istio` 资源现在只有一个修订版本 |
| 280 | + |
| 281 | + {{< text bash >}} |
| 282 | + $ kubectl get istio |
| 283 | + NAME REVISIONS READY IN USE ACTIVE REVISION STATUS VERSION AGE |
| 284 | + default 1 1 1 default-v1-24-3 Healthy v1.24.3 24m |
| 285 | + {{< /text >}} |
| 286 | + |
| 287 | +**恭喜!**您已成功使用基于修订的升级策略更新了您的 Istio 控制平面。 |
| 288 | + |
| 289 | +{{< idea >}} |
| 290 | +要查看最新的 Sail Operator 版本,请访问我们的[发布页面](https://github.com/istio-ecosystem/sail-operator/releases)。 |
| 291 | +由于此示例可能会随着时间的推移而发展, |
| 292 | +请参阅我们的[文档](https://github.com/istio-ecosystem/sail-operator/tree/main/docs#example-using-the-revisionbased-strategy-and-an-istiorevisiontag)以确保您阅读的是最新版本。 |
| 293 | +{{< /idea >}} |
| 294 | + |
| 295 | +## 结论 {#conclusion} |
| 296 | + |
| 297 | +Sail Operator 可自动执行手动任务,确保从初始安装到集群中 Istio 的持续维护和升级, |
| 298 | +获得一致、可靠且简单的体验。Sail Operator 是一个 [istio-ecosystem](https://github.com/istio-ecosystem) 项目, |
| 299 | +我们鼓励您试用并提供反馈以帮助我们改进它,您可以查看我们的[贡献指南](https://github.com/istio-ecosystem/sail-operator/blob/main/CONTRIBUTING.md)了解有关如何为项目做出贡献的更多信息。 |
0 commit comments