Unable to communicate between 2 node,js apps in Istio enabled GKE cluster

9/11/2019

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) .

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

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

Any help? TIA

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

/restcall calls internally nodeservice2

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'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'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');
});
-- Roobal Jindal
google-cloud-platform
google-kubernetes-engine
istio
node.js

1 Answer

9/15/2019

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.

-- uvindu sri
Source: StackOverflow