我们有一个应用程序,我们正试图进入Istio网格。其中一项服务向metadata.google.internal
发出请求以完成环境配置。
我创建了ServiceEntry类型对象白名单metadata.google.internal
,如下所示(尝试过不同的组合):
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: google-metadata-server
spec:
hosts:
- metadata.google.internal
location: MESH_EXTERNAL
ports:
- number: 80
name: http
protocol: HTTP
resolution: DNS
由于某种原因,我无法获得正确的响应,因此服务失败。检查istio-proxy
容器上的日志时,在服务中,这是我得到的错误:
[2019-02-07T15:29:22.834Z] "GET /computeMetadata/v1/project/project-idHTTP/1.1" 200 - 0 14 2 1 "-" "Google-HTTP-Java-Client/1.27.0 (gzip)" "513f6e25-57ce-4cf0-a273-d391b3da604b" "metadata.google.internal" "169.254.169.254:80" outbound|80||metadata.google.internal - 169.254.169.254:80 10.16.0.29:58790
[2019-02-07T15:29:22.865Z] "GET /HTTP/1.1" 404 NR 0 0 0 - "-" "Google-HTTP-Java-Client/1.27.0 (gzip)" "490fe0dd-e03a-4460-a63b-7ed84a168d39" "169.254.169.254" "-" - - 169.254.169.254:80 10.16.0.29:58794
[2019-02-07T15:29:22.883Z] "GET /HTTP/1.1" 404 NR 0 0 0 - "-" "Google-HTTP-Java-Client/1.27.0 (gzip)" "dac0e762-d799-4457-ae48-75179e2f0b82" "169.254.169.254" "-" - - 169.254.169.254:80 10.16.0.29:58794
[2019-02-07T15:29:22.886Z] "GET /HTTP/1.1" 404 NR 0 0 0 - "-" "Google-HTTP-Java-Client/1.27.0 (gzip)" "3411a0be-6d29-42f3-b01a-567edf2cc3e2" "169.254.169.254" "-" - - 169.254.169.254:80 10.16.0.29:58794
[2019-02-07T15:29:47.781Z] "GET /computeMetadata/v1/project/project-idHTTP/1.1" 200 - 0 14 4 3 "-" "Google-HTTP-Java-Client/1.27.0 (gzip)" "7115bf46-e7e9-4b2f-ba37-10cd6b8c9dea" "metadata.google.internal" "169.254.169.254:80" outbound|80||metadata.google.internal - 169.254.169.254:80 10.16.0.29:58876
正如你所看到的那样,我对/computeMetadata/v1/project/project-id
的请求得到200,但/
失败了。不知道为什么。
随着istio-sidecar-injector
pod一切似乎都很好。在日志中没有任何指出。
我所做的是使用Istio创建一个简单的部署,在同一个集群中,使用相同的命名空间,并手动telnet元数据服务器:
root@demo-675c758c68-vrbcv:/# telnet metadata.google.internal 80
Trying 169.254.169.254...
Connected to metadata.google.internal.
Escape character is '^]'.
GET / HTTP/1.1
Host: metadata.google.internal
HTTP/1.1 200 OK
metadata-flavor: Google
content-type: application/text
date: Thu, 07 Feb 2019 16:35:52 GMT
server: envoy
content-length: 22
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-envoy-upstream-service-time: 1
0.1/
computeMetadata/
我不明白为什么我会得到这些404.知道发生了什么事吗?
这是地址的添加方式。
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: google-metadata-server
spec:
hosts:
- metadata.google.internal
addresses:
- 169.254.169.254
ports:
- number: 80
name: http
protocol: HTTP
location: MESH_INTERNAL
resolution: DNS