无法在启用 Istio 的 GKE 集群中的 2 个节点、js 应用程序之间进行通信
Unable to communicate between 2 node,js apps in Istio enabled GKE cluster
我创建了一个 GKE 集群并在其中部署了两个 node.js 基本应用程序,名为 nodeservice1 和 nodeservice2 其中只有 nodeservice1 对世界开放(允许未经身份验证的调用=true)。
我的 nodeservice1 通过 restcall 在内部调用 nodeservice2 并且 returning what nodeservice2 returns.
我可以通过 curl 命令调用 nodeservice1,它工作正常。当我到达端点 ../restcall
(实际上在内部调用 nodeservice2)时,它不会 return 除了 HTTPS 200 OK
.
注意:这两个应用程序都在 'cloud run' 上。以上设置
有什么帮助吗? TIA
我尝试点击来自 nodeservice1 的以下 URL。也试过 curl 命令:
curl -v -H "Host: nodeservice1.istio-system.example.com" 34.80.18.249/restcall
其中 34.80.18.249 是我的 istio 入口负载均衡器 IP。
/restcall 在内部调用 nodeservice2
当我检查 运行 服务时,我的 nodeservice1 和 nodeservice2 有 type=ExternalName。但是我暴露了nodeservice1=Loadbalancer和Nodeservice2=ClusterIP。我缺少什么吗?
Nodeservice1 的 server.js 文件:
var express = require("express");
var http = require('http');
var app = express();
app.get('/',function(req, res, next){
res.send('Hurrah !!! nodeservice1 is up and running !!!');
});
app.get('/restcall',function(req, res, next){
var data = '';
console.log('inside /restcall in nodeservice1');
http.get('http://nodeservice1.default.example.com:8080/restcall',(resp) =>{
console.log('inside response');
resp.on('data', function (chunk) {
data += chunk;
console.log('inside end restcall');
});
resp.on('end', () => {
res.send(data);
console.log('inside end restcall');
console.log(data);
})
})
})
app.listen('8080',function(){
console.log('Node service 2 server listening on port 8080');
});
Nodeservice2 的 server.js
var express = require("express");
var http = require('http');
var app = express();
app.get('/',function(req, res){
res.send('Hurrah !!! nodeservice2 is up and running !!!');
});
app.get('/restcall',function(req, res, next){
console.log('inside /restcall in nodeservice2');
res.send('restcall api successfull from nodeservice2 !!!');
});
app.listen('8080',function(){
console.log('Node service 2 server listening on port 8080');
});
几周前我遇到了同样的问题。我认为问题是你的 nodeservice1 无法在内部找到 nodeservice2,我可能建议尝试像 nodeservice1.default.svc.cluster.local 这样的东西。尝试使用 kubectl get svc 列出您的服务。或者,如果您需要查看 curl 命令中发生的情况,请尝试使用 curl 的 -v 标志。
我创建了一个 GKE 集群并在其中部署了两个 node.js 基本应用程序,名为 nodeservice1 和 nodeservice2 其中只有 nodeservice1 对世界开放(允许未经身份验证的调用=true)。
我的 nodeservice1 通过 restcall 在内部调用 nodeservice2 并且 returning what nodeservice2 returns.
我可以通过 curl 命令调用 nodeservice1,它工作正常。当我到达端点 ../restcall
(实际上在内部调用 nodeservice2)时,它不会 return 除了 HTTPS 200 OK
.
注意:这两个应用程序都在 'cloud run' 上。以上设置
有什么帮助吗? TIA
我尝试点击来自 nodeservice1 的以下 URL。也试过 curl 命令: curl -v -H "Host: nodeservice1.istio-system.example.com" 34.80.18.249/restcall 其中 34.80.18.249 是我的 istio 入口负载均衡器 IP。
/restcall 在内部调用 nodeservice2
当我检查 运行 服务时,我的 nodeservice1 和 nodeservice2 有 type=ExternalName。但是我暴露了nodeservice1=Loadbalancer和Nodeservice2=ClusterIP。我缺少什么吗?
Nodeservice1 的 server.js 文件:
var express = require("express");
var http = require('http');
var app = express();
app.get('/',function(req, res, next){
res.send('Hurrah !!! nodeservice1 is up and running !!!');
});
app.get('/restcall',function(req, res, next){
var data = '';
console.log('inside /restcall in nodeservice1');
http.get('http://nodeservice1.default.example.com:8080/restcall',(resp) =>{
console.log('inside response');
resp.on('data', function (chunk) {
data += chunk;
console.log('inside end restcall');
});
resp.on('end', () => {
res.send(data);
console.log('inside end restcall');
console.log(data);
})
})
})
app.listen('8080',function(){
console.log('Node service 2 server listening on port 8080');
});
Nodeservice2 的 server.js
var express = require("express");
var http = require('http');
var app = express();
app.get('/',function(req, res){
res.send('Hurrah !!! nodeservice2 is up and running !!!');
});
app.get('/restcall',function(req, res, next){
console.log('inside /restcall in nodeservice2');
res.send('restcall api successfull from nodeservice2 !!!');
});
app.listen('8080',function(){
console.log('Node service 2 server listening on port 8080');
});
几周前我遇到了同样的问题。我认为问题是你的 nodeservice1 无法在内部找到 nodeservice2,我可能建议尝试像 nodeservice1.default.svc.cluster.local 这样的东西。尝试使用 kubectl get svc 列出您的服务。或者,如果您需要查看 curl 命令中发生的情况,请尝试使用 curl 的 -v 标志。