Upgrade the ops documents translate to Chinese. (#9888)

* finish upgrate the istio CTL analyze article translate to Chinese.

* finish upgrate the istio proxy cmd article translate to Chinese.

* finish upgrate the istio  ctl article translate to Chinese.

* fix the spelling check error.
This commit is contained in:
凡梦星尘 2021-06-28 20:20:58 +08:00 committed by GitHub
parent c74efe29cb
commit b7b8935a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 313 additions and 249 deletions

View File

@ -13,42 +13,143 @@ test: yes
可以使用如下的命令分析您当前的集群:
{{< text bash >}}
$ istioctl analyze
{{< text syntax=bash snip_id=analyze_all_namespaces >}}
$ istioctl analyze --all-namespaces
{{< /text >}}
就是这样!它会给你任何合适的建议。
例如,如果您忘记启用 Istio 注入(一个非常常见的问题),则会收到以下警告:
{{< text plain >}}
Warn [IST0102](Namespace default) The namespace is not enabled for Istio injection. Run 'kubectl label namespace default istio-injection=enabled' to enable it, or 'kubectl label namespace default istio-injection=disabled' to explicitly mark it as not needing injection
{{< text syntax=plain snip_id=analyze_all_namespace_sample_response >}}
Info [IST0102] (Namespace default) The namespace is not enabled for Istio injection. Run 'kubectl label namespace default istio-injection=enabled' to enable it, or 'kubectl label namespace default istio-injection=disabled' to explicitly mark it as not needing injection.
{{< /text >}}
## 分析实时群集,本地文件或同时分析两者{#analyzing-live-clusters-local-files-or-both}
可使用如下命令修复:
上面的例子是对运行的集群进行分析。但是该工具还支持对一组本地 Kubernetes yaml 配置文件,或对本地文件和运行集群的组合进行分析。当分析一组本地文件时,文件集应该是完全独立的。通常,这用于分析打算部署到集群的整个配置文件集。
分析一组特定的本地文件:
{{< text bash >}}
$ istioctl analyze --use-kube=false a.yaml b.yaml
{{< text syntax=bash snip_id=fix_default_namespace >}}
$ kubectl label namespace default istio-injection=enabled
{{< /text >}}
分析当前文件夹中的所有 yaml 文件
然后再重试一下:
{{< text bash >}}
$ istioctl analyze --use-kube=false *.yaml
{{< text syntax=bash snip_id=try_with_fixed_namespace >}}
$ istioctl analyze --namespace default
✔ No validation issues found when analyzing namespace: default.
{{< /text >}}
模拟将当前文件夹中的文件应用于当前集群:
## 分析活动群集,本地文件或同时分析两者{#analyzing-live-clusters-local-files-or-both}
{{< text bash >}}
$ istioctl analyze *.yaml
分析当前的活动集群,模拟在 `samples/bookinfo/networking` 目录下应用诸如 `bookinfo-gateway.yaml``destination-rule-all.yaml` 等额外 yaml 文件的效果:
{{< text syntax=bash snip_id=analyze_sample_destrule >}}
$ istioctl analyze @samples/bookinfo/networking/bookinfo-gateway.yaml@ @samples/bookinfo/networking/destination-rule-all.yaml@
Error [IST0101] (VirtualService bookinfo.default samples/bookinfo/networking/bookinfo-gateway.yaml:39) Referenced host not found: "productpage"
Error: Analyzers found issues when analyzing namespace: default.
See https://istio.io/v{{< istio_version >}}/zh/docs/reference/config/analysis for more information about causes and resolutions.
{{< /text >}}
分析整个 `networking` 目录:
{{< text syntax=bash snip_id=analyze_networking_directory >}}
$ istioctl analyze samples/bookinfo/networking/
{{< /text >}}
分析 `networking` 目录下的所有 yaml 文件:
{{< text syntax=bash snip_id=analyze_all_networking_yaml >}}
$ istioctl analyze samples/bookinfo/networking/*.yaml
{{< /text >}}
上面的例子是对活动集群进行分析。但是该工具还支持对一组本地 Kubernetes yaml 配置文件,或对本地文件和活动集群的组合进行分析。当分析一组本地文件时,文件集应该是完全独立的。通常,这用于分析打算部署到集群的整个配置文件集。 要使用此功能,只需添加 `--use-kube=false` 标志。
分析 `networking` 目录下的所有 yaml 文件:
{{< text syntax=bash snip_id=analyze_all_networking_yaml_no_kube >}}
$ istioctl analyze --use-kube=false samples/bookinfo/networking/*.yaml
{{< /text >}}
可以运行 `istioctl analyze --help` 来查看完整的选项集。
## 高级功能{#advanced}
### 为资源状态启用验证消息{#enabling-validation-messages-for-resource-status}
{{< boilerplate experimental-feature-warning >}}
从 Istio 1.5 开始,可以通过`istiod.enableAnalysis`标志将 Galley 设置为与其主要负责的配置分发一起执行配置分析。
此分析使用与`istioctl analysis`相同的逻辑和错误消息。 来自分析的验证消息被写入受影响的 Istio 资源的状态子资源。
例如如果您的“ratings”虚拟服务上的网关配置错误运行 `kubectl get virtualservice ratings` 会给你类似这样的结果:
{{< text syntax=yaml snip_id=vs_yaml_with_status >}}
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
...
spec:
gateways:
- bogus-gateway
hosts:
- ratings
...
status:
validationMessages:
- documentation_url: https://istio.io/v{{< istio_version >}}/zh/docs/reference/config/analysis/ist0101/?ref=status-controller
level: 3
type:
code: IST0101
{{< /text >}}
`enableAnalysis` 在后台运行,并将保持资源的状态字段与其当前验证状态保持同步。 请注意,这不是`istioctl analysis`的替代品:
- 并非所有资源都有自定义状态字段(例如 Kubernetes `namespace`资源),因此附加到这些资源的消息不会显示验证消息。
- `enableAnalysis` 仅适用于从 1.5 开始的 Istio 版本,而 `istioctl analysis` 可用于旧版本。
- 虽然可以轻松查看特定资源的问题,但很难全面了解网格中的验证状态。
您可以通过以下方式命令此功能:
{{< text syntax=bash snip_id=install_with_custom_config_analysis >}}
$ istioctl install --set values.global.istiod.enableAnalysis=true
{{< /text >}}
### 通过 CLI 忽略特定的分析者消息{#ignoring-specific-analyzer-messages-via-cli}
有时您可能会发现在某些情况下隐藏或忽略分析器消息很有用。 例如,想象这样一种情况,其中发出一条关于您无权更新的资源的消息:
{{< text syntax=bash snip_id=analyze_k_frod >}}
$ istioctl analyze -k --namespace frod
Info [IST0102] (Namespace frod) The namespace is not enabled for Istio injection. Run 'kubectl label namespace frod istio-injection=enabled' to enable it, or 'kubectl label namespace frod istio-injection=disabled' to explicitly mark it as not needing injection.
{{< /text >}}
由于您无权更新命名空间,因此无法通过注释命名空间来解析消息。 相反,您可以使用`istioctl analysis`来抑制资源上的上述消息:
{{< text syntax=bash snip_id=analyze_suppress0102 >}}
$ istioctl analyze -k --namespace frod --suppress "IST0102=Namespace frod"
✔ No validation issues found when analyzing namespace: frod.
{{< /text >}}
当引用:`<kind> <name>.<namespace>`资源时,用于抑制的语法与整个 `istioctl` 中使用的语法相同,或者仅使用`<kind> <name>`对于`Namespace`集群范围的资源。如果你想抑制多个对象,你可以重复 `--suppress` 参数或使用通配符:
{{< text syntax=bash snip_id=analyze_suppress_frod_0107_baz >}}
$ # Suppress code IST0102 on namespace frod and IST0107 on all pods in namespace baz
$ istioctl analyze -k --all-namespaces --suppress "IST0102=Namespace frod" --suppress "IST0107=Pod *.baz"
{{< /text >}}
### 通过注释忽略特定的分析器消息{#ignoring-specific-analyzer-messages-via-annotations}
您也可以使用资源上的注释忽略特定的分析器消息。例如,要忽略资源`deployment/my deployment`上的代码IST0107`MisplacedAnnotation`
{{< text syntax=bash snip_id=annotate_for_deployment_suppression >}}
$ kubectl annotate deployment my-deployment galley.istio.io/analyze-suppress=IST0107
{{< /text >}}
要忽略资源的多个代码,请用逗号分隔每个代码:
{{< text syntax=bash snip_id=annotate_for_deployment_suppression_107 >}}
$ kubectl annotate deployment my-deployment galley.istio.io/analyze-suppress=IST0107,IST0002
{{< /text >}}
## 帮助我们改进此工具{#helping-us-improve-this-tool}
我们将不断增加更多的分析功能,并希望您能帮助我们发现更多的用例。
@ -89,120 +190,4 @@ $ istioctl analyze *.yaml
- **在哪里可以找到解决错误的方法?**
[配置分析消息](/zh/docs/reference/config/analysis/)集包含每个消息的描述以及建议的修复程序。
## 高级功能{#advanced}
### 获取最新版本的 `istioctl analyze`{#getting-the-latest-version-of-Istio-analyze}
虽然 `istioctl analyze` 是包含在了 Istio 1.4 以及更高级的版本中,但是还可以直接下载最新版本到集群中使用的。最新版本可能不稳定,但是会有最完整和最新的分析程序集,并且可能会发现旧版本遗漏的问题。
可以使用下面的命令下载最新的 `istioctl` 到当前目录:
{{< tabset category-name="platform" >}}
{{< tab name="Mac" category-value="macos" >}}
{{< text bash >}}
$ curl https://storage.googleapis.com/istio-build/dev/latest | xargs -I {} curl https://storage.googleapis.com/istio-build/dev/{}/istioctl-{}-osx.tar.gz | tar xvz
{{< /text >}}
{{< /tab >}}
{{< tab name="Linux" category-value="linux" >}}
{{< text bash >}}
$ curl https://storage.googleapis.com/istio-build/dev/latest | xargs -I {} curl https://storage.googleapis.com/istio-build/dev/{}/istioctl-{}-linux-amd64.tar.gz | tar xvz
{{< /text >}}
{{< /tab >}}
{{< /tabset >}}
### 为资源状态启用验证消息{#enabling-validation-messages-for-resource-status}
从 Istio 1.4 开始,可以通过 `galley.enableAnalysis` 标志将 Galley 设置为与主要负责的配置分发一起执行配置分析。该分析使用与 `istioctl analyze` 相同的逻辑和错误消息。来自分析的验证消息将写入受影响的 Istio 资源的状态子资源。
例如,如果您在 "ratings" 虚拟服务上网关配置错误,运行 `kubectl get virtualservice ratings` 将为您提供以下信息:
{{< text yaml >}}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"networking.istio.io/v1alpha3","kind":"VirtualService","metadata":{"annotations":{},"name":"ratings","namespace":"default"},"spec":{"hosts":["ratings"],"http":[{"route":[{"destination":{"host":"ratings","subset":"v1"}}]}]}}
creationTimestamp: "2019-09-04T17:31:46Z"
generation: 11
name: ratings
namespace: default
resourceVersion: "12760039"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/ratings
uid: dec86702-cf39-11e9-b803-42010a8a014a
spec:
gateways:
- bogus-gateway
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
status:
validationMessages:
- code: IST0101
level: Error
message: 'Referenced gateway not found: "bogus-gateway"'
{{< /text >}}
`enableAnalysis` 在后台运行,并将使资源的状态字段保持其当前验证状态的最新状态。请注意,这不能代替 `istioctl analyze`
- 并非所有资源都有自定义状态字段 (例如 Kubernetes `namespace` 资源),因此附加到这些资源的消息将不会显示验证消息。
- `enableAnalysis` 仅适用于从 1.4 开始的 Istio 版本,而 `istioctl analysis` 可以用于较早的版本。
- 尽管可以轻松查看特定资源的问题所在,但要在网格中全面了解验证状态更加困难。
您可以通过以下方式启用此功能:
{{< text bash >}}
$ istioctl manifest apply --set values.galley.enableAnalysis=true
{{< /text >}}
### 通过 CLI 忽略特定的分析器消息{#ignoring-specific-analyzer-messages-via-cli}
有时候你可能会发现,在某些情况下隐藏或忽略分析器消息很有用。例如,假设出现这样一种情况,其发出有关您无权更新资源的消息:
{{< text bash >}}
$ istioctl analyze -k --all-namespaces
Warn [IST0102] (Namespace frod) The namespace is not enabled for Istio injection. Run 'kubectl label namespace frod istio-injection=enabled' to enable it, or 'kubectl label namespace frod istio-injection=disabled' to explicitly mark it as not needing injection
Error: Analyzers found issues.
See https://istio.io/docs/reference/config/analysis for more information about causes and resolutions.
{{< /text >}}
因为您没有更新命名空间的权限,所以无法通过注释命名空间来解析消息。相反,您可以直接使用 `istioctl analyze` 来抑制上述资源中的消息:
{{< text bash >}}
$ istioctl analyze -k --all-namespaces --suppress "IST0102=Namespace frod"
✔ No validation issues found.
{{< /text >}}
用于抑制的语法与引用资源时在整个 `istioctl` 中使用的语法相同:`<kind> <name>.<namespace>`。或只是 `<kind> <name>` 用于集群范围内的资源,例如,`Namespace`。如果要抑制多个对象,则可以重复使用 `--suppress` 参数或使用通配符:
{{< text bash >}}
$ # Suppress code IST0102 on namespace frod and IST0107 on all pods in namespace baz
$ istioctl analyze -k --all-namespaces --suppress "IST0102=Namespace frod" --suppress "IST0107=Pod *.baz"
{{< /text >}}
### 通过注释忽略特定的分析器消息{#ignoring-specific-analyzer-messages-via-annotations}
您还可以使用资源上的注释忽略特定的分析器消息。例如,忽略资源 `deployment/my-deployment` 上的代码 IST0107`MisplacedAnnotation`
{{< text bash >}}
$ kubectl annotate deployment my-deployment galley.istio.io/analyze-suppress=IST0107
{{< /text >}}
要忽略资源的多处代码,请用逗号分隔每处代码:
{{< text bash >}}
$ kubectl annotate deployment my-deployment galley.istio.io/analyze-suppress=IST0107,IST0002
{{< /text >}}
[配置分析消息](/zh/docs/reference/config/analysis/)集包含每个消息的描述以及建议的修复程序。

View File

@ -13,7 +13,7 @@ test: no
在 Istio 1.3 中,我们新增了 [`istioctl experimental describe`](/zh/docs/reference/commands/istioctl/#istioctl-experimental-describe-pod) 命令。
一些配置可以影响 {{< gloss >}}pod{{< /gloss >}},要理解这些配置,您可以利用这个命令行工具得到一些必要的信息。
这份指南向您展示如何使用这个实验性命令来查看一个 pod 是否在网格中并验证它的配置。
这份指南向您展示如何使用这个实验性质的命令来查看一个 pod 是否在网格中并验证它的配置。
该命令的基本用法如下:
@ -35,12 +35,17 @@ $ istioctl experimental describe <pod-name>[.<namespace>]
如果 pod 里没有 {{< gloss >}}Envoy{{< /gloss >}} 代理或者代理没启动,`istioctl describe` 命令会返回一个警告。
另外,如果 [pods 的 Istio 需求](/zh/docs/ops/deployment/requirements/)未完全满足,该命令也会警告。
例如,下面的命令发出的警告表示一个 `kubernetes-dashboard` pod 不被包含在服务网格内,因为它没有 sidecar
例如,下面的命令发出的警告表示一个 `kube-dns` pod 不被包含在服务网格内,因为它没有 sidecar
{{< text bash >}}
$ export DASHBOARD_POD=$(kubectl -n kube-system get pod -l k8s-app=kubernetes-dashboard -o jsonpath='{.items[0].metadata.name}')
$ istioctl x describe pod -n kube-system $DASHBOARD_POD
WARNING: kubernetes-dashboard-7996b848f4-nbns2.kube-system is not part of mesh; no Istio sidecar
$ export KUBE_POD=$(kubectl -n kube-system get pod -l k8s-app=kube-dns -o jsonpath='{.items[0].metadata.name}')
$ istioctl x describe pod -n kube-system $KUBE_POD
Pod: coredns-f9fd979d6-2zsxk
Pod Ports: 53/UDP (coredns), 53 (coredns), 9153 (coredns)
WARNING: coredns-f9fd979d6-2zsxk is not part of mesh; no Istio sidecar
--------------------
2021-01-22T16:10:14.080091Z error klog an error occurred forwarding 42785 -> 15000: error forwarding port 15000 to pod 692362a4fe313005439a873a1019a62f52ecd02c3de9a0957cd0af8f947866e5, uid : failed to execute portforward in network namespace "/var/run/netns/cni-3c000d0a-fb1c-d9df-8af8-1403e6803c22": failed to dial 15000: dial tcp4 127.0.0.1:15000: connect: connection refused[]
Error: failed to execute command on sidecar: failure running port forward process: Get "http://localhost:42785/config_dump": EOF
{{< /text >}}
但对于服务网格内的 pod如 Bookinfo 的 `ratings` 服务,该命令就不会报警,而是输出该 pod 的 Istio 配置:
@ -48,12 +53,11 @@ WARNING: kubernetes-dashboard-7996b848f4-nbns2.kube-system is not part of mesh;
{{< text bash >}}
$ export RATINGS_POD=$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')
$ istioctl experimental describe pod $RATINGS_POD
Pod: ratings-v1-f745cf57b-qrxl2
Pod Ports: 9080 (ratings), 15090 (istio-proxy)
Pod: ratings-v1-7dc98c7588-8jsbw
Pod Ports: 9080 (ratings), 15090 (istio-proxy)
--------------------
Service: ratings
Port: http 9080/HTTP
Pilot reports that pod enforces HTTP/mTLS and clients speak HTTP
Port: http 9080/HTTP targets pod port 9080
{{< /text >}}
该输出展示了下列信息:
@ -61,7 +65,6 @@ Pilot reports that pod enforces HTTP/mTLS and clients speak HTTP
- Pod 内的服务容器的端口,如本例中的 `ratings` 容器的 `9080`
- Pod 内的 `istio-proxy` 容器的端口,如本例中的 `15090`
- Pod 内的服务所用的协议,如本例中的端口 `9080` 上的 `HTTP`
- Pod 的双向 TLS 设置。
## 验证 destination rule 配置{#verify-destination-rule-configurations}
@ -84,7 +87,6 @@ DestinationRule: ratings for "ratings"
Matching subsets: v1
(Non-matching subsets v2,v2-mysql,v2-mysql-vm)
Traffic Policy TLS Mode: ISTIO_MUTUAL
Pilot reports that pod enforces HTTP/mTLS and clients speak mTLS
{{< /text >}}
该命令现在显示了更多的输出:

View File

@ -136,6 +136,10 @@ $ brew install bash-completion
根据您选择的 shell按照以下步骤在您的系统开启 `istioctl` 命令补全 :
{{< warning >}}
您需要下载包含自动补全文件(在`/tools`目录下)的 Istio 完整发行版本。如果你没有这么做, 现在请[下载 Istio 完整发行版本](/zh/docs/setup/getting-started/#download) 。
{{< /warning >}}
{{< tabset category-name="profile" >}}
{{< tab name="Bash" category-value="bash" >}}

View File

@ -1,5 +1,5 @@
---
title: 调试 Envoy 和 Pilot
title: 调试 Envoy 和 Istiod
description: 描述诊断与流量管理相关的 Envoy 配置问题的工具和技术。
weight: 20
keywords: [debug,proxy,status,config,pilot,envoy]
@ -29,31 +29,30 @@ Istio 提供了两个非常有价值的命令来帮助诊断流量管理配置
{{< text bash >}}
$ istioctl proxy-status
PROXY CDS LDS EDS RDS PILOT VERSION
details-v1-6dcc6fbb9d-wsjz4.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-tfdvh 1.1.2
istio-egressgateway-c49694485-l9d5l.istio-system SYNCED SYNCED SYNCED NOT SENT istio-pilot-75bdf98789-tfdvh 1.1.2
istio-ingress-6458b8c98f-7ks48.istio-system SYNCED SYNCED SYNCED NOT SENT istio-pilot-75bdf98789-n2kqh 1.1.2
istio-ingressgateway-7d6874b48f-qxhn5.istio-system SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2
productpage-v1-6c886ff494-hm7zk.default SYNCED SYNCED SYNCED STALE istio-pilot-75bdf98789-n2kqh 1.1.2
ratings-v1-5d9ff497bb-gslng.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2
reviews-v1-55d4c455db-zjj2m.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2
reviews-v2-686bbb668-99j76.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-tfdvh 1.1.2
reviews-v3-7b9b5fdfd6-4r52s.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2
NAME CDS LDS EDS RDS ISTIOD VERSION
details-v1-558b8b4b76-qzqsg.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
istio-ingressgateway-66c994c45c-cmb7x.istio-system SYNCED SYNCED SYNCED NOT SENT istiod-6cf8d4f9cb-wm7x6 1.7.0
productpage-v1-6987489c74-nc7tj.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
prometheus-7bdc59c94d-hcp59.istio-system SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
ratings-v1-7dc98c7588-5m6xj.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
reviews-v1-7f99cc4496-rtsqn.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
reviews-v2-7d79d5bd5d-tj6kf.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
reviews-v3-7dbcdcbc56-t8wrx.default SYNCED SYNCED SYNCED SYNCED istiod-6cf8d4f9cb-wm7x6 1.7.0
{{< /text >}}
如果列表中缺少代理,这意味着它目前没有连接到 Pilot 实例,因此不会接收任何配置。
如果列表中缺少代理,这意味着它目前没有连接到 Istiod 实例,因此不会接收任何配置。
* `SYNCED` 意思是 Envoy 知晓了 Pilot 已经将最新的配置发送给了它。
* `NOT SENT` 意思是 Pilot 没有发送任何信息给 Envoy。这通常是因为 Pilot 没什么可发送的。
* `STALE` 意思是 Pilot 已经发送了一个更新到 Envoy但还没有收到应答。这通常意味着 Envoy 和 Pilot 之间存在网络问题,或者 Istio 自身的 bug。
* `SYNCED` 意思是 Envoy 知晓了 {{< gloss >}}Istiod{{< /gloss >}} 已经将最新的配置发送给了它。
* `NOT SENT` 意思是 Istiod 没有发送任何信息给 Envoy。这通常是因为 Istiod 没什么可发送的。
* `STALE` 意思是 Istiod 已经发送了一个更新到 Envoy但还没有收到应答。这通常意味着 Envoy 和 Istiod 之间存在网络问题,或者 Istio 自身的 bug。
## 检查 Envoy 和 Istio Pilot 的差异{#retrieve-diffs-between-envoy-and-Istio-pilot}
## 检查 Envoy 和 Istiod 的差异{#retrieve-diffs-between-envoy-and-Istiod}
通过提供代理 ID`proxy-status` 命令还可以用来检查 Envoy 已加载的配置和 Pilot 发送给它的配置有什么异同,这可以帮您准确定位哪些配置是不同步的,以及问题出在哪里。
通过提供代理 ID`proxy-status` 命令还可以用来检查 Envoy 已加载的配置和 Istiod 发送给它的配置有什么异同,这可以帮您准确定位哪些配置是不同步的,以及问题出在哪里。
{{< text bash json >}}
$ istioctl proxy-status details-v1-6dcc6fbb9d-wsjz4.default
--- Pilot Clusters
--- Istiod Clusters
+++ Envoy Clusters
@@ -374,36 +374,14 @@
"edsClusterConfig": {
@ -94,7 +93,7 @@ $ istioctl proxy-status details-v1-6dcc6fbb9d-wsjz4.default
}
Listeners Match
Routes Match
Routes Match (RDS last loaded at Tue, 04 Aug 2020 11:52:54 IST)
{{< /text >}}
从这儿可以看到,监听器和路由是匹配的,但集群不同步。
@ -105,14 +104,30 @@ Routes Match
{{< text bash >}}
$ istioctl proxy-config cluster -n istio-system istio-ingressgateway-7d6874b48f-qxhn5
SERVICE FQDN PORT SUBSET DIRECTION TYPE
BlackHoleCluster - - - STATIC
details.default.svc.cluster.local 9080 - outbound EDS
heapster.kube-system.svc.cluster.local 80 - outbound EDS
istio-citadel.istio-system.svc.cluster.local 8060 - outbound EDS
istio-citadel.istio-system.svc.cluster.local 15014 - outbound EDS
istio-egressgateway.istio-system.svc.cluster.local 80 - outbound EDS
SERVICE FQDN PORT SUBSET DIRECTION TYPE DESTINATION RULE
BlackHoleCluster - - - STATIC
agent - - - STATIC
details.default.svc.cluster.local 9080 - outbound EDS details.default
istio-ingressgateway.istio-system.svc.cluster.local 80 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 443 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 15021 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 15443 - outbound EDS
istiod.istio-system.svc.cluster.local 443 - outbound EDS
istiod.istio-system.svc.cluster.local 853 - outbound EDS
istiod.istio-system.svc.cluster.local 15010 - outbound EDS
istiod.istio-system.svc.cluster.local 15012 - outbound EDS
istiod.istio-system.svc.cluster.local 15014 - outbound EDS
kube-dns.kube-system.svc.cluster.local 53 - outbound EDS
kube-dns.kube-system.svc.cluster.local 9153 - outbound EDS
kubernetes.default.svc.cluster.local 443 - outbound EDS
...
productpage.default.svc.cluster.local 9080 - outbound EDS
prometheus_stats - - - STATIC
ratings.default.svc.cluster.local 9080 - outbound EDS
reviews.default.svc.cluster.local 9080 - outbound EDS
sds-grpc - - - STATIC
xds-grpc - - - STRICT_DNS
zipkin - - - STRICT_DNS
{{< /text >}}
为了调试 Envoy 您需要理解 Envoy 集群、监听器、路由、endpoints 以及它们是如何交互的。我们将使用带有 `-o json` 参数的 `proxy-config` 命令,根据标志过滤出并跟随特定的 Envoy它将请求从 `productpage` pod 发送到 `reviews` pod 9080 端口。
@ -125,45 +140,48 @@ istio-egressgateway.istio-system.svc.cluster.local
{{< text bash >}}
$ istioctl proxy-config listeners productpage-v1-6c886ff494-7vxhs
ADDRESS PORT TYPE
172.21.252.250 15005 TCP <--+
172.21.252.250 15011 TCP |
172.21.79.56 42422 TCP |
172.21.160.5 443 TCP |
172.21.157.6 443 TCP |
172.21.117.222 443 TCP |
172.21.0.10 53 TCP |
172.21.126.131 443 TCP | Receives outbound non-HTTP traffic for relevant IP:PORT pair from listener `0.0.0.0_15001`
172.21.160.5 31400 TCP |
172.21.81.159 9102 TCP |
172.21.0.1 443 TCP |
172.21.126.131 80 TCP |
172.21.119.8 443 TCP |
172.21.112.64 80 TCP |
172.21.179.54 443 TCP |
172.21.165.197 443 TCP <--+
0.0.0.0 9090 HTTP <-+
0.0.0.0 8060 HTTP |
0.0.0.0 15010 HTTP |
0.0.0.0 15003 HTTP |
0.0.0.0 15004 HTTP |
0.0.0.0 15014 HTTP | Receives outbound HTTP traffic for relevant port from listener `0.0.0.0_15001`
0.0.0.0 15007 HTTP |
0.0.0.0 8080 HTTP |
0.0.0.0 9091 HTTP |
0.0.0.0 9080 HTTP |
0.0.0.0 80 HTTP <-+
0.0.0.0 15001 TCP // Receives all inbound and outbound traffic to the pod from IP tables and hands over to virtual listener
172.30.164.190 9080 HTTP // Receives all inbound traffic on 9080 from listener `0.0.0.0_15001`
ADDRESS PORT MATCH DESTINATION
10.96.0.10 53 ALL Cluster: outbound|53||kube-dns.kube-system.svc.cluster.local
0.0.0.0 80 App: HTTP Route: 80
0.0.0.0 80 ALL PassthroughCluster
10.100.93.102 443 ALL Cluster: outbound|443||istiod.istio-system.svc.cluster.local
10.111.121.13 443 ALL Cluster: outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
10.96.0.1 443 ALL Cluster: outbound|443||kubernetes.default.svc.cluster.local
10.100.93.102 853 App: HTTP Route: istiod.istio-system.svc.cluster.local:853
10.100.93.102 853 ALL Cluster: outbound|853||istiod.istio-system.svc.cluster.local
0.0.0.0 9080 App: HTTP Route: 9080
0.0.0.0 9080 ALL PassthroughCluster
0.0.0.0 9090 App: HTTP Route: 9090
0.0.0.0 9090 ALL PassthroughCluster
10.96.0.10 9153 App: HTTP Route: kube-dns.kube-system.svc.cluster.local:9153
10.96.0.10 9153 ALL Cluster: outbound|9153||kube-dns.kube-system.svc.cluster.local
0.0.0.0 15001 ALL PassthroughCluster
0.0.0.0 15006 Addr: 10.244.0.22/32:15021 inbound|15021|mgmt-15021|mgmtCluster
0.0.0.0 15006 Addr: 10.244.0.22/32:9080 Inline Route: /*
0.0.0.0 15006 Trans: tls; App: HTTP TLS; Addr: 0.0.0.0/0 Inline Route: /*
0.0.0.0 15006 App: HTTP; Addr: 0.0.0.0/0 Inline Route: /*
0.0.0.0 15006 App: Istio HTTP Plain; Addr: 10.244.0.22/32:9080 Inline Route: /*
0.0.0.0 15006 Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: tls; App: TCP TLS; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15010 App: HTTP Route: 15010
0.0.0.0 15010 ALL PassthroughCluster
10.100.93.102 15012 ALL Cluster: outbound|15012||istiod.istio-system.svc.cluster.local
0.0.0.0 15014 App: HTTP Route: 15014
0.0.0.0 15014 ALL PassthroughCluster
0.0.0.0 15021 ALL Inline Route: /healthz/ready*
10.111.121.13 15021 App: HTTP Route: istio-ingressgateway.istio-system.svc.cluster.local:15021
10.111.121.13 15021 ALL Cluster: outbound|15021||istio-ingressgateway.istio-system.svc.cluster.local
0.0.0.0 15090 ALL Inline Route: /stats/prometheus*
10.111.121.13 15443 ALL Cluster: outbound|15443||istio-ingressgateway.istio-system.svc.cluster.local
{{< /text >}}
1. 从上面的信息可以看到,每一个 sidecar 有一个绑定到 `0.0.0.0:15001` 的监听器,来确定 IP 表将所有进出 Pod 的流量路由到哪里。监听器设置 `useOriginalDst` 为 true 意味着它将请求传递给最适合原始请求目的地的监听器。如果找不到匹配的虚拟监听器,它会将请求发送到直接连接到目的地的 `PassthroughCluster`
{{< text bash json >}}
{{< text bash json >}}
$ istioctl proxy-config listeners productpage-v1-6c886ff494-7vxhs --port 15001 -o json
[
{
"name": "virtual",
"name": "virtualOutbound",
"address": {
"socketAddress": {
"address": "0.0.0.0",
@ -173,22 +191,47 @@ istio-egressgateway.istio-system.svc.cluster.local
"filterChains": [
{
"filters": [
{
"name": "istio.stats",
"typedConfig": {
"@type": "type.googleapis.com/udpa.type.v1.TypedStruct",
"typeUrl": "type.googleapis.com/envoy.extensions.filters.network.wasm.v3.Wasm",
"value": {
"config": {
"configuration": "{\n \"debug\": \"false\",\n \"stat_prefix\": \"istio\"\n}\n",
"root_id": "stats_outbound",
"vm_config": {
"code": {
"local": {
"inline_string": "envoy.wasm.stats"
}
},
"runtime": "envoy.wasm.runtime.null",
"vm_id": "tcp_stats_outbound"
}
}
}
}
},
{
"name": "envoy.tcp_proxy",
"config": {
"cluster": "PassthroughCluster",
"stat_prefix": "PassthroughCluster"
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.filter.network.tcp_proxy.v2.TcpProxy",
"statPrefix": "PassthroughCluster",
"cluster": "PassthroughCluster"
}
}
]
],
"name": "virtualOutbound-catchall-tcp"
}
],
"useOriginalDst": true
"trafficDirection": "OUTBOUND",
"hiddenEnvoyDeprecatedUseOriginalDst": true
}
]
{{< /text >}}
1. 我们的请求是到端口 `9080` 的出站 HTTP 请求,它将被传递给 `0.0.0.0:9080` 的虚拟监听器。这一监听器将检索在它配置的 RDS 里的路由配置。在这个例子中它将寻找 Pilot通过 ADS配置在 RDS 中的路由 `9080`
1. 我们的请求是到端口 `9080` 的出站 HTTP 请求,它将被传递给 `0.0.0.0:9080` 的虚拟监听器。这一监听器将检索在它配置的 RDS 里的路由配置。在这个例子中它将寻找 Istiod(通过 ADS配置在 RDS 中的路由 `9080`
{{< text bash json >}}
$ istioctl proxy-config listeners productpage-v1-6c886ff494-7vxhs -o json --address 0.0.0.0 --port 9080
@ -223,22 +266,25 @@ istio-egressgateway.istio-system.svc.cluster.local
"reviews.default.svc:9080",
"reviews.default",
"reviews.default:9080",
"172.21.152.34",
"172.21.152.34:9080"
"10.98.88.0",
"10.98.88.0:9080"
],
"routes": [
{
"name": "default",
"match": {
"prefix": "/"
},
"route": {
"cluster": "outbound|9080||reviews.default.svc.cluster.local",
"timeout": "0.000s"
},
"timeout": "0s",
}
}
]
...
{{< /text >}}
1. 此集群配置为从 Pilot(通过 ADS检索关联的 endpoints。所以 Envoy 会使用 `serviceName` 字段作为主键,来检查 endpoint 列表并把请求代理到其中之一。
1. 此集群配置为从 Istiod(通过 ADS检索关联的 endpoints。所以 Envoy 会使用 `serviceName` 字段作为主键,来检查 endpoint 列表并把请求代理到其中之一。
{{< text bash json >}}
$ istioctl proxy-config cluster productpage-v1-6c886ff494-7vxhs --fqdn reviews.default.svc.cluster.local -o json
@ -248,16 +294,22 @@ istio-egressgateway.istio-system.svc.cluster.local
"type": "EDS",
"edsClusterConfig": {
"edsConfig": {
"ads": {}
"ads": {},
"resourceApiVersion": "V3"
},
"serviceName": "outbound|9080||reviews.default.svc.cluster.local"
},
"connectTimeout": "1.000s",
"connectTimeout": "10s",
"circuitBreakers": {
"thresholds": [
{}
{
"maxConnections": 4294967295,
"maxPendingRequests": 4294967295,
"maxRequests": 4294967295,
"maxRetries": 4294967295
}
]
}
},
}
]
{{< /text >}}
@ -266,15 +318,15 @@ istio-egressgateway.istio-system.svc.cluster.local
{{< text bash json >}}
$ istioctl proxy-config endpoints productpage-v1-6c886ff494-7vxhs --cluster "outbound|9080||reviews.default.svc.cluster.local"
ENDPOINT STATUS OUTLIER CHECK CLUSTER
172.17.0.17:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.18:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.5:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
ENDPOINT STATUS OUTLIER CHECK CLUSTER
172.17.0.7:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.8:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.9:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
{{< /text >}}
## 检查 bootstrap 配置{#inspecting-bootstrap-configuration}
到目前为止,我们已经查看了从 Pilot 检索到的配置(大部分),然而 Envoy 需要一些 bootstrap 配置,其中包括诸如在何处可以找到 Pilot 之类的信息。使用下面的命令查看:
到目前为止,我们已经查看了从 Istiod 检索到的配置(大部分),然而 Envoy 需要一些 bootstrap 配置,其中包括诸如在何处可以找到 Istiod 之类的信息。使用下面的命令查看:
{{< text bash json >}}
$ istioctl proxy-config bootstrap -n istio-system istio-ingressgateway-7d6874b48f-qxhn5
@ -284,51 +336,72 @@ $ istioctl proxy-config bootstrap -n istio-system istio-ingressgateway-7d6874b48
"id": "router~172.30.86.14~istio-ingressgateway-7d6874b48f-qxhn5.istio-system~istio-system.svc.cluster.local",
"cluster": "istio-ingressgateway",
"metadata": {
"POD_NAME": "istio-ingressgateway-7d6874b48f-qxhn5",
"istio": "sidecar"
"CLUSTER_ID": "Kubernetes",
"EXCHANGE_KEYS": "NAME,NAMESPACE,INSTANCE_IPS,LABELS,OWNER,PLATFORM_METADATA,WORKLOAD_NAME,MESH_ID,SERVICE_ACCOUNT,CLUSTER_ID",
"INSTANCE_IPS": "10.244.0.7",
"ISTIO_PROXY_SHA": "istio-proxy:f98b7e538920abc408fbc91c22a3b32bc854d9dc",
"ISTIO_VERSION": "1.7.0",
"LABELS": {
"app": "istio-ingressgateway",
"chart": "gateways",
"heritage": "Tiller",
"istio": "ingressgateway",
"pod-template-hash": "68bf7d7f94",
"release": "istio",
"service.istio.io/canonical-name": "istio-ingressgateway",
"service.istio.io/canonical-revision": "latest"
},
"MESH_ID": "cluster.local",
"NAME": "istio-ingressgateway-68bf7d7f94-sp226",
"NAMESPACE": "istio-system",
"OWNER": "kubernetes://apis/apps/v1/namespaces/istio-system/deployments/istio-ingressgateway",
"ROUTER_MODE": "sni-dnat",
"SDS": "true",
"SERVICE_ACCOUNT": "istio-ingressgateway-service-account",
"WORKLOAD_NAME": "istio-ingressgateway"
},
"buildVersion": "0/1.8.0-dev//RELEASE"
"userAgentBuildVersion": {
"version": {
"majorNumber": 1,
"minorNumber": 15
},
"metadata": {
"build.type": "RELEASE",
"revision.sha": "f98b7e538920abc408fbc91c22a3b32bc854d9dc",
"revision.status": "Clean",
"ssl.version": "BoringSSL"
}
},
},
...
{{< /text >}}
## 验证到 Istio Pilot 的连通性{#verifying-connectivity-to-Istio-pilot}
## 验证到 Istiod 的连通性{#verifying-connectivity-to-Istiod}
验证与 Pilot 的连通性是一个有用的故障排除步骤。服务网格内的每个代理容器都应该能和 Pilot 通信。这可以通过几个简单的步骤来实现:
验证与 Istiod 的连通性是一个有用的故障排除步骤。服务网格内的每个代理容器都应该能和 Istiod 通信。这可以通过几个简单的步骤来实现:
1. 获取 Istio Ingress pod 的名称:
1. 创建一个 `sleep` pod
{{< text bash >}}
$ INGRESS_POD_NAME=$(kubectl get po -n istio-system | grep ingressgateway\- | awk '{print$1}'); echo ${INGRESS_POD_NAME};
$ kubectl create namespace foo
$ kubectl apply -f <(istioctl kube-inject -f samples/sleep/sleep.yaml) -n foo
{{< /text >}}
1. 通过 exec 进入 Istio Ingress pod
1. 使用`curl`测试 Istiod 的连接。下面的示例使用默认 Istiod 配置参数和启用相互 TLS 调用 v1 注册 API
{{< text bash >}}
$ kubectl exec -it $INGRESS_POD_NAME -n istio-system /bin/bash
$ kubectl exec $(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name}) -c sleep -n foo -- curl -sS istiod.istio-system:15014/debug/endpointz
{{< /text >}}
1. 使用 `curl` 测试与 Pilot 的连通性。下面的示例使用了默认的 Pilot 配置参数和开启双向 TLS 来调用 v1 注册 API
{{< text bash >}}
$ curl -k --cert /etc/certs/cert-chain.pem --cacert /etc/certs/root-cert.pem --key /etc/certs/key.pem https://istio-pilot:8080/debug/edsz
{{< /text >}}
如果双向 TLS 是关闭的:
{{< text bash >}}
$ curl http://istio-pilot:8080/debug/edsz
{{< /text >}}
对网格内的每个服务,您将会收到一个响应,列举了 "service-key" 和 "hosts"。
您应该收到一个响应,其中列出了网格中每个服务的“服务”和“端点”。
## Istio 使用的 Envoy 版本是什么?{#what-envoy-version-is-Istio-using}
要在部署中找出 Envoy 的版本,您可以通过 `exec` 进入容器并查询 `server_info` endpoint
要在部署中找出 Envoy 的版本,您可以通过 `exec` 进入容器并查询 `server_info` 终端:
{{< text bash >}}
$ kubectl exec -it PODNAME -c istio-proxy -n NAMESPACE pilot-agent request GET server_info
$ kubectl exec -it productpage-v1-6b746f74dc-9stvs -c istio-proxy -n default -- pilot-agent request GET server_info --log_as_json | jq {version}
{
"version": "48bc83d8f0582fc060ef76d5aa3d75400e739d9e/1.12.0-dev/Clean/RELEASE/BoringSSL"
"version": "2d4ec97f3ac7b3256d060e1bb8aa6c415f5cef63/1.17.0/Clean/RELEASE/BoringSSL"
}
{{< /text >}}
{{< /text >}}