mirror of https://github.com/istio/istio.io.git
* Sync #14445 into Chinese * Apply suggestions from code review Co-authored-by: Michael <haifeng.yao@daocloud.io> --------- Co-authored-by: Michael <haifeng.yao@daocloud.io>
This commit is contained in:
parent
533639e329
commit
fb785d143e
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
---
|
||||
{{< tip >}}
|
||||
{{< boilerplate gateway-api-future >}}
|
||||
{{< boilerplate gateway-api-choose >}}
|
||||
{{< /tip >}}
|
||||
|
||||
{{< warning >}}
|
||||
以下 Gateway API 指令包括 [Experimental(实验)](https://gateway-api.sigs.k8s.io/geps/overview/#status)以及
|
||||
Istio 特定的功能。在使用 Gateway API 指令之前,请确保安装**实验版本**的 Gateway API CRD:
|
||||
|
||||
{{< text syntax=bash snip_id=install_experimental_crds >}}
|
||||
$ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref={{< k8s_gateway_api_version >}}" | kubectl apply -f -
|
||||
{{< /text >}}
|
||||
|
||||
{{< /warning >}}
|
|
@ -8,7 +8,7 @@
|
|||
{{< warning >}}
|
||||
请注意,本文使用 Gateway API 配置内部网格(东西)流量,即不仅是 Ingress(南北)流量。
|
||||
使用 Gateway API 配置内部网格流量目前是一个还在开发的[实验性特性](https://gateway-api.sigs.k8s.io/geps/overview/#status)。
|
||||
若使用 Gateway API 指令,请先确保:
|
||||
在使用 Gateway API 指令之前,请确保:
|
||||
|
||||
1) 安装 **实验版本** 的 Gateway API CRD:
|
||||
|
||||
|
|
|
@ -243,10 +243,11 @@ Istio 代理允许调用未知的服务。如果这个选项设置为 `REGISTRY_
|
|||
|
||||
### 管理到外部服务的流量 {#manage-traffic-to-external-services}
|
||||
|
||||
与集群内的请求相似,也可以为使用 `ServiceEntry` 配置访问的外部服务设置
|
||||
[Istio 路由规则](/zh/docs/concepts/traffic-management/#routing-rules)。
|
||||
与集群间请求类似,可以为使用 `ServiceEntry` 配置访问的外部服务设置路由规则。
|
||||
在本示例中,您将设置对 `httpbin.org` 服务访问的超时规则。
|
||||
|
||||
{{< boilerplate gateway-api-experimental >}}
|
||||
|
||||
1. 从用作测试源的 Pod 内部,向外部服务 `httpbin.org` 的 `/delay`
|
||||
endpoint 发出 **curl** 请求:
|
||||
|
||||
|
@ -262,23 +263,59 @@ Istio 代理允许调用未知的服务。如果这个选项设置为 `REGISTRY_
|
|||
|
||||
1. 退出测试源 Pod,使用 `kubectl` 设置调用外部服务 `httpbin.org` 的超时时间为 3 秒。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
http:
|
||||
- timeout: 3s
|
||||
route:
|
||||
- destination:
|
||||
host: httpbin.org
|
||||
weight: 100
|
||||
EOF
|
||||
{{< /text >}}
|
||||
{{< tabset category-name="config-api" >}}
|
||||
|
||||
{{< tab name="Istio APIs" category-value="istio-apis" >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
http:
|
||||
- timeout: 3s
|
||||
route:
|
||||
- destination:
|
||||
host: httpbin.org
|
||||
weight: 100
|
||||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
{{< /tab >}}
|
||||
|
||||
{{< tab name="Gateway API" category-value="gateway-api" >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
parentRefs:
|
||||
- kind: ServiceEntry
|
||||
group: networking.istio.io
|
||||
name: httpbin-ext
|
||||
hostnames:
|
||||
- httpbin.org
|
||||
rules:
|
||||
- timeouts:
|
||||
request: 3s
|
||||
backendRefs:
|
||||
- kind: Hostname
|
||||
group: networking.istio.io
|
||||
name: httpbin.org
|
||||
port: 80
|
||||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
{{< /tab >}}
|
||||
|
||||
{{< /tabset >}}
|
||||
|
||||
1. 几秒后,重新发出 **curl** 请求:
|
||||
|
||||
|
@ -295,11 +332,28 @@ Istio 代理允许调用未知的服务。如果这个选项设置为 `REGISTRY_
|
|||
|
||||
### 清理对外部服务的受控访问 {#cleanup-the-controlled-access-to-external-services}
|
||||
|
||||
{{< tabset category-name="config-api" >}}
|
||||
|
||||
{{< tab name="Istio APIs" category-value="istio-apis" >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete serviceentry httpbin-ext google
|
||||
$ kubectl delete virtualservice httpbin-ext --ignore-not-found=true
|
||||
{{< /text >}}
|
||||
|
||||
{{< /tab >}}
|
||||
|
||||
{{< tab name="Gateway API" category-value="gateway-api" >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete serviceentry httpbin-ext
|
||||
$ kubectl delete httproute httpbin-ext --ignore-not-found=true
|
||||
{{< /text >}}
|
||||
|
||||
{{< /tab >}}
|
||||
|
||||
{{< /tabset >}}
|
||||
|
||||
## 直接访问外部服务 {#direct-access-to-external-services}
|
||||
|
||||
如果要让特定范围的 IP 完全绕过 Istio,则可以配置 Envoy Sidecar
|
||||
|
|
Loading…
Reference in New Issue