Hello all, I am new to consul ( exploring now ) and I have installed consul using helm charts on my minikube cluster and it works well. Now I have deployed a sample HTTPBIN application in a separate namespace. Then I have upgraded my installation to enable sync so that services can be synced to catalog and it was successful as I was able to see the service in the catalog from Consul UI as well as API. Now I want to access this httpbin service using /get path via consul, how can I achieve it as I want to use this a service discovery .
Hello @aram , thanks for the help. I have deployed a sample httpbin application on my minikube cluster which has consul running and now if i do a curl request to httpbinservice:port /get I am getting a expected response as what k8’s provides me. Now using k8s-sync I have synced all the services to consul and wondering how to access those services via consul ? Something like below
curl http://127.0.0.1:8500/v1/agent/httpbin/get
Do I need to get my httpbin service registered to consul for accessing it from outside application ? Is syncing and registering a service different ?
In a kubs pod it wouldn’t be 127.0.0.1 but your agent’s kub name so you can get to the consul agent. Or you could make an external call to the leader node if that has a advertise name. Also the path is /agent/services/ … not replace service with your servicename.
Yes sync and register are two different things ( looking at it from a consul point of view). Sync refers to the agents and servers transferring the state of a service. Registration is how you tell consul where your service is so that it can tell anyone else who’s asking.
Is it the problem because I just only synced it not registered ? Actually my goal here is to make my application which is running in same cluster use the httpbin API in consul like service discovery thing.
Hello @aram , thanks for your help and response. I can see services listed along with my service when I exec into the consul-server pod also I have used below API to check the services and I can see my service here
curl localhost:8500/v1/catalog/services
My query is how can consume this service in my another application meaning what hostname:port should and endpoint I use to access this service from my application .
I have deployed the sample and counting example in my k8’s cluster where consul is also being deployed. When I exec into any pod and then try a curl request to the counting pod IP with the port it is giving me empty reply from server message. Is this expected and if yes then how can access my application with pod IP or another way from a another application.
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
The same curl command works as expected giving response if there are no consul sidecar containers present along with the deployment by using annotation ‘consul.hashicorp.com/connect-inject’: ‘true’ . Can you tell me why is it and how to access my application when running in consul please ?
Hello @lkysow I have even tried with Service Ip and still same result as Empty reply from server
k exec <test-tool-podname> -- curl counting.consul-k8s.svc: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
Actually I am thinking whether I should use any other annotation here to expose svc when we are using envoy proxy along with my application. The main problem is I am not able to access my application if there is a side car proxy injection by consul . Can you test it on your end and let me know if you see the same behaviour. This is quite important as I am performing a POC on Consul product to evaluate.
Hello @lkysow any update on this please ? Actually I need this because I am trying to integrate with a external application and want to resolve why I am not able use svc/pod ip to connect to the consul service running with side cars.
Hello @lkysow I have tested with istio service mesh which also injects side car containers and curling a pod ip and port works as expected but only consul side cars I am getting empty reply from server error. Can you please help on this as this becomes a situation for me to re-evaluate other products away from hashicorp products end as this is critical to understand.
Hello @lkysow I have used this sample httpbin application istio/httpbin.yaml at master · istio/istio · GitHub . I can say that the problem is not the application, it is just that when consul injects a side car into application we cannot reach the application via svc ip or pod ip. We need to figure out if we need to add any annotation to make the communication proper when using side car envoy proxy.