0

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
  • 214
  • 2
  • 13
  • Hello Roobal, "it doesn't return anything but HTTPS 200 OK"If it returns this, means that the server received the request and was able to successfully process it. From there, is code only. Networking works fine and also DNS resolution so I don't see anything wrong with GKE. If you want to dig deeper I would recommend you to `curl -v` the pod address instead of the service hostname and share the output, let see if you get the same error message. – Luis Javier Alvarez Rodriguez Sep 13 '19 at 18:57

1 Answers1

1

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
  • 264
  • 1
  • 4
  • 16
  • Yes, it worked. But the basic mistake I was doing is that I didnt expose my nodeservice2. I wanted nodeservice2 to be secure and to be called from only within the cluster. So I ran "kubectl expose deployment nodeservice2 --type=ClusterIP --port=8080" – Roobal Jindal Sep 23 '19 at 12:03
  • 1
    It resolved my problem for normal kubernete cluster but when I use GKE cluster enabled with Istio, I am not able to call nodeservice2 via noderservice1. I have updated the post. Can you help? TIA – Roobal Jindal Sep 25 '19 at 09:16
  • can you please send me the output of your curl coomand with -v flag – uvindu sri Sep 25 '19 at 16:40
  • I have made another question for the same. Please check the output here: https://stackoverflow.com/questions/58095870/not-able-to-access-a-istio-enabled-gke-service-directly-from-browser-but-only-th – Roobal Jindal Sep 26 '19 at 06:02