Getting issue when application deployed in one pod calls to another application deployed in another pod in minikube

6/9/2019

I have 2 small java application. One is frontend and another is backend. These two application deployed in 2 different pods. frontend application is exposed by NodeType service so I am able to access this application from my browser. I have a single button to call the service in this frontend application. Now when I clicked the button I have written the code to call the backend application in another pod and backend application return success if it is called.

Front End application code
        @RequestMapping("/service")
        public class CallExternalServiceController {
        @RequestMapping("/callFrontEndService")
        @ResponseBody
        public String getResponseFromBackendService() {
            final RestTemplate template = new RestTemplate();
            final String serviceURL = System.getenv("BACKEND_PORT");
            if (!StringUtils.isEmpty(serviceURL)) {
                final String response = template.getForObject(serviceURL, String.class);
                return response;
            } else {
                System.out.print("In Else block");
                return "Service URL not defined";
            }
        }

        Backend Application:-
        @RequestMapping("/service")
        public class ServiceReceiver {

        @RequestMapping(value = "/callBackendService", produces = "text/plain")
        @ResponseBody
        public String getBackendResponse() {
            System.out.println("Reached");
            return "<html><h1>Calls received at Backend End:-)</h2></html>";
        }
        }

When I clicked the button flow reached to my frontend application and it also got the backend application URL from the frontend pod but url is below.

URL:- tcp://10.102.146.210:8081

and I got the below error.

Sun Jun 09 09:34:39 GMT 2019 There was an unexpected error (type=Internal Server Error, status=500). I/O error on GET request for "tcp://10.102.146.210:8081": unknown protocol: tcp; nested exception is java.net.MalformedURLException: unknown protocol: tcp

I didn't explicitly set this URL. I first deployed backend application and the frontend. it's an autogenerated URL.

Please let me know where I am doing wrong.

-- Gourav
kubernetes
minikube

0 Answers