从 Salesforce 通过 http 调用 Istio VirtualService

时间:2021-05-20 11:46:54

标签: google-cloud-platform salesforce google-kubernetes-engine istio istio-gateway

我们将 istio-ingress 与 Gateway 和 VirtualService 结合使用。 Istio 已使用 IstioOperator 安装。 Istio 在 GKE 中的私有 VPC 中工作。入口流量来自 GCP 外部负载平衡器。

当通过 curl 或一些可公开访问的 API 测试软件调用端点时,一切正常,例如

curl -sv  -HHost:host.name.pl "http://[redacted]/api/health/livez"                                                           
*   Trying [redacted]:80...
* TCP_NODELAY set
* Connected to [redacted] (redacted) port 80 (#0)
> GET /api/health/livez HTTP/1.1
> Host:host.name.pl
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: text/plain; charset=utf-8
< content-length: 2
< date: Thu, 20 May 2021 11:35:15 GMT
< x-envoy-upstream-service-time: 2
< server: istio-envoy
< 
* Connection #0 to host [redacted] left intact
ok%                                         

但是当从 Salesforce Apex 调用虚拟服务时:

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://[some IP]/api/health/livez');
request.setMethod('GET');
request.setHeader('Host', '[some host]');
request.setHeader('Cache-Control', 'no-cache');
request.setTimeout(12000);
System.debug('### request: ' + (request));
HttpResponse response = http.send(request);

System.debug('### response: ' + response);
for(string s : response.getHeaderKeys()){
    System.debug('### header: ' + s + '  ' + response.getHeader(s));
}
System.debug('### response: ' + response.getStatus());
System.debug('### response: ' + response.getStatusCode());

然后响应如下:

02:35:52.21 (64126592)|USER_DEBUG|[16]|DEBUG|### header: X-Cache  MISS from proxy-fra.net.salesforce.com
02:35:52.21 (64153199)|USER_DEBUG|[16]|DEBUG|### header: Server  istio-envoy
02:35:52.21 (64167840)|USER_DEBUG|[16]|DEBUG|### header: X-Cache-Lookup  MISS from proxy-fra.net.salesforce.com:8080
02:35:52.21 (64181660)|USER_DEBUG|[16]|DEBUG|### header: Connection  keep-alive
02:35:52.21 (64194536)|USER_DEBUG|[16]|DEBUG|### header: Content-Length  0
02:35:52.21 (64207171)|USER_DEBUG|[16]|DEBUG|### header: Date  Thu, 20 May 2021 09:35:52 GMT
02:35:52.21 (64236542)|USER_DEBUG|[18]|DEBUG|### response: Not Found
02:35:52.21 (64293430)|USER_DEBUG|[19]|DEBUG|### response: 404

我们不知道为什么要在响应中添加 X-Cache 和 X-Cache-Lookup(proxy-fra.net.salesforce.com:8080,当然不是我们的主机:端口)以及如何处理。我们不知道这是 salesforce 方面的问题还是 istio 方面的问题。

有什么想法吗?

0 个答案:

没有答案
相关问题