I am trying to connect a simple application to emulate a frontend container in one pod on one host, which makes a request to another backend container in another pod on another host. This cluster was created by kops on AWS.
The services are created correctly and I am able to reach the default frontend service at the LB url created by frontend service. However, the request /greet which calls backend hangs and eventually times out with 500 error.
I checked logs but it doesn't show anything useful. Am I missing anything that would prevent the pods to communicate?
@app.route('/greet')
def greet():
r = requests.get('http://sample-greeter')
print(r.content)
return r.content
if __name__ == "__main__":
app.run(host="0.0.0.0", port=int("5000"), debug=True)
//frontend
kubectl run sample-genericserver --image=genericserver --replicas=1 --port=5000
kubectl expose deployment sample-genericserver --port=5000 --type=LoadBalancer
@app.route('/')
def hello_world():
return 'Greetings from BackendService'
if __name__ == "__main__":
app.run(host="0.0.0.0", port=int("8090"), debug=True)
//backend
$ kubectl run sample-greeter --image=greeter --replicas=1 --port=8090
$ kubectl expose deployment sample-greeter --port=8090
Thanks to David's answer, I was able to add port number to calling url and backend service was able to respond correctly.
r = requests.get('http://sample-greeter:8090')