mirror of https://github.com/istio/istio.io.git
This commit is contained in:
parent
dd63078cc1
commit
7b1ad175e3
|
@ -28,20 +28,20 @@ JWT 声明复制到 HTTP 头。
|
|||
|
||||
* 使用 [Istio 安装指南](/zh/docs/setup/install/istioctl/)安装 Istio。
|
||||
|
||||
* 在已启用 Sidecar 注入的命名空间 `foo` 中部署 `httpbin` 和 `sleep`
|
||||
* 在已启用 Sidecar 注入的命名空间 `foo` 中部署 `httpbin` 和 `curl`
|
||||
工作负载。使用以下命令部署命名空间和工作负载示例:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl label namespace foo istio-injection=enabled
|
||||
$ kubectl apply -f @samples/httpbin/httpbin.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@ -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令验证 `sleep` 是否成功与 `httpbin` 通信:
|
||||
* 使用以下命令验证 `curl` 是否成功与 `httpbin` 通信:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -78,7 +78,7 @@ JWT 声明复制到 HTTP 头。
|
|||
1. 确认带有无效 JWT 的请求被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer invalidToken" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer invalidToken" -w "%{http_code}\n"
|
||||
401
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -92,14 +92,14 @@ JWT 声明复制到 HTTP 头。
|
|||
1. 确认允许带有有效 JWT 的请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
1. 确认请求包含有效的 HTTP 头且这个头具有 JWT 声明值:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -H "Authorization: Bearer $TOKEN" | jq '.headers["X-Jwt-Claim-Foo"][0]'
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -H "Authorization: Bearer $TOKEN" | jq '.headers["X-Jwt-Claim-Foo"][0]'
|
||||
"bar"
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -40,36 +40,36 @@ STRICT 双向 TLS 来尝试迁移过程。
|
|||
|
||||
* 创建两个命名空间:`foo` 和 `bar`,并在这两个命名空间上部署
|
||||
[httpbin]({{< github_tree >}}/samples/httpbin)、
|
||||
[sleep]({{< github_tree >}}/samples/sleep) 和 Sidecar。
|
||||
[curl]({{< github_tree >}}/samples/curl) 和 Sidecar。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
|
||||
$ kubectl create ns bar
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n bar
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n bar
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n bar
|
||||
{{< /text >}}
|
||||
|
||||
* 创建另一个命名空间 `legacy`,并在没有 Sidecar 的情况下部署
|
||||
[sleep]({{< github_tree >}}/samples/sleep):
|
||||
[curl]({{< github_tree >}}/samples/curl):
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns legacy
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n legacy
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@ -n legacy
|
||||
{{< /text >}}
|
||||
|
||||
* (使用 curl 命令)从每个 Sleep Pod(命名空间为 `foo`、`bar` 或 `legacy`)分别向
|
||||
* (使用 curl 命令)从每个 curl Pod(命名空间为 `foo`、`bar` 或 `legacy`)分别向
|
||||
`httpbin.foo` 发送 http 请求。所有请求都应成功响应,返回 HTTP code 200。
|
||||
|
||||
{{< text bash >}}
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name})" -c sleep -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "sleep.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
sleep.foo to httpbin.foo: 200
|
||||
sleep.foo to httpbin.bar: 200
|
||||
sleep.bar to httpbin.foo: 200
|
||||
sleep.bar to httpbin.bar: 200
|
||||
sleep.legacy to httpbin.foo: 200
|
||||
sleep.legacy to httpbin.bar: 200
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=curl -n ${from} -o jsonpath={.items..metadata.name})" -c curl -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "curl.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
curl.foo to httpbin.foo: 200
|
||||
curl.foo to httpbin.bar: 200
|
||||
curl.bar to httpbin.foo: 200
|
||||
curl.bar to httpbin.bar: 200
|
||||
curl.legacy to httpbin.foo: 200
|
||||
curl.legacy to httpbin.bar: 200
|
||||
{{< /text >}}
|
||||
|
||||
{{< tip >}}
|
||||
|
@ -106,17 +106,17 @@ spec:
|
|||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
此时,源自 `sleep.legacy` 的请求将响应失败。
|
||||
此时,源自 `curl.legacy` 的请求将响应失败。
|
||||
|
||||
{{< text bash >}}
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name})" -c sleep -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "sleep.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
sleep.foo to httpbin.foo: 200
|
||||
sleep.foo to httpbin.bar: 200
|
||||
sleep.bar to httpbin.foo: 200
|
||||
sleep.bar to httpbin.bar: 200
|
||||
sleep.legacy to httpbin.foo: 000
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=curl -n ${from} -o jsonpath={.items..metadata.name})" -c curl -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "curl.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
curl.foo to httpbin.foo: 200
|
||||
curl.foo to httpbin.bar: 200
|
||||
curl.bar to httpbin.foo: 200
|
||||
curl.bar to httpbin.bar: 200
|
||||
curl.legacy to httpbin.foo: 000
|
||||
command terminated with exit code 56
|
||||
sleep.legacy to httpbin.bar: 200
|
||||
curl.legacy to httpbin.bar: 200
|
||||
{{< /text >}}
|
||||
|
||||
如果您安装 Istio 时带有参数 `values.global.proxy.privileged=true`,
|
||||
|
@ -128,7 +128,7 @@ tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
|
|||
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
|
||||
{{< /text >}}
|
||||
|
||||
当分别从 `sleep.legacy` 和 `sleep.foo` 发送请求时,
|
||||
当分别从 `curl.legacy` 和 `curl.foo` 发送请求时,
|
||||
您将在输出中看到纯文本和加密文本。
|
||||
|
||||
若无法将所有服务迁移至 Istio (注入 Envoy Sidecar),则必须开启 `PERMISSIVE` 模式。
|
||||
|
@ -150,10 +150,10 @@ EOF
|
|||
{{< /text >}}
|
||||
|
||||
现在,`foo` 和 `bar` 命名空间都强制执行仅双向 TLS 流量,
|
||||
因此您应该会看到来自 `sleep.legacy` 的请求访问两个命名空间的服务都失败了。
|
||||
因此您应该会看到来自 `curl.legacy` 的请求访问两个命名空间的服务都失败了。
|
||||
|
||||
{{< text bash >}}
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name})" -c sleep -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "sleep.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
$ for from in "foo" "bar" "legacy"; do for to in "foo" "bar"; do kubectl exec "$(kubectl get pod -l app=curl -n ${from} -o jsonpath={.items..metadata.name})" -c curl -n ${from} -- curl http://httpbin.${to}:8000/ip -s -o /dev/null -w "curl.${from} to httpbin.${to}: %{http_code}\n"; done; done
|
||||
{{< /text >}}
|
||||
|
||||
## 清理 {#clean-up-the-example}
|
||||
|
|
|
@ -22,20 +22,20 @@ test: yes
|
|||
|
||||
* 部署测试工作负载:
|
||||
|
||||
该任务使用两个工作负载,`httpbin` 和 `sleep`,部署在 `foo` 命名空间中。
|
||||
该任务使用两个工作负载,`httpbin` 和 `curl`,部署在 `foo` 命名空间中。
|
||||
这两个工作负载都包含 Envoy 代理边车容器。使用以下命令部署示例命名空间和工作负载:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl label ns foo istio-injection=enabled
|
||||
$ kubectl apply -f @samples/httpbin/httpbin.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@ -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令验证 `sleep` 是否可以访问 `httpbin`:
|
||||
* 使用以下命令验证 `curl` 是否可以访问 `httpbin`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -s -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -182,14 +182,14 @@ spec:
|
|||
1. 验证 `ext_authz` 示例服务器拒绝了头部为 `x-ext-authz:deny` 的路径 `/headers` 的请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -H "x-ext-authz: deny" -s
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -H "x-ext-authz: deny" -s
|
||||
denied by ext_authz for not found header `x-ext-authz: allow` in the request
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证 `ext_authz` 示例服务器是否允许头部为 `x-ext-authz:low` 的路径 `/headers` 的请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -H "x-ext-authz: allow" -s | jq '.headers'
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -H "x-ext-authz: allow" -s | jq '.headers'
|
||||
...
|
||||
"X-Ext-Authz-Check-Result": [
|
||||
"allowed"
|
||||
|
@ -200,7 +200,7 @@ spec:
|
|||
1. 确认允许 `/ip` 路径请求且不触发外部授权:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/ip" -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/ip" -s -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -210,12 +210,12 @@ spec:
|
|||
$ kubectl logs "$(kubectl get pod -l app=ext-authz -n foo -o jsonpath={.items..metadata.name})" -n foo -c ext-authz
|
||||
2021/01/07 22:55:47 Starting HTTP server at [::]:8000
|
||||
2021/01/07 22:55:47 Starting gRPC server at [::]:9000
|
||||
2021/01/08 03:25:00 [gRPCv3][denied]: httpbin.foo:8000/headers, attributes: source:{address:{socket_address:{address:"10.44.0.22" port_value:52088}} principal:"spiffe://cluster.local/ns/foo/sa/sleep"} destination:{address:{socket_address:{address:"10.44.3.30" port_value:80}} principal:"spiffe://cluster.local/ns/foo/sa/httpbin"} request:{time:{seconds:1610076306 nanos:473835000} http:{id:"13869142855783664817" method:"GET" headers:{key:":authority" value:"httpbin.foo:8000"} headers:{key:":method" value:"GET"} headers:{key:":path" value:"/headers"} headers:{key:"accept" value:"*/*"} headers:{key:"content-length" value:"0"} headers:{key:"user-agent" value:"curl/7.74.0-DEV"} headers:{key:"x-b3-sampled" value:"1"} headers:{key:"x-b3-spanid" value:"377ba0cdc2334270"} headers:{key:"x-b3-traceid" value:"635187cb20d92f62377ba0cdc2334270"} headers:{key:"x-envoy-attempt-count" value:"1"} headers:{key:"x-ext-authz" value:"deny"} headers:{key:"x-forwarded-client-cert" value:"By=spiffe://cluster.local/ns/foo/sa/httpbin;Hash=dd14782fa2f439724d271dbed846ef843ff40d3932b615da650d028db655fc8d;Subject=\"\";URI=spiffe://cluster.local/ns/foo/sa/sleep"} headers:{key:"x-forwarded-proto" value:"http"} headers:{key:"x-request-id" value:"9609691a-4e9b-9545-ac71-3889bc2dffb0"} path:"/headers" host:"httpbin.foo:8000" protocol:"HTTP/1.1"}} metadata_context:{}
|
||||
2021/01/08 03:25:06 [gRPCv3][allowed]: httpbin.foo:8000/headers, attributes: source:{address:{socket_address:{address:"10.44.0.22" port_value:52184}} principal:"spiffe://cluster.local/ns/foo/sa/sleep"} destination:{address:{socket_address:{address:"10.44.3.30" port_value:80}} principal:"spiffe://cluster.local/ns/foo/sa/httpbin"} request:{time:{seconds:1610076300 nanos:925912000} http:{id:"17995949296433813435" method:"GET" headers:{key:":authority" value:"httpbin.foo:8000"} headers:{key:":method" value:"GET"} headers:{key:":path" value:"/headers"} headers:{key:"accept" value:"*/*"} headers:{key:"content-length" value:"0"} headers:{key:"user-agent" value:"curl/7.74.0-DEV"} headers:{key:"x-b3-sampled" value:"1"} headers:{key:"x-b3-spanid" value:"a66b5470e922fa80"} headers:{key:"x-b3-traceid" value:"300c2f2b90a618c8a66b5470e922fa80"} headers:{key:"x-envoy-attempt-count" value:"1"} headers:{key:"x-ext-authz" value:"allow"} headers:{key:"x-forwarded-client-cert" value:"By=spiffe://cluster.local/ns/foo/sa/httpbin;Hash=dd14782fa2f439724d271dbed846ef843ff40d3932b615da650d028db655fc8d;Subject=\"\";URI=spiffe://cluster.local/ns/foo/sa/sleep"} headers:{key:"x-forwarded-proto" value:"http"} headers:{key:"x-request-id" value:"2b62daf1-00b9-97d9-91b8-ba6194ef58a4"} path:"/headers" host:"httpbin.foo:8000" protocol:"HTTP/1.1"}} metadata_context:{}
|
||||
2021/01/08 03:25:00 [gRPCv3][denied]: httpbin.foo:8000/headers, attributes: source:{address:{socket_address:{address:"10.44.0.22" port_value:52088}} principal:"spiffe://cluster.local/ns/foo/sa/curl"} destination:{address:{socket_address:{address:"10.44.3.30" port_value:80}} principal:"spiffe://cluster.local/ns/foo/sa/httpbin"} request:{time:{seconds:1610076306 nanos:473835000} http:{id:"13869142855783664817" method:"GET" headers:{key:":authority" value:"httpbin.foo:8000"} headers:{key:":method" value:"GET"} headers:{key:":path" value:"/headers"} headers:{key:"accept" value:"*/*"} headers:{key:"content-length" value:"0"} headers:{key:"user-agent" value:"curl/7.74.0-DEV"} headers:{key:"x-b3-sampled" value:"1"} headers:{key:"x-b3-spanid" value:"377ba0cdc2334270"} headers:{key:"x-b3-traceid" value:"635187cb20d92f62377ba0cdc2334270"} headers:{key:"x-envoy-attempt-count" value:"1"} headers:{key:"x-ext-authz" value:"deny"} headers:{key:"x-forwarded-client-cert" value:"By=spiffe://cluster.local/ns/foo/sa/httpbin;Hash=dd14782fa2f439724d271dbed846ef843ff40d3932b615da650d028db655fc8d;Subject=\"\";URI=spiffe://cluster.local/ns/foo/sa/curl"} headers:{key:"x-forwarded-proto" value:"http"} headers:{key:"x-request-id" value:"9609691a-4e9b-9545-ac71-3889bc2dffb0"} path:"/headers" host:"httpbin.foo:8000" protocol:"HTTP/1.1"}} metadata_context:{}
|
||||
2021/01/08 03:25:06 [gRPCv3][allowed]: httpbin.foo:8000/headers, attributes: source:{address:{socket_address:{address:"10.44.0.22" port_value:52184}} principal:"spiffe://cluster.local/ns/foo/sa/curl"} destination:{address:{socket_address:{address:"10.44.3.30" port_value:80}} principal:"spiffe://cluster.local/ns/foo/sa/httpbin"} request:{time:{seconds:1610076300 nanos:925912000} http:{id:"17995949296433813435" method:"GET" headers:{key:":authority" value:"httpbin.foo:8000"} headers:{key:":method" value:"GET"} headers:{key:":path" value:"/headers"} headers:{key:"accept" value:"*/*"} headers:{key:"content-length" value:"0"} headers:{key:"user-agent" value:"curl/7.74.0-DEV"} headers:{key:"x-b3-sampled" value:"1"} headers:{key:"x-b3-spanid" value:"a66b5470e922fa80"} headers:{key:"x-b3-traceid" value:"300c2f2b90a618c8a66b5470e922fa80"} headers:{key:"x-envoy-attempt-count" value:"1"} headers:{key:"x-ext-authz" value:"allow"} headers:{key:"x-forwarded-client-cert" value:"By=spiffe://cluster.local/ns/foo/sa/httpbin;Hash=dd14782fa2f439724d271dbed846ef843ff40d3932b615da650d028db655fc8d;Subject=\"\";URI=spiffe://cluster.local/ns/foo/sa/curl"} headers:{key:"x-forwarded-proto" value:"http"} headers:{key:"x-request-id" value:"2b62daf1-00b9-97d9-91b8-ba6194ef58a4"} path:"/headers" host:"httpbin.foo:8000" protocol:"HTTP/1.1"}} metadata_context:{}
|
||||
{{< /text >}}
|
||||
|
||||
您还可以从日志中看出,`ext-authz` 过滤器和 `ext-authz` 示例服务器之间的连接启用了
|
||||
mTLS,因为源主体填充了值 `spirffe://cluster.local/ns/foo/sa/sleep`。
|
||||
mTLS,因为源主体填充了值 `spirffe://cluster.local/ns/foo/sa/curl`。
|
||||
|
||||
现在,您可以对示例 `ext-authz` 服务器应用另一个授权策略,以控制允许谁访问它。
|
||||
|
||||
|
|
|
@ -20,19 +20,19 @@ test: yes
|
|||
|
||||
* 部署工作负载:
|
||||
|
||||
该任务使用 `httpbin` 和 `sleep` 这两个工作负载,部署在一个命名空间 `foo` 中。
|
||||
该任务使用 `httpbin` 和 `curl` 这两个工作负载,部署在一个命名空间 `foo` 中。
|
||||
这两个工作负载之前都运行了一个 Envoy 代理。使用以下命令部署示例命名空间和工作负载:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令校验 `sleep` 任务与 `httpbin` 的对话。
|
||||
* 使用以下命令校验 `curl` 任务与 `httpbin` 的对话。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -69,14 +69,14 @@ test: yes
|
|||
1. 检查 `GET` 请求是否被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/get" -X GET -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/get" -X GET -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查是否允许 `POST` 请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/post" -X POST -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/post" -X POST -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -109,14 +109,14 @@ test: yes
|
|||
1. 检查是否允许 HTTP 头 `x-token: admin` 的 `GET` 请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: admin" -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: admin" -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 HTTP 头 `x-token: guest` 的 GET 请求是否被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: guest" -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: guest" -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -146,14 +146,14 @@ test: yes
|
|||
策略拒绝。“拒绝策略”优先级高于“允许策略”:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/ip" -X GET -H "x-token: guest" -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/ip" -X GET -H "x-token: guest" -s -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 `/ip` 路径中 HTTP 头 `x-token: admin` 的 `GET` 请求是否被 `allow-path-ip` 策略允许:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/ip" -X GET -H "x-token: admin" -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/ip" -X GET -H "x-token: admin" -s -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -161,7 +161,7 @@ test: yes
|
|||
因为它们与 `allow-path-ip` 策略不匹配:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: admin" -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/get" -X GET -H "x-token: admin" -s -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -34,14 +34,14 @@ status: Alpha
|
|||
|
||||
* 部署测试工作负载:
|
||||
|
||||
本任务使用 `httpbin` 和 `sleep` 两个工作负载,均部署在命名空间 `foo` 中。
|
||||
本任务使用 `httpbin` 和 `curl` 两个工作负载,均部署在命名空间 `foo` 中。
|
||||
两个工作负载都带有 Envoy 代理 Sidecar。请使用以下命令创建 `foo` 命名空间并部署工作负载:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl label ns foo istio-injection=enabled
|
||||
$ kubectl apply -f @samples/httpbin/httpbin.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n foo
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@ -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 启用代理调试级别日志以检查模拟运行日志结果:
|
||||
|
@ -51,10 +51,10 @@ status: Alpha
|
|||
rbac: debug
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令验证 `sleep` 是否可以访问 `httpbin`:
|
||||
* 使用以下命令验证 `curl` 是否可以访问 `httpbin`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -s -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -s -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -94,11 +94,11 @@ status: Alpha
|
|||
{{< /text >}}
|
||||
|
||||
1. 验证请求路径 `/headers` 是否允许,因为策略是在模拟运行模式下创建的,
|
||||
所以请运行以下命令将 20 个请求从 `sleep` 发送到 `httpbin`,
|
||||
所以请运行以下命令将 20 个请求从 `curl` 发送到 `httpbin`,
|
||||
此请求包含头部 `X-B3-Sampled: 1` 以始终触发 Zipkin 追踪:
|
||||
|
||||
{{< text bash >}}
|
||||
$ for i in {1..20}; do kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/headers -H "X-B3-Sampled: 1" -s -o /dev/null -w "%{http_code}\n"; done
|
||||
$ for i in {1..20}; do kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/headers -H "X-B3-Sampled: 1" -s -o /dev/null -w "%{http_code}\n"; done
|
||||
200
|
||||
200
|
||||
200
|
||||
|
@ -157,7 +157,7 @@ $ kubectl logs "$(kubectl -n foo -l app=httpbin get pods -o jsonpath={.items..me
|
|||
$ istioctl dashboard zipkin
|
||||
{{< /text >}}
|
||||
|
||||
1. 查找从 `sleep` 到 `httpbin` 的请求的追踪结果。
|
||||
1. 查找从 `curl` 到 `httpbin` 的请求的追踪结果。
|
||||
如果您由于 Zipkin 中的延迟看到追踪结果,请尝试发送更多请求。
|
||||
|
||||
1. 在追踪结果中,您应看到以下自定义标记,表明此请求被命名空间 `foo` 中的模拟运行策略 `deny-path-headers` 拒绝:
|
||||
|
|
|
@ -23,19 +23,19 @@ Istio 授权策略同时支持字符串类型和列表类型的 JWT 声明。
|
|||
|
||||
* 参照 [Istio 安装指南](/zh/docs/setup/install/istioctl/)安装 Istio。
|
||||
|
||||
* 部署两个工作负载(workload):`httpbin` 和 `sleep`。将它们部署在同一个命名空间中,
|
||||
* 部署两个工作负载(workload):`httpbin` 和 `curl`。将它们部署在同一个命名空间中,
|
||||
* 例如 `foo`。每个工作负载都在前面运行一个 Envoy 代理。您可以使用以下命令来部署它们:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用下面的命令验证 `sleep` 能够正常访问 `httpbin` 服务:
|
||||
* 使用下面的命令验证 `curl` 能够正常访问 `httpbin` 服务:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -69,14 +69,14 @@ Istio 授权策略同时支持字符串类型和列表类型的 JWT 声明。
|
|||
1. 验证使用无效 JWT 的请求被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer invalidToken" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer invalidToken" -w "%{http_code}\n"
|
||||
401
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证没有 JWT 令牌的请求被允许,因为以上策略不包含授权策略:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -115,14 +115,14 @@ Istio 授权策略同时支持字符串类型和列表类型的 JWT 声明。
|
|||
1. 验证使用有效 JWT 的请求被允许:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证没有 JWT 的请求被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -164,14 +164,14 @@ Istio 授权策略同时支持字符串类型和列表类型的 JWT 声明。
|
|||
1. 验证包含 JWT 且 JWT 中包含名为 `groups` 值为 `group1` 声明的请求被允许:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN_GROUP" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN_GROUP" -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证包含 JWT,但 JWT 不包含 `groups` 声明的请求被拒绝:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl "http://httpbin.foo:8000/headers" -sS -o /dev/null -H "Authorization: Bearer $TOKEN" -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ test: yes
|
|||
|
||||
* 根据 [Istio 安装指南](/zh/docs/setup/install/istioctl/)安装 Istio。
|
||||
|
||||
* 在命名空间例如 `foo` 中部署两个工作负载:`sleep` 和 `tcp-echo`。
|
||||
* 在命名空间例如 `foo` 中部署两个工作负载:`curl` 和 `tcp-echo`。
|
||||
这两个工作负载每个前面都会运行一个 Envoy 代理。
|
||||
`tcp-echo` 工作负载会监听 9000、9001 和 9002 端口,并以 `hello` 为前缀输出它收到的所有流量。
|
||||
例如,如果您发送 `world` 给 `tcp-echo`,那么它将会回复 `hello world`。
|
||||
|
@ -29,35 +29,35 @@ test: yes
|
|||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/tcp-echo/tcp-echo.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令验证 `sleep` 可以成功与 `tcp-echo` 的 9000 和 9001 端口通信:
|
||||
* 使用以下命令验证 `curl` 可以成功与 `tcp-echo` 的 9000 和 9001 端口通信:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9000
|
||||
connection succeeded
|
||||
{{< /text >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9001" | nc tcp-echo 9001' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9001
|
||||
connection succeeded
|
||||
{{< /text >}}
|
||||
|
||||
* 确认 `sleep` 可以成功与 `tcp-echo` 的 9002 端口通信。
|
||||
* 确认 `curl` 可以成功与 `tcp-echo` 的 9002 端口通信。
|
||||
您需要将流量直接发送到 `tcp-echo` 的 Pod IP,因为在 `tcp-echo` 的 Kubernetes Service 对象中未定义端口 9002。
|
||||
获取 Pod IP 地址,并使用以下命令发送请求:
|
||||
|
||||
{{< text bash >}}
|
||||
$ TCP_ECHO_IP=$(kubectl get pod "$(kubectl get pod -l app=tcp-echo -n foo -o jsonpath={.items..metadata.name})" -n foo -o jsonpath="{.status.podIP}")
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
"echo \"port 9002\" | nc $TCP_ECHO_IP 9002" | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9002
|
||||
connection succeeded
|
||||
|
@ -94,8 +94,8 @@ test: yes
|
|||
1. 使用以下命令验证是否允许请求 9000 端口:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9000
|
||||
connection succeeded
|
||||
|
@ -104,8 +104,8 @@ test: yes
|
|||
1. 使用以下命令验证是否允许请求 9001 端口:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9001" | nc tcp-echo 9001' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9001
|
||||
connection succeeded
|
||||
|
@ -115,8 +115,8 @@ test: yes
|
|||
授权策略也会将其应用于透传过滤器链。运行以下命令并验证输出:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
"echo \"port 9002\" | nc $TCP_ECHO_IP 9002" | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -148,8 +148,8 @@ test: yes
|
|||
运行以下命令并验证输出:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -157,8 +157,8 @@ test: yes
|
|||
1. 验证对 9001 端口的请求是否被拒绝。发生这种情况是因为请求与任何 ALLOW 规则都不匹配。运行以下命令并验证输出:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9001" | nc tcp-echo 9001' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -190,8 +190,8 @@ test: yes
|
|||
规则时不理解 HTTP-only 字段,并且由于这个规则的限制性质,将拒绝所有到 tcp 端口的流量:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -199,8 +199,8 @@ test: yes
|
|||
1. 验证到 9001 端口的请求是否被拒绝。原因同上。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9001" | nc tcp-echo 9001' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -230,8 +230,8 @@ test: yes
|
|||
1. 验证对 9000 端口的请求是否被拒绝。发生这种情况是因为此类请求与上述 DENY 策略中的 `ports` 匹配:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
connection rejected
|
||||
{{< /text >}}
|
||||
|
@ -239,8 +239,8 @@ test: yes
|
|||
1. 验证是否允许对 9001 端口的请求。发生这种情况是因为请求与 DENY 策略中的 `ports` 不匹配:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c sleep -n foo -- sh -c \
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" \
|
||||
-c curl -n foo -- sh -c \
|
||||
'echo "port 9001" | nc tcp-echo 9001' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
|
||||
hello port 9001
|
||||
connection succeeded
|
||||
|
|
|
@ -29,19 +29,19 @@ test: yes
|
|||
{{< /text >}}
|
||||
|
||||
1. 将 [httpbin]({{< github_tree >}}/samples/httpbin) 示例部署于 `default` 命名空间中,
|
||||
将 [sleep]({{< github_tree >}}/samples/sleep) 示例部署于 `default` 和 `sleep-allow`
|
||||
将 [curl]({{< github_tree >}}/samples/curl) 示例部署于 `default` 和 `curl-allow`
|
||||
命名空间中:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl label namespace default istio-injection=enabled
|
||||
$ kubectl apply -f @samples/httpbin/httpbin.yaml@
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@
|
||||
$ kubectl create namespace sleep-allow
|
||||
$ kubectl label namespace sleep-allow istio-injection=enabled
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n sleep-allow
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@
|
||||
$ kubectl create namespace curl-allow
|
||||
$ kubectl label namespace curl-allow istio-injection=enabled
|
||||
$ kubectl apply -f @samples/curl/curl.yaml@ -n curl-allow
|
||||
{{< /text >}}
|
||||
|
||||
1. 应用如下授权策略以拒绝所有到 `httpbin` 的请求,除了来自 `sleep-allow` 命名空间的 `sleep` 服务。
|
||||
1. 应用如下授权策略以拒绝所有到 `httpbin` 的请求,除了来自 `curl-allow` 命名空间的 `curl` 服务。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
|
@ -55,7 +55,7 @@ test: yes
|
|||
- from:
|
||||
- source:
|
||||
principals:
|
||||
- old-td/ns/sleep-allow/sa/sleep
|
||||
- old-td/ns/curl-allow/sa/curl
|
||||
to:
|
||||
- operation:
|
||||
methods:
|
||||
|
@ -71,17 +71,17 @@ test: yes
|
|||
|
||||
1. 验证从以下请求源发送至 `httpbin` 的请求:
|
||||
|
||||
* 来自 `default` 命名空间的 `sleep` 服务的请求被拒绝。
|
||||
* 来自 `default` 命名空间的 `curl` 服务的请求被拒绝。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
* 来自 `sleep-allow` 命名空间的 `sleep` 服务的请求通过了。
|
||||
* 来自 `curl-allow` 命名空间的 `curl` 服务的请求通过了。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl -n sleep-allow get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -n sleep-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl -n curl-allow get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -n curl-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -101,32 +101,32 @@ test: yes
|
|||
|
||||
Istio 网格现在运行于一个新的信任域 `new-td` 了。
|
||||
|
||||
1. 重新部署 `httpbin` 和 `sleep` 应用以从新的 Istio 控制平面获取更新。
|
||||
1. 重新部署 `httpbin` 和 `curl` 应用以从新的 Istio 控制平面获取更新。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete pod --all
|
||||
{{< /text >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete pod --all -n sleep-allow
|
||||
$ kubectl delete pod --all -n curl-allow
|
||||
{{< /text >}}
|
||||
|
||||
1. 验证来自 `default` 和 `sleep-allow` 命名空间的 `sleep` 到 `httpbin` 的访问都被拒绝。
|
||||
1. 验证来自 `default` 和 `curl-allow` 命名空间的 `curl` 到 `httpbin` 的访问都被拒绝。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl -n sleep-allow get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -n sleep-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl -n curl-allow get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -n curl-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
这是因为我们指定了一个授权策略,它会拒绝所有到 `httpbin` 的请求,除非请求来源的身份是
|
||||
`old-td/ns/sleep-allow/sa/sleep`,而这个身份是 `sleep-allow` 命名空间的 `sleep` 的旧身份。
|
||||
当我们迁移到一个新的信任域,即 `new-td`,`sleep` 应用的身份就变成 `new-td/ns/sleep-allow/sa/sleep`,
|
||||
与 `old-td/ns/sleep-allow/sa/sleep` 不同。因此,`sleep-allow` 命名空间中的 `sleep`
|
||||
`old-td/ns/curl-allow/sa/curl`,而这个身份是 `curl-allow` 命名空间的 `curl` 的旧身份。
|
||||
当我们迁移到一个新的信任域,即 `new-td`,`curl` 应用的身份就变成 `new-td/ns/curl-allow/sa/curl`,
|
||||
与 `old-td/ns/curl-allow/sa/curl` 不同。因此,`curl-allow` 命名空间中的 `curl`
|
||||
应用之前的请求被放行,但现在被拒绝。在 Istio 1.4 之前,修复该问题的唯一方式就是手动调整授权策略。
|
||||
而在 Istio 1.4 中,我们引入了一种更简单的方法,如下所示。
|
||||
|
||||
|
@ -149,24 +149,24 @@ test: yes
|
|||
|
||||
1. 不调整授权策略,验证到 `httpbin` 的请求:
|
||||
|
||||
* 来自 `default` 命名空间的 `sleep` 的请求被拒绝。
|
||||
* 来自 `default` 命名空间的 `curl` 的请求被拒绝。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
403
|
||||
{{< /text >}}
|
||||
|
||||
* 来自 `sleep-allow` 命名空间的 `sleep` 通过了。
|
||||
* 来自 `curl-allow` 命名空间的 `curl` 通过了。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl -n sleep-allow get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -n sleep-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl -n curl-allow get pod -l app=curl -o jsonpath={.items..metadata.name})" -c curl -n curl-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
## 最佳实践{#best-practices}
|
||||
|
||||
从 Istio 1.4 起,在编辑授权策略时,您应该在策略中的信任域部分使用 `cluster.local`。
|
||||
例如,应该是 `cluster.local/ns/sleep-allow/sa/sleep`,而不是 `old-td/ns/sleep-allow/sa/sleep`。
|
||||
例如,应该是 `cluster.local/ns/curl-allow/sa/curl`,而不是 `old-td/ns/curl-allow/sa/curl`。
|
||||
请注意,在这种情况下,`cluster.local` 并不是 Istio 网格的信任域(信任域依然是 `old-td`)。
|
||||
在策略中,`cluster.local` 是一个指针,指向当前信任域,即 `old-td`(后来是 `new-td`)及其别名。
|
||||
通过在授权策略中使用 `cluster.local`,当您迁移到新的信任域时,Istio 将检测到此情况,
|
||||
|
@ -177,8 +177,8 @@ test: yes
|
|||
{{< text bash >}}
|
||||
$ kubectl delete authorizationpolicy service-httpbin.default.svc.cluster.local
|
||||
$ kubectl delete deploy httpbin; kubectl delete service httpbin; kubectl delete serviceaccount httpbin
|
||||
$ kubectl delete deploy sleep; kubectl delete service sleep; kubectl delete serviceaccount sleep
|
||||
$ kubectl delete deploy curl; kubectl delete service curl; kubectl delete serviceaccount curl
|
||||
$ istioctl uninstall --purge -y
|
||||
$ kubectl delete namespace sleep-allow istio-system
|
||||
$ kubectl delete namespace curl-allow istio-system
|
||||
$ rm ./td-installation.yaml
|
||||
{{< /text >}}
|
||||
|
|
|
@ -249,33 +249,33 @@ $ export BARCA=$(kubectl get clusterissuers bar -o jsonpath='{.spec.ca.secretNam
|
|||
$ kubectl apply -f ./proxyconfig-foo.yaml
|
||||
{{< /text >}}
|
||||
|
||||
1. 在 `foo` 和 `bar` 命名空间中部署 `httpbin` 和 `sleep` 样例应用程序。
|
||||
1. 在 `foo` 和 `bar` 命名空间中部署 `httpbin` 和 `curl` 样例应用程序。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl label ns foo istio-injection=enabled
|
||||
$ kubectl label ns bar istio-injection=enabled
|
||||
$ kubectl apply -f samples/httpbin/httpbin.yaml -n foo
|
||||
$ kubectl apply -f samples/sleep/sleep.yaml -n foo
|
||||
$ kubectl apply -f samples/curl/curl.yaml -n foo
|
||||
$ kubectl apply -f samples/httpbin/httpbin.yaml -n bar
|
||||
{{< /text >}}
|
||||
|
||||
## 验证相同命名空间内 `httpbin` 和 `sleep` 之间的网络连通性 {#verify-network-connectivity-between-httpbin-and-sleep-within-a-namespace}
|
||||
## 验证相同命名空间内 `httpbin` 和 `curl` 之间的网络连通性 {#verify-network-connectivity-between-httpbin-and-curl-within-a-namespace}
|
||||
|
||||
在部署工作负载时,它们会发送具有相关签名者信息的 CSR 请求。Istiod 将这些 CSR 请求转发到自定义 CA 进行签名。
|
||||
自定义 CA 将使用正确的集群签发器在证书上签名。`foo` 命名空间下的工作负载将使用 `foo` 集群签发器,
|
||||
而 `bar` 命名空间下的工作负载将使用 `bar` 集群签发器。要验证它们已经被正确的集群签发器进行了真正的签名,
|
||||
我们可以验证相同命名空间下的工作负载可以通信,而不同命名空间下的工作负载不能通信。
|
||||
|
||||
1. 将 `SLEEP_POD_FOO` 环境变量设置为 `sleep` Pod 的名称。
|
||||
1. 将 `CURL_POD_FOO` 环境变量设置为 `curl` Pod 的名称。
|
||||
|
||||
{{< text bash >}}
|
||||
$ export SLEEP_POD_FOO=$(kubectl get pod -n foo -l app=sleep -o jsonpath={.items..metadata.name})
|
||||
$ export CURL_POD_FOO=$(kubectl get pod -n foo -l app=curl -o jsonpath={.items..metadata.name})
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 `foo` 命名空间中 `sleep` 和 `httpbin` 服务之间的网络连通性。
|
||||
1. 检查 `foo` 命名空间中 `curl` 和 `httpbin` 服务之间的网络连通性。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$SLEEP_POD_FOO" -n foo -c sleep -- curl http://httpbin.foo:8000/html
|
||||
$ kubectl exec "$CURL_POD_FOO" -n foo -c curl -- curl http://httpbin.foo:8000/html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -291,10 +291,10 @@ $ export BARCA=$(kubectl get clusterissuers bar -o jsonpath='{.spec.ca.secretNam
|
|||
</body>
|
||||
{{< /text >}}
|
||||
|
||||
1. 检查 `foo` 命名空间中的 `sleep` 服务与 `bar` 命名空间中的 `httpbin` 服务之间的网络连通性。
|
||||
1. 检查 `foo` 命名空间中的 `curl` 服务与 `bar` 命名空间中的 `httpbin` 服务之间的网络连通性。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$SLEEP_POD_FOO" -n foo -c sleep -- curl http://httpbin.bar:8000/html
|
||||
$ kubectl exec "$CURL_POD_FOO" -n foo -c curl -- curl http://httpbin.bar:8000/html
|
||||
upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: TLS error: 268435581:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -109,12 +109,12 @@ Istio CA 签发中间证书。Istio CA 可以使用管理员指定的证书和
|
|||
|
||||
## 部署示例服务{#deploying-example-services}
|
||||
|
||||
1. 部署 `httpbin` 和 `sleep` 示例服务。
|
||||
1. 部署 `httpbin` 和 `curl` 示例服务。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f samples/httpbin/httpbin.yaml) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f samples/sleep/sleep.yaml) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f samples/curl/curl.yaml) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
1. 为 `foo` 命名空间中的工作负载部署一个策略,使其只接受相互的 TLS 流量。
|
||||
|
@ -139,7 +139,7 @@ Istio CA 签发中间证书。Istio CA 可以使用管理员指定的证书和
|
|||
所以可以预料 openssl 命令返回 `verify error:num=19:self signed certificate in certificate chain`。
|
||||
|
||||
{{< text bash >}}
|
||||
$ sleep 20; kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -showcerts -connect httpbin.foo:8000 > httpbin-proxy-cert.txt
|
||||
$ sleep 20; kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -showcerts -connect httpbin.foo:8000 > httpbin-proxy-cert.txt
|
||||
{{< /text >}}
|
||||
|
||||
1. 解析证书链上的证书。
|
||||
|
@ -194,10 +194,10 @@ Istio CA 签发中间证书。Istio CA 可以使用管理员指定的证书和
|
|||
$ kubectl delete peerauthentication -n foo default
|
||||
{{< /text >}}
|
||||
|
||||
* 删除示例应用 `sleep` 和 `httpbin`:
|
||||
* 删除示例应用 `curl` 和 `httpbin`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete -f samples/sleep/sleep.yaml -n foo
|
||||
$ kubectl delete -f samples/curl/curl.yaml -n foo
|
||||
$ kubectl delete -f samples/httpbin/httpbin.yaml -n foo
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -37,19 +37,19 @@ Istio 工作负载当前支持的最高 TLS 版本为 1.3。
|
|||
配置完 Istio 工作负载的最低 TLS 版本后,
|
||||
您可以验证最低版本的 TLS 是否已配置,并是否按预期工作。
|
||||
|
||||
* 部署两个工作负载:`httpbin` 和 `sleep`。并将它们部署到单个的命名空间中,
|
||||
* 部署两个工作负载:`httpbin` 和 `curl`。并将它们部署到单个的命名空间中,
|
||||
例如 `foo`,两个工作负载都在各自服务的前面使用 Envoy 作为流量代理运行。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
* 使用以下命令验证 `sleep` 是否成功地与 `httpbin` 建立通信:
|
||||
* 使用以下命令验证 `curl` 是否成功地与 `httpbin` 建立通信:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n"
|
||||
200
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -62,7 +62,7 @@ Istio 工作负载当前支持的最高 TLS 版本为 1.3。
|
|||
您可以使用以下命令查看 TLS 1.3 协议是否被允许使用:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_3 -connect httpbin.foo:8000 | grep "TLSv1.3"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_3 -connect httpbin.foo:8000 | grep "TLSv1.3"
|
||||
{{< /text >}}
|
||||
|
||||
文本输出应该包括如下内容:
|
||||
|
@ -74,7 +74,7 @@ TLSv1.3
|
|||
要检查是否允许 TLS 的 1.2 版本,您可以运行以下命令:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_2 -connect httpbin.foo:8000 | grep "Cipher is (NONE)"
|
||||
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_2 -connect httpbin.foo:8000 | grep "Cipher is (NONE)"
|
||||
{{< /text >}}
|
||||
|
||||
文本输出应该包括如下内容:
|
||||
|
@ -85,11 +85,11 @@ Cipher is (NONE)
|
|||
|
||||
## 清理{#cleanup}
|
||||
|
||||
从 `foo` 命名空间中删除样例应用 `sleep` 和 `httpbin`:
|
||||
从 `foo` 命名空间中删除样例应用 `curl` 和 `httpbin`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete -f samples/httpbin/httpbin.yaml -n foo
|
||||
$ kubectl delete -f samples/sleep/sleep.yaml -n foo
|
||||
$ kubectl delete -f samples/curl/curl.yaml -n foo
|
||||
{{< /text >}}
|
||||
|
||||
从集群中卸载 Istio:
|
||||
|
|
Loading…
Reference in New Issue