mirror of https://github.com/istio/istio.io.git
zh: content/docs/tasks/traffic-management/secure-ingress/index.md (#2678)
This commit is contained in:
parent
531bda2945
commit
e684ce75b8
|
|
@ -5,54 +5,54 @@ weight: 31
|
|||
keywords: [流量管理,ingress]
|
||||
---
|
||||
|
||||
> 本文任务使用了新的 [v1alpha3 流量控制 API](/zh/blog/2018/v1alpha3-routing/)。旧版本 API 已经过时,会在下一个 Istio 版本中移除。如果需要使用旧版本 API,请阅读[旧版本文档](https://archive.istio.io/v0.7/docs/tasks/traffic-management/)
|
||||
|
||||
[控制 Ingress 流量](/zh/docs/tasks/traffic-management/ingress)任务描述了如何对 Ingress gateway 进行配置,从而对外以 HTTP 端点的形式暴露服务。本文中将会对这一任务进行扩展,为服务启用普通或双向 TLS 保护,以 HTTPS 的形式对网格外提供服务。
|
||||
|
||||
## 开始之前
|
||||
|
||||
1. 执行[开始之前](/zh/docs/tasks/traffic-management/ingress/#前提条件)的步骤,并且[确定 Ingress 地址和端口](/zh/docs/tasks/traffic-management/ingress/#确定入口-ip-和端口)。在完成这些步骤后,应该已经部署了可用的 Istio 服务网格以及 [httpbin]({{< github_tree >}}/samples/httpbin) 应用了,并且 `INGRESS_HOST` 和 `SECURE_INGRESS_PORT` 这两个变量也已经生成并赋值。
|
||||
1. 执行[开始之前](/zh/docs/tasks/traffic-management/ingress/#前提条件)的步骤,并且[确定 Ingress 地址和端口](/zh/docs/tasks/traffic-management/ingress/#确定入口-ip-和端口)。在完成这些步骤后,应该已经部署了可用的 Istio 服务网格以及 [httpbin]({{< github_tree >}}/samples/httpbin) 应用了,并且 `INGRESS_HOST` 和 `SECURE_INGRESS_PORT` 这两个变量也已经生成并赋值。
|
||||
|
||||
1. macOS 用户需要注意,要检查一下 `curl` 的编译是否包含了 [LibreSSL](http://www.libressl.org) 库:
|
||||
1. macOS 用户需要注意,要检查一下 `curl` 的编译是否包含了 [LibreSSL](http://www.libressl.org) 库:
|
||||
|
||||
{{< text bash >}}
|
||||
$ curl --version | grep LibreSSL
|
||||
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
|
||||
{{< /text >}}
|
||||
|
||||
如果命令输出中包含了 _LibreSSL_ ,那么 `curl` 命令就是适合于本文任务的。否则就要尝试使用其他的 `curl` 了,例如使用 Linux 系统。
|
||||
如果上面的命令输出中包含了 _LibreSSL_ ,那么 `curl` 命令就是适合于本文任务的。
|
||||
否则就要尝试使用其他的 `curl` 了,例如使用 Linux 系统。
|
||||
|
||||
## 生成客户端与服务器的证书和密钥
|
||||
|
||||
这里可以使用任意工具来生成证书和密钥,下面我们使用了[一个脚本](https://github.com/nicholasjackson/mtls-go-example/blob/master/generate.sh):
|
||||
对于此任务,您可以使用自己喜欢的工具生成证书和密钥。此示例使用[脚本](https://github.com/nicholasjackson/mtls-go-example/blob/master/generate.sh)
|
||||
来自 <https://github.com/nicholasjackson/mtls-go-example> 存储库。
|
||||
|
||||
1. 克隆 <https://github.com/nicholasjackson/mtls-go-example> 仓库:
|
||||
1. 克隆 <https://github.com/nicholasjackson/mtls-go-example> 仓库:
|
||||
|
||||
{{< text bash >}}
|
||||
$ git clone https://github.com/nicholasjackson/mtls-go-example
|
||||
{{< /text >}}
|
||||
|
||||
1. 进入代码目录:
|
||||
1. 进入代码目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ pushd mtls-go-example
|
||||
{{< /text >}}
|
||||
|
||||
1. 使用以下的命令(密码任意指定)为 `httpbin.example.com` 生成证书:
|
||||
1. 为 `httpbin.example.com` 生成证书。将以下命令中 `password` 改为您喜欢的任何值:
|
||||
|
||||
{{< text bash >}}
|
||||
$ ./generate.sh httpbin.example.com <password>
|
||||
$ ./generate.sh httpbin.example.com password
|
||||
{{< /text >}}
|
||||
|
||||
所有提示问题都选择 `y`。这一命令会生成四个目录: `1_root`、`2_intermediate`、`3_application` 以及 `4_client`,其中包含了后续步骤所需的客户端和服务器的证书。
|
||||
|
||||
1. 将证书移动到 `httpbin.example.com` 目录:
|
||||
1. 将证书移动到 `httpbin.example.com` 目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ mkdir ~+1/httpbin.example.com && mv 1_root 2_intermediate 3_application 4_client ~+1/httpbin.example.com
|
||||
{{< /text >}}
|
||||
|
||||
1. 更改目录:
|
||||
1. 更改目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ popd
|
||||
|
|
@ -71,9 +71,10 @@ keywords: [流量管理,ingress]
|
|||
secret "istio-ingressgateway-certs" created
|
||||
{{< /text >}}
|
||||
|
||||
注意缺省情况下,`istio-system` 命名空间中所有的 Service account 都是可以访问 Secret 的,所以可能会泄漏私钥。可以通过 [RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) 设置来进行对涉密数据的保护。
|
||||
注意 默认情况下,`istio-system` 命名空间中所有的 Service account 都是可以访问 Secret 的,
|
||||
所以可能会泄漏私钥。可以通过 [Role-Based Access Control (RBAC)](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) 设置来进行对涉密数据的保护。
|
||||
|
||||
1. 定义一个 Gateway 对象,其中包含了使用 443 端口的 `server` 部分。
|
||||
1. 定义一个 Gateway 对象,其中包含了使用 443 端口的 `server` 部分。
|
||||
|
||||
> 证书的私钥的位置 **必须** 是 `/etc/istio/ingressgateway-certs`,否则 Gateway 无法载入。
|
||||
|
||||
|
|
@ -85,7 +86,7 @@ keywords: [流量管理,ingress]
|
|||
name: mygateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # 使用 Istio 的缺省 Gateway
|
||||
istio: ingressgateway # 使用 Istio 默认的 Gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 443
|
||||
|
|
@ -100,7 +101,7 @@ keywords: [流量管理,ingress]
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
1. 为通过 Gateway 进入的流量进行路由配置。配置一个和[控制 Ingress 流量任务](/zh/docs/tasks/traffic-management/ingress/#使用-istio-网关配置-ingress) 中一致的 `Virtualservice`:
|
||||
1. 为通过 Gateway 进入的流量进行路由配置。配置一个和[控制 Ingress 流量任务](/zh/docs/tasks/traffic-management/ingress/#使用-istio-网关配置-ingress) 中一致的 `Virtualservice`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
|
|
@ -127,14 +128,14 @@ keywords: [流量管理,ingress]
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
1. 用 `curl` 发送 `https` 请求到 `SECURE_INGRESS_PORT`,也就是通过 HTTPS 协议访问 `httpbin` 服务。
|
||||
1. 用 `curl` 发送 `https` 请求到 `SECURE_INGRESS_PORT`,也就是通过 HTTPS 协议访问 `httpbin` 服务。
|
||||
|
||||
`--resolve` 选项要求 `curl` 通过域名 `httpbin.example.com` 使用 TLS 访问 Gateway 地址,这样也就符合了证书的 [SNI](https://en.wikipedia.org/wiki/Server_Name_Indication) 要求。`--cacert` 参数则让 `curl` 命令使用刚刚生成的证书来对服务器进行校验。
|
||||
|
||||
发送请求到 `/status/418`,会看到漂亮的返回内容,这说明我们成功访问了 `httpbin`。`httpbin` 服务会返回 [418 I'm a Teapot](https://tools.ietf.org/html/rfc7168#section-2.3.3)。
|
||||
|
||||
{{< text bash >}}
|
||||
$ curl -v --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
$ curl -v -HHost:httpbin.example.com --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
...
|
||||
Server certificate:
|
||||
subject: C=US; ST=Denial; L=Springfield; O=Dis; CN=httpbin.example.com
|
||||
|
|
@ -162,8 +163,6 @@ keywords: [流量管理,ingress]
|
|||
|
||||
查看 `curl` 命令返回内容中的 `Server certificate` 部分,注意其中的 `common name`:`common name: httpbin.example.com (matched)`。另外输出中还包含了 `SSL certificate verify ok`,这说明对服务器的证书校验是成功的,返回状态码为 418 和一个茶壶画。
|
||||
|
||||
如果需要支持 [双向 TLS](https://en.wikipedia.org/wiki/Mutual_authentication) ,请继续下一节内容。
|
||||
|
||||
## 配置 Ingress gateway 的双向 TLS 支持
|
||||
|
||||
这一节中会再次对 Gateway 定义进行扩展,从而在从外部客户端到 Gateway 的访问中添加对 [双向 TLS](https://en.wikipedia.org/wiki/Mutual_authentication) 的支持。
|
||||
|
|
@ -177,7 +176,7 @@ keywords: [流量管理,ingress]
|
|||
secret "istio-ingressgateway-ca-certs" created
|
||||
{{< /text >}}
|
||||
|
||||
1. 重新定义之前的 Gateway,把其中的 `tls` 一节的 `mode` 字段的值修改为 `MUTUAL`,并给 `caCertificates` 赋值:
|
||||
1. 重新定义之前的 Gateway,把其中的 `tls` 一节的 `mode` 字段的值修改为 `MUTUAL`,并给 `caCertificates` 赋值:
|
||||
|
||||
> 证书的位置 **必须** 是 `/etc/istio/ingressgateway-ca-certs`,否则 Gateway 无法加载。证书的文件名必须和创建 Secret 时使用的文件名一致,这里就是 `ca-chain.cert.pem`
|
||||
|
||||
|
|
@ -189,7 +188,7 @@ keywords: [流量管理,ingress]
|
|||
name: mygateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # 是用缺省的 Istio Gateway
|
||||
istio: ingressgateway # 使用 Istio 默认的 Gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 443
|
||||
|
|
@ -205,11 +204,11 @@ keywords: [流量管理,ingress]
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
1. 同样的使用 HTTPS 方式访问 `httpbin` 服务:
|
||||
1. 同样的使用 HTTPS 方式访问 `httpbin` 服务:
|
||||
|
||||
{{< text bash >}}
|
||||
|
||||
$ curl --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
$ curl -HHost:httpbin.example.com --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
curl: (35) error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
|
||||
{{< /text >}}
|
||||
|
||||
|
|
@ -217,10 +216,10 @@ keywords: [流量管理,ingress]
|
|||
|
||||
因为服务拒绝接受未经验证的请求,这次访问会得到一个错误返回。因此这次调用必须使用客户端证书,并且需要把密钥传递给 `curl` ,从而完成对请求的签名过程。
|
||||
|
||||
1. 再次使用 `curl` 命令发送请求,这次的参数加入了客户端证书(`--cert`)以及私钥(`--key`):
|
||||
1. 再次使用 `curl` 命令发送请求,这次的参数加入了客户端证书(`--cert`)以及私钥(`--key`):
|
||||
|
||||
{{< text bash >}}
|
||||
$ curl --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert 2_intermediate/certs/ca-chain.cert.pem --cert 4_client/certs/httpbin.example.com.cert.pem --key 4_client/private/httpbin.example.com.key.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
$ curl -HHost:httpbin.example.com --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem --cert httpbin.example.com/4_client/certs/httpbin.example.com.cert.pem --key httpbin.example.com/4_client/private/httpbin.example.com.key.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
|
||||
-=[ teapot ]=-
|
||||
|
||||
|
|
@ -241,29 +240,30 @@ keywords: [流量管理,ingress]
|
|||
|
||||
### 为 `bookinfo.com` 生成客户端和服务器证书和密钥
|
||||
|
||||
在本小节中,执行与[生成客户端和服务器证书和密钥](/zh/docs/tasks/traffic-management/secure-ingress/#生成客户端与服务器的证书和密钥)子部分相同的步骤。为方便起见,我在下面列出它们。
|
||||
执行与[生成客户端和服务器证书和密钥](#生成客户端与服务器的证书和密钥)相同的步骤,
|
||||
仅适用于主机 `bookinfo.com` 而不是 `httpbin.example.com`。
|
||||
|
||||
1. 进入代码目录:
|
||||
1. 进入代码目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ pushd mtls-go-example
|
||||
{{< /text >}}
|
||||
|
||||
1. 使用以下的命令(密码任意指定)为 `httpbin.example.com` 生成证书:
|
||||
1. 为 `bookinfo.com` 生成证书。将以下命令中 `password` 改为您喜欢的任何值:
|
||||
|
||||
{{< text bash >}}
|
||||
$ ./generate.sh bookinfo.com <password>
|
||||
$ ./generate.sh bookinfo.com password
|
||||
{{< /text >}}
|
||||
|
||||
出现提示时,为所有问题选择 `y` 。
|
||||
|
||||
1. 将证书移动到 `bookinfo.com` 目录:
|
||||
1. 将证书移动到 `bookinfo.com` 目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ mkdir ~+1/bookinfo.com && mv 1_root 2_intermediate 3_application 4_client ~+1/bookinfo.com
|
||||
{{< /text >}}
|
||||
|
||||
1. 更改目录:
|
||||
1. 更改目录:
|
||||
|
||||
{{< text bash >}}
|
||||
$ popd
|
||||
|
|
@ -278,7 +278,7 @@ keywords: [流量管理,ingress]
|
|||
secret "istio-ingressgateway-bookinfo-certs" created
|
||||
{{< /text >}}
|
||||
|
||||
1. 通过使用新 Secret 的 volume 生成部署 `istio-ingressgateway` 的 deployment。生成 `istio.yaml` 时使用与生成 `istio-ingressgateway` 相同的选项:
|
||||
1. 通过使用新 Secret 的 volume 生成部署 `istio-ingressgateway` 的 deployment。生成 `istio.yaml` 时使用与生成 `istio-ingressgateway` 相同的选项:
|
||||
|
||||
{{< text bash >}}
|
||||
$ helm template install/kubernetes/helm/istio/ --name istio-ingressgateway --namespace istio-system -x charts/gateways/templates/deployment.yaml --set gateways.istio-egressgateway.enabled=false \
|
||||
|
|
@ -294,14 +294,14 @@ keywords: [流量管理,ingress]
|
|||
$HOME/istio-ingressgateway.yaml
|
||||
{{< /text >}}
|
||||
|
||||
1. 重新部署 `istio-ingressgateway`:
|
||||
1. 重新部署 `istio-ingressgateway`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f $HOME/istio-ingressgateway.yaml
|
||||
deployment "istio-ingressgateway" configured
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证密钥和证书是否已成功加载到 `istio-ingressgateway` pod 中:
|
||||
1. 验证密钥和证书是否已成功加载到 `istio-ingressgateway` pod 中:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-bookinfo-certs
|
||||
|
|
@ -311,13 +311,13 @@ keywords: [流量管理,ingress]
|
|||
|
||||
### 配置 `bookinfo.com` 主机的流量
|
||||
|
||||
1. 在没有网关的情况下部署 [Bookinfo 示例应用程序](/zh/docs/examples/bookinfo/):
|
||||
1. 在没有网关的情况下部署 [Bookinfo 示例应用程序](/zh/docs/examples/bookinfo/):
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
|
||||
{{< /text >}}
|
||||
|
||||
1. 使用 `bookinfo.com` 的主机重新部署 `Gateway` :
|
||||
1. 使用 `bookinfo.com` 的主机重新部署 `Gateway` :
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
|
|
@ -352,7 +352,7 @@ keywords: [流量管理,ingress]
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
1. 配置 `bookinfo.com` 的路由。定义一个类似于 [`samples/bookinfo/networking/bookinfo-gateway.yaml`]({{<github_file>}}/samples/bookinfo/networking/bookinfo-gateway.yaml) 中的 `VirtualService` :
|
||||
1. 配置 `bookinfo.com` 的路由。定义一个类似于 [`samples/bookinfo/networking/bookinfo-gateway.yaml`]({{<github_file>}}/samples/bookinfo/networking/bookinfo-gateway.yaml) 中的 `VirtualService` :
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
|
|
@ -383,10 +383,10 @@ keywords: [流量管理,ingress]
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
1. 向 _Bookinfo_ `productpage` 发送请求:
|
||||
1. 向 _Bookinfo_ `productpage` 发送请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ curl -o /dev/null -s -v -w "%{http_code}\n" --resolve bookinfo.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert bookinfo.com/2_intermediate/certs/ca-chain.cert.pem -HHost:bookinfo.com https://bookinfo.com:$SECURE_INGRESS_PORT/productpage
|
||||
$ curl -o /dev/null -s -v -w "%{http_code}\n" -HHost:bookinfo.com --resolve bookinfo.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert bookinfo.com/2_intermediate/certs/ca-chain.cert.pem -HHost:bookinfo.com https://bookinfo.com:$SECURE_INGRESS_PORT/productpage
|
||||
...
|
||||
Server certificate:
|
||||
subject: C=US; ST=Denial; L=Springfield; O=Dis; CN=bookinfo.com
|
||||
|
|
@ -399,10 +399,10 @@ keywords: [流量管理,ingress]
|
|||
200
|
||||
{{< /text >}}
|
||||
|
||||
1. 像以前一样访问 `httbin.example.com` 的方式验证一下。向它发送请求,你应该再次看到喜欢的茶壶画:
|
||||
1. 像以前一样访问 `httbin.example.com` 的方式验证一下。向它发送请求,你应该再次看到喜欢的茶壶画:
|
||||
|
||||
{{< text bash >}}
|
||||
$ curl -v --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
$ curl -v -HHost:httpbin.example.com --resolve httpbin.example.com:$SECURE_INGRESS_PORT:$INGRESS_HOST --cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem https://httpbin.example.com:$SECURE_INGRESS_PORT/status/418
|
||||
...
|
||||
-=[ teapot ]=-
|
||||
|
||||
|
|
@ -417,14 +417,14 @@ keywords: [流量管理,ingress]
|
|||
|
||||
## 常见问题
|
||||
|
||||
1. 查看 `INGRESS_HOST` 以及 `SECURE_INGRESS_PORT` 这两个环境变量,确定它们的正确取值,具体命令:
|
||||
1. 查看 `INGRESS_HOST` 以及 `SECURE_INGRESS_PORT` 这两个环境变量,确定它们的正确取值,具体命令:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl get svc -n istio-system
|
||||
$ echo INGRESS_HOST=$INGRESS_HOST, SECURE_INGRESS_PORT=$SECURE_INGRESS_PORT
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 `istio-ingressgateway` Pod 是否正确的加载了证书和私钥:
|
||||
1. 检查 `istio-ingressgateway` Pod 是否正确的加载了证书和私钥:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-certs
|
||||
|
|
@ -432,14 +432,14 @@ keywords: [流量管理,ingress]
|
|||
|
||||
`tls.crt` 和 `tls.key` 都应该保存在这个目录中。
|
||||
|
||||
1. 检查 Ingress gateway 证书中的 `Subject` 字段的正确性:
|
||||
1. 检查 Ingress gateway 证书中的 `Subject` 字段的正确性:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -i -n istio-system $(kubectl get pod -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].metadata.name}') -- cat /etc/istio/ingressgateway-certs/tls.crt | openssl x509 -text -noout | grep 'Subject:'
|
||||
Subject: C=US, ST=Denial, L=Springfield, O=Dis, CN=httpbin.example.com
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 Ingress gateway 的代理能够正确访问证书:
|
||||
1. 检查 Ingress gateway 的代理能够正确访问证书:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -ti $(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath={.items[0]..metadata.name}) -n istio-system -- curl 127.0.0.1:15000/certs
|
||||
|
|
@ -449,7 +449,7 @@ keywords: [流量管理,ingress]
|
|||
}
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 `istio-ingressgateway` 中的错误信息:
|
||||
1. 检查 `istio-ingressgateway` 中的错误信息:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl logs -n istio-system -l istio=ingressgateway
|
||||
|
|
@ -461,13 +461,13 @@ keywords: [流量管理,ingress]
|
|||
$ kubectl delete pod -n istio-system -l istio=ingressgateway
|
||||
{{< /text >}}
|
||||
|
||||
1. macOS 用户,检查 `curl` 是否包含 [LibreSSL](http://www.libressl.org) 库,和[开始之前](#开始之前)中提到的一样。
|
||||
1. macOS 用户,检查 `curl` 是否包含 [LibreSSL](http://www.libressl.org) 库,和[开始之前](#开始之前)中提到的一样。
|
||||
|
||||
### 双向 TLS 常见问题
|
||||
|
||||
除去刚才提到的内容之外,执行下列检查:
|
||||
|
||||
1. 检查 `istio-ingressgateway` Pod 是否正确加载 CA 证书:
|
||||
1. 检查 `istio-ingressgateway` Pod 是否正确加载 CA 证书:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-ca-certs
|
||||
|
|
@ -475,16 +475,22 @@ keywords: [流量管理,ingress]
|
|||
|
||||
`ca-chain.cert.pem` 应该保存在这个路径中。
|
||||
|
||||
1. 检查 Ingress gateway 中 CA 证书的 `Subject` 字段内容:
|
||||
1. 检查 Ingress gateway 中 CA 证书的 `Subject` 字段内容:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -i -n istio-system $(kubectl get pod -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].metadata.name}') -- cat /etc/istio/ingressgateway-ca-certs/ca-chain.cert.pem | openssl x509 -text -noout | grep 'Subject:'
|
||||
Subject: C=US, ST=Denial, L=Springfield, O=Dis, CN=httpbin.example.com
|
||||
{{< /text >}}
|
||||
|
||||
1. 如果创建了密钥但未加载密钥,则终止入口网关 pod 并强制它重新加载证书:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete pod -n istio-system -l istio=ingressgateway
|
||||
{{< /text >}}
|
||||
|
||||
## 清理
|
||||
|
||||
1. 删除 `Gateway` 配置、`VirtualService` 以及 Secret 对象:
|
||||
1. 删除 `Gateway` 配置、`VirtualService` 以及 Secret 对象:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete gateway mygateway
|
||||
|
|
@ -493,19 +499,19 @@ keywords: [流量管理,ingress]
|
|||
$ kubectl delete --ignore-not-found=true virtualservice bookinfo
|
||||
{{< /text >}}
|
||||
|
||||
1. 删除证书的目录和用于生成它们的存储库:
|
||||
1. 删除证书的目录和用于生成它们的存储库:
|
||||
|
||||
{{< text bash >}}
|
||||
$ rm -rf httpbin.example.com bookinfo.com mtls-go-example
|
||||
{{< /text >}}
|
||||
|
||||
1. 删除用于重新部署 `istio-ingressgateway` 的文件:
|
||||
1. 删除用于重新部署 `istio-ingressgateway` 的文件:
|
||||
|
||||
{{< text bash >}}
|
||||
$ rm -f $HOME/istio-ingressgateway.yaml
|
||||
{{< /text >}}
|
||||
|
||||
1. 关闭 [httpbin]({{< github_tree >}}/samples/httpbin) 服务:
|
||||
1. 关闭 [httpbin]({{< github_tree >}}/samples/httpbin) 服务:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete --ignore-not-found=true -f @samples/httpbin/httpbin.yaml@
|
||||
|
|
|
|||
Loading…
Reference in New Issue