I have a backend pod, service related to it "backend-service" and another frontend pod trying to access the backend on url http://backend-service:8000 . I port forward my frontend , open the url in browser I could see backend url called on networks tab but no request is coming on my backend.
But when port-forward my backend and use url "http://localhost:8000", things work
A few things to check:
Are you deploying a
Servicefor your backend? Without aServiceyou won't be able to access the backend's ports from anywhere unless you port-forward them manually. This is likely why you can't access the backend without a port-forward.Second: Are your Services in different namespaces? If you are deploying in different namespaces, you can't just use the service name to connect like you can in docker. To connect to a service in Kubernetes, the format is
<serviceName>.<namespace>.svc.cluster.local. So for you it might bebackend-server.backend.svc.cluster.local. Check your Services and namespaces and also update your connection strings to use the k8s format.