Hello, I have consul in my k8’s cluster and I have deployed my application and side car got auto injected along with my application and see the service registered in the catalog. Now how can I access my service internally side my k8’s cluster using curl which IP to use as service Ip is not working inside the k8’s cluster when the application has side car containers in it.
Can someone please help me on this .
If you have network connectivity to the k8s cluster then you could do something like this:
kubectl port-forward deployment/frontend 8080:80
You can specify a pod instead of a deployment if you want to. Another question I would ask is if your service definition is deploying a LoadBalancer, that would get you an IP as well.
You can issue the command kubectl get service <YourServiceName>
to see the available IPs.
Hello @karl-cardenas-coding Thanks for the help. I am aware that I can do a port-forwarding or use LB svc or nodePort service to access my application outside. But my query here is when consul injects a envoy side car proxy along with my application, then I am able to curl my application service Ip internally within the cluster that is my problem and when there is no side car injected it is working as expected. I am getting empty reply response as below when there is a side car container injected by consul.
k get pod -o wide -n consul-k8s
counting-d9d58c4cb-fr5cr 2/2 Running 0 33h 10.288.0.157 <none> <none>
Now if do curl as below with Pod IP
k exec network-toolspod-f64c586f4-7nzrd -- curl 10.288.0.157:9001/counting
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (52) Empty reply from server
command terminated with exit code 52