0
votes

I am learning Kubernetes on GCP

So far i have two deployments front end and backend as separate containers through separate deployment yaml files.

I am exposing them through service yaml files on port 8080 and 8081 respectively.

I can trigger the endpoints separately , however what should be the hostname/ ip address in the ajax call ?

When I do kubectl get services. I get two different services with their own cluster ip and external ip , but external ip changes as I delete the service.

how can i use locahost:8081?querysearch in my ajax call

1

1 Answers

0
votes

Found the answer.

I was trying something stupid , I had made my ui as a static frontend , hence the need for ajax calls to the backend.

I changed it by using a simple express server serving the requests , and a function inside would call the request to my backend

since the express server is inside the cluster , I was then able to access the backend with

http://service-name.default.svc.cluster.local:portname