zh-translation: docs/ops/configuration/traffic-management/protocol-se… (#9259)

* zh-translation: docs/ops/configuration/traffic-management/protocol-selection/index.md

* zh-translation: docs/ops/configuration/traffic-management/protocol-selection/index.md

* zh-translation: docs/ops/configuration/traffic-management/protocol-selection/index.md modify

* zh-translation: docs/ops/configuration/traffic-management/protocol-selection/index.md modify
This commit is contained in:
orangegzx 2021-03-17 10:35:52 +08:00 committed by GitHub
parent 2377bb313d
commit 4e44c9aadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 28 deletions

View File

@ -1,6 +1,6 @@
---
title: 协议选择
description: 关于怎么声明协议的信息
description: 关于如何声明协议
weight: 10
keywords: [protocol,protocol sniffing,protocol selection,protocol detection]
aliases:
@ -8,31 +8,50 @@ aliases:
- /zh/help/ops/protocol-selection
- /zh/help/tasks/traffic-management/protocol-selection
- /zh/docs/ops/traffic-management/protocol-selection
owner: istio/wg-networking-maintainers
test: no
---
Istio 默认支持代理所有 TCP 流量,但为了提供附加的能力,比如路由和丰富的指标,使用什么协议必须被确定。协议可以被自动检测或者明确的声明确定。
Istio 默认支持代理所有 TCP 流量。包括 HTTP、HTTPS、gRPC 以及原始 TCP 协议。但为了提供额外的能力,比如路由和丰富的指标,必须确定协议。协议可以被自动检测或者手动声明。
使用非基于 TCP 的协议时,如 UDP不会被 Istio 代理拦截,可以继续正常工作。但是不能在仅代理的组件中使用,如 Ingress 或 Egress Gateway。
## 自动协议选择{#automatic-protocol-selection}
Istio 可以自动检测出 HTTP 和 HTTP/2 流量。如果未自动检测出协议,流量将会视为普通 TCP 流量。
{{< tip >}}
Server First 协议,如 MySQL不兼容自动协议选择。
查看更多[Server First 协议](/zh/docs/ops/deployment/requirements#server-first-protocols)
{{< /tip >}}
## 手动协议选择{#manual-protocol-selection}
通过声明一个 Service 端口,协议可以被手动指定 `name: <protocol>[-<suffix>]`
下列协议是被支持的:
协议可以在 Service 定义中手动指定。
- `grpc`
- `grpc-web`
- `http`
- `http2`
- `https`
- `mongo`
- `mysql`\*
- `redis`\*
- `tcp`
- `tls`
- `udp`
可以通过以下两种方式配置:
\* 这些协议默认被禁用以阻止偶然地产生试验性的特性
要启用他们,请配置相应的 Pilot [环境变量](/zh/docs/reference/commands/pilot-discovery/#envvars)
- 通过端口名称配置:`name: <protocol>[-<suffix>]`。
- 在版本 1.18+ 的Kubernetes通过 `appProtocol` 字段配置:`appProtocol: <protocol>`。
下面是一个 Service 例子,它定义了一个 `mysql` 端口 和一个 `http` 端口:
支持以下协议:
- `HTTP`
- `HTTP2`
- `HTTPS`
- `TCP`
- `TLS`
- `gRPC`
- `gRPC-Web`
- `Mongo`
- `MySQL`\*
- `Redis`\*
- `UDP` (UDP 不会被代理,但可以将端口指定为 UDP)
\* 在默认情况下,这些协议是禁用的,目的是避免无意启用 Experimental Feature。
如需启用它们,需配置相应的 Pilot [环境变量](/zh/docs/reference/commands/pilot-discovery/#envvars)。
例如Service 通过 `appProtocol` 、名称分别定义一个 `mysql` 端口和一个 `http` 端口:
{{< text yaml >}}
kind: Service
@ -41,16 +60,8 @@ metadata:
spec:
ports:
- number: 3306
name: mysql
name: database
appProtocol: mysql
- number: 80
name: http-web
{{< /text >}}
## 自动协议选择{#automatic-protocol-selection}
Istio 可以自动检测出 HTTP 和 HTTP/2 流量。如果协议无法自动确定,流量将会被当作普通 TCP 流量对待。
这个特性是默认开启的。通过设置这些安装选项可以将其关闭:
- `--set values.pilot.enableProtocolSniffingForOutbound=false` 为(非指定的或不支持协议的)出站监听器禁用协议检测。
- `--set values.pilot.enableProtocolSniffingForInbound=false` 为(非指定的或不支持协议的)入站监听器禁用协议检测。