404使用Istio从K8s广告连播中点击“ metadata.google.internal”

时间:2019-02-07 16:40:15

标签: kubernetes google-kubernetes-engine istio envoyproxy

我们有一个应用程序正在尝试移入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吊舱,一切似乎都很好。在日志中什么也没指出。

我要做的是使用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。知道发生了什么吗?

1 个答案:

答案 0 :(得分:0)

这是应该添加地址的方式。

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