尝试在启用边车之间卷曲时从 envoy 获取 403 Forbidden pods

Getting 403 Forbidden from envoy when attempting to curl between sidecar enabled pods

我正在使用 Kubernetes/Istio 设置,我的 pods 和服务列表如下:

NAME                                                READY     STATUS    RESTARTS   AGE
hr--debug-deployment-86575cffb6-wl6rx               2/2       Running   0          33m
hr--hr-deployment-596946948d-jrd7g                  2/2       Running   0          33m

NAME                             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
hr--debug-service                ClusterIP   10.104.160.61    <none>        80/TCP              33m
hr--hr-service                   ClusterIP   10.102.117.177   <none>        80/TCP              33m

我正试图从 hr--debug-deployment-86575cffb6-wl6rx

缩成 hr--hr-service
pasan@ubuntu:~/product-vick$ kubectl exec -it hr--debug-deployment-86575cffb6-wl6rx /bin/bash
Defaulting container name to debug.
Use 'kubectl describe pod/hr--debug-deployment-86575cffb6-wl6rx -n default' to see all of the containers in this pod.
root@hr--debug-deployment-86575cffb6-wl6rx:/# curl hr--hr-service -v
* Rebuilt URL to: hr--hr-service/
*   Trying 10.102.117.177...
* Connected to hr--hr-service (10.102.117.177) port 80 (#0)
> GET / HTTP/1.1
> Host: hr--hr-service
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< date: Thu, 03 Jan 2019 04:06:17 GMT
< server: envoy
< content-length: 0
<
* Connection #0 to host hr--hr-service left intact

你能解释一下为什么我收到 403 被 envoy 禁止以及我该如何解决它吗?

如果您注入了 envoy sidecar,这实际上取决于您的服务之间 authentication policy 的类型。您使用的是 MeshPolicy 还是 Policy

您也可以尝试禁用服务之间的身份验证以进行调试。像这样(如果你的政策是这样定义的):

apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
metadata:
  name: "hr--hr-service"
spec:
  targets:
  - name: hr--hr-service
  peers:
  - mTLS:
      mode: PERMISSIVE