无法在启用了Istio的GKE群集中的2个Node.js应用程序之间进行通信 [英] Unable to communicate between 2 node,js apps in Istio enabled GKE cluster

查看:96
本文介绍了无法在启用了Istio的GKE群集中的2个Node.js应用程序之间进行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个GKE集群,并在其中部署了两个名为 nodeservice1 nodeservice2 的node.js基本应用,其中仅打开 nodeservice1 世界(允许未经身份验证的呼叫= true).

I have created a GKE cluster and deployed two node.js basic apps in it named nodeservice1 and nodeservice2 where only nodeservice1 is open to world (Allow unauthenticated calls=true) .

我的 nodeservice1 正在内部通过restcall调用 nodeservice2 ,并返回 nodeservice2 返回的内容.

My nodeservice1 is internally calling nodeservice2 via restcall and returning what nodeservice2 returns.

我可以通过curl命令调用 nodeservice1 ,它工作正常.当我命中端点../restcall(实际上在内部调用 nodeservice2 )时,它仅返回HTTPS 200 OK.

I am able to call nodeservice1 via curl command, it works fine. When I hit endpoint ../restcall (Which actually calls nodeservice2 internally), it doesn't return anything but HTTPS 200 OK.

注意:这两个应用程序均处于云运行"状态.上面的设置

Note: Both of the apps are on 'cloud run'. Above setup

有帮助吗? TIA

我曾尝试从 nodeservice1 中访问以下URL.也尝试了curl命令: curl -v -H主机:nodeservice1.istio-system.example.com" 34.80.18.249/restcall 其中34.80.18.249是我的istio入口负载平衡器IP.

I have tried hitting following URLs from nodeservice1. Tried curl command too: curl -v -H "Host: nodeservice1.istio-system.example.com" 34.80.18.249/restcall where 34.80.18.249 is my istio ingress load balancer IP.

  1. http://nodeservice2.istio-system:8080/restcall
  2. http://nodeservice2:8080/restcall
  1. http://nodeservice2.istio-system:8080/restcall
  2. http://nodeservice2:8080/restcall

/restcall内部调用nodeservice2

/restcall calls internally nodeservice2

当我检查正在运行的服务时,我的nodeservice1和nodeservice2的类型为= ExternalName.但是我公开了nodeservice1 = Loadbalancer和Nodeservice2 = ClusterIP.是我缺少的东西吗?

When I check running services, my nodeservice1 and nodeservice2 have type=ExternalName. But I have exposed nodeservice1=Loadbalancer and Nodeservice2=ClusterIP. Is something I am missing?

Nodeservice1的server.js文件:

Nodeservice1's server.js file:

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

Nodeservice2's 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命令中发生的情况,请尝试-cur标志-v标志.

I have faced the same issue few weeks ago. I think the problem is your nodeservice1 can't find the nodeservice2 internally,I may suggest try something like nodeservice1.default.svc.cluster.local. try the kubectl get svc to list down your services. or if you need to see what happens in your curl command try -v flag with your curl.

这篇关于无法在启用了Istio的GKE群集中的2个Node.js应用程序之间进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆