zh-translation/docs/ops/configuration/mesh/config-resource-ready (#9279)

* translation doc

* Update content/zh/docs/ops/configuration/mesh/config-resource-ready/index.md

* refine config-resource-ready doc

* modify config-resource-ready doc
This commit is contained in:
k-9527 2021-03-19 18:29:57 +08:00 committed by GitHub
parent cfd8374e91
commit b6ed6a0bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,40 @@
---
title: 等待应用的配置资源状态就绪
description: 如何等待资源达到给定的就绪状态。
weight: 15
owner: istio/wg-user-experience-maintainers
test: yes
---
{{< warning >}}
该功能还处于 `Alpha` 阶段,参考 [Istio 功能状态](/zh/about/feature-stages/)。欢迎在 [Istio 用户经验探讨区](https://discuss.istio.io/c/UX/23) 提出您的反馈。目前这些功能仅在单控制平面低容量存储版本的集群中进行了测试。
{{< /warning >}}
Istio 的网格配置是声明式的,意味着您声明或修改一个配置信息不会立即生效而是随着时间慢慢应用到网格中。因此您的命令很可能在相关资源就绪之前就开始使用了网格服务。
在 Istio 1.6 及之后的版本,您可以使用 `kubectl wait` 命令对 Istio 应用配置更改到网格中的方式实行更好的掌控。为了实现该目的, `kubectl wait` 命令监控资源状态的 [`status`](/zh/docs/reference/config/config-status/) 字段,该字段在 Istio 完成配置更改时会被更新。
## 开始之前 {#before-you-begin}
该功能在默认情况下是关闭的。在安装的过程中使用以下命令设置 `status` 的相关配置参数开启该功能。
{{< text syntax=bash snip_id=install_with_enable_status >}}
$ istioctl install --set values.pilot.env.PILOT_ENABLE_STATUS=true --set values.global.istiod.enableAnalysis=true
{{< /text >}}
## 等待资源就绪 {#wait-for-resource-readiness}
您可以先 `apply` 更改的内容,然后等待完成。例如,等待下面的 `virtual service`,可以使用以下命令:
{{< text syntax=bash snip_id=apply_and_wait_for_httpbin_vs >}}
$ kubectl apply -f @samples/httpbin/httpbin.yaml@
$ kubectl apply -f @samples/httpbin/httpbin-gateway.yaml@
$ kubectl wait --for=condition=Reconciled virtualservice/httpbin
virtualservice.networking.istio.io/httpbin condition met
{{< /text >}}
该命令会一直保持阻塞状态,直到 `virtual service` 被成功下发到网格内所有的代理中,或者命令执行超时。
当您在脚本中使用 `kubectl wait` 命令时,返回码 `0` 代表成功,非 `0` 代表超时状态。
关于更多用法和语法信息请参考 [kubectl wait](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#wait) 命令。

View File

@ -0,0 +1,35 @@
#!/bin/bash
# shellcheck disable=SC2034,SC2153,SC2155,SC2164
# Copyright Istio Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
####################################################################################################
# WARNING: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT. PLEASE MODIFY THE ORIGINAL MARKDOWN FILE:
# docs/ops/configuration/mesh/config-resource-ready/index.md
####################################################################################################
snip_install_with_enable_status() {
istioctl install --set values.pilot.env.PILOT_ENABLE_STATUS=true --set values.global.istiod.enableAnalysis=true
}
snip_apply_and_wait_for_httpbin_vs() {
kubectl apply -f samples/httpbin/httpbin.yaml
kubectl apply -f samples/httpbin/httpbin-gateway.yaml
kubectl wait --for=condition=Reconciled virtualservice/httpbin
}
! read -r -d '' snip_apply_and_wait_for_httpbin_vs_out <<\ENDSNIP
virtualservice.networking.istio.io/httpbin condition met
ENDSNIP

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e # Exit on failure
set -u # Unset is an error
# There is no need to echo, output appears in TestDocs/ops/configuration/mesh/config-resource-ready/test.sh/test.sh/_test_context/test.sh_debug.txt
set -o pipefail
# This script doesn't need a control plane initially and will install Istio when needed
# @setup profile=none
echo '*** config-resource-ready step 1 ***'
echo y | snip_install_with_enable_status
echo '*** istioctl-analyze step 2 ***'
_verify_contains snip_apply_and_wait_for_httpbin_vs "$snip_apply_and_wait_for_httpbin_vs_out"
# @cleanup
# Note that the framework automatically turns off errexit, thus this works if the test partially fails
kubectl delete -f samples/httpbin/httpbin.yaml
kubectl delete -f samples/httpbin/httpbin-gateway.yaml
# Delete the Istio this test installed
echo y | istioctl x uninstall --revision "default"
kubectl delete ns istio-system