Communication between services
# 🌱|help-and-getting-started
d
Hello, guys! So the problem is that i cant access my services within cluster with HTTP-requests. For example, i have two services:
frontend and api-gateway
. Their ports are respectively 3000 and 3001. The main issue is that i cant do a HTTP-request to http://api-gateway:3001 ( i get an
ERR_NAME_NOT_RESOLVED
). I can only do that using
external IP-address (http://127.10.0.7:3001)
. When i used Docker Compose, i had no problems with getting access to the other services with
api-gateway:3001
. I am sorry in advance for it, but can i ask one more question? I run my own test in Garden, but i cant see the
succeed
option in the Dashboard near it. It uses Jest-library to run the test. And it really passes it. Thanks in advance!
Some UPD: I've managed to check all the pods in Minikube, but i couldnt figure out the readdressing of my services. can't understand what's wrong with it...
UPD: So i have checked all containers and tried to execute
wget
command. It works great. The services actually know about each other. Cool. But i cant make axios requests in my NodeJS application 🙂
b
Hello @damp-manchester-26851 welcome to our Discord! Something that you can do to make the setup a little bit easier is use the NGINX Ingress gateway; to do so simply: In your localEnvironment:
Copy code
environments:
  - name: local
    defaultNamespace: ${var.DEFAULT_NAMESPACE}
    variables:
      base-hostname: local.demo.garden
And then in your applications you can setup the ingress like the following:
Copy code
services:
  - name: api
    ports:
    - name: http
      containerPort: 3000
   ingresses:
     - path: /
       port: http
       hostname: api.${var.base-hostname}
Do this for each one of your applications, and now you can do HTTP requests directly to the HTTP endpoint.
api.local.demo.garden
@damp-manchester-26851 let's move the conversation here!
d
Yep!
So i have deleted unnecessary namespaces via
kubectl
b
Beautiful, can you please do a
kubectl get ingress -A
now to see which ingresses you have there?
d
b
beautiful. what happens if you try to go to api.local.app.garden in a browser?
d
It refuses the connection (
b
Ok, just wanted to see. Let's change baseHostname to local.demo.garden instead and stick with that for now
Are you ok with cleaning up your namespace and deploying it again?
d
Ok, i have redeployed the application
b
you can do a
garden delete environment
this will cleanup everything (including dbs and volumes)
and then I would get rid of the namespaces that garden manages to make sure everything gets deployed again
kubectl delete namespace garden-system
also delete the nginx namespace you have there please
are you db's ephemeral?
d
Oh.. Actually, i dont know what you mean. It is just only garden.yml with
image: mongo
So now i have sth like that:
b
oh, sorry. What I mean is that if your application is ok with your db getting deleted and coming back up or you have some sort of static data you didn't wanted to loose
Nice! so now your k8s cluster is clean! Now please execute a good garden deploy and let's see what happens! ❤️
d
Huh, dont mention it! It is completely empty
b
nice! can you try to deploy again? ❤️
d
It is still refusing the connection (
b
Is this the case for any container or just for the API? for example if you open your frontend does it work?
@quaint-dress-831 by any chance do you have experience using Garden's ingress in Minikube?
d
Nothing works ((
b
sad. If you do a port-forward with kubernetes can you access them?
are you using windows or linux?
d
I use Linux, Ubuntu
Do you mean accessing IP like
http://127.10.0.8:8070
?
b
can you do a
kubectl get deployments -A
please?
d
b
No, port-forwarding basically forwards the traffic of a K8s pod to your local
d
Oh... I have never experienced this
b
It's alright, please try this command:
kubectl port-forward -n kaptal-default deployment/api-gateway 3000:3001
d
So whats next?.. It forwarded successfully
b
now, you can go to your browser and type localhost:3000
let's see what happens
d
Yeah, i get a response from my api-gateway
b
nice. so this means that your service is alright. What is failing is the ingress part of the deal.
d
Its soooo weird... I couldnt think that i could deal with such problem xD
b
Well, we are happy to help you in your learning experiences with Garden -> Kubernetes ❤️
d
I really appreciate that help!!
b
Can you please do a
cat /etc/hosts
I think minikube might not be adding a Host entry to resolve DNS locally 🤔
d
b
can you please add this one?
Copy code
::1             localhost
d
Just to change the line under
# The following lines are desirable for IPv6 capable hosts
?
b
no don't change it
add it below FarHowl entry host
it has to have the same indentation
d
b
yes sir, beautiful
can you please try again?
d
((
b
sad stuff
Would you be willing to test different local kubernetes solutions? 😄
d
I am thinking about it right now, huh))
b
I have used this one in the past and it has worked perfectly with the Ingress
d
Let me try! Is it a good soution?
b
oh yes. I have had a great experience with it
Please give it a try, enable kubernetes and point your project to
docker-desktop
context
d
Do i need to enable Kubernetes in Docker Desktop?
b
yes, after you install it
you go to configuration and enable kubernetes check mark
d
Now it works))
b
I'm going to test minikube on the side as well to make sure we don't have a bug there.
it worked in docker-desktop?
d
Yes, in docker-desktop
b
can you please share your hosts again?
cat /etc/hosts
d
b
yes sir. Those lines added by docker desktop are the ones that makes the thing work
d
I see!
b
I'm testing minikube to make sure we don't have a bug
d
I am interested too))
So am i supposed to do requests between services using ingress? Why doesnt the thing as
http://api-gateway:3001
work?
b
can you try to just remove the port?
you can do either or, having the ingress is just a nice feature
for frontends for example
d
b
oh that won’t work from your browser
d
Thats the clg from frontend function. Wont it work?...
b
with the ingress it will
your browser is not going to be able to reach api-gateway itself
d
Ok, thanks! So just using ingresses
b
correct
let me know if that works 😄
d
Yeah, that works!!!
b
I’m glad❤️
3 Views