https://garden.io logo
#🌱|help-and-getting-started
Communication between services
# 🌱|help-and-getting-started
d

damp-manchester-26851

04/21/2023, 5:08 PM
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

bright-policeman-43626

04/23/2023, 10:38 AM
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

damp-manchester-26851

04/24/2023, 10:50 AM
Yep!
So i have deleted unnecessary namespaces via
kubectl
b

bright-policeman-43626

04/24/2023, 11:03 AM
Beautiful, can you please do a
kubectl get ingress -A
now to see which ingresses you have there?
d

damp-manchester-26851

04/24/2023, 11:03 AM
b

bright-policeman-43626

04/24/2023, 11:03 AM
beautiful. what happens if you try to go to api.local.app.garden in a browser?
d

damp-manchester-26851

04/24/2023, 11:04 AM
It refuses the connection (
b

bright-policeman-43626

04/24/2023, 11:06 AM
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

damp-manchester-26851

04/24/2023, 11:09 AM
Ok, i have redeployed the application
b

bright-policeman-43626

04/24/2023, 11:10 AM
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

damp-manchester-26851

04/24/2023, 11:12 AM
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

bright-policeman-43626

04/24/2023, 11:17 AM
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

damp-manchester-26851

04/24/2023, 11:18 AM
Huh, dont mention it! It is completely empty
b

bright-policeman-43626

04/24/2023, 11:20 AM
nice! can you try to deploy again? ❤️
d

damp-manchester-26851

04/24/2023, 11:20 AM
It is still refusing the connection (
b

bright-policeman-43626

04/24/2023, 11:23 AM
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

damp-manchester-26851

04/24/2023, 11:24 AM
Nothing works ((
b

bright-policeman-43626

04/24/2023, 11:24 AM
sad. If you do a port-forward with kubernetes can you access them?
are you using windows or linux?
d

damp-manchester-26851

04/24/2023, 11:25 AM
I use Linux, Ubuntu
Do you mean accessing IP like
http://127.10.0.8:8070
?
b

bright-policeman-43626

04/24/2023, 11:26 AM
can you do a
kubectl get deployments -A
please?
d

damp-manchester-26851

04/24/2023, 11:27 AM
b

bright-policeman-43626

04/24/2023, 11:27 AM
No, port-forwarding basically forwards the traffic of a K8s pod to your local
d

damp-manchester-26851

04/24/2023, 11:28 AM
Oh... I have never experienced this
b

bright-policeman-43626

04/24/2023, 11:28 AM
It's alright, please try this command:
kubectl port-forward -n kaptal-default deployment/api-gateway 3000:3001
d

damp-manchester-26851

04/24/2023, 11:29 AM
So whats next?.. It forwarded successfully
b

bright-policeman-43626

04/24/2023, 11:30 AM
now, you can go to your browser and type localhost:3000
let's see what happens
d

damp-manchester-26851

04/24/2023, 11:30 AM
Yeah, i get a response from my api-gateway
b

bright-policeman-43626

04/24/2023, 11:31 AM
nice. so this means that your service is alright. What is failing is the ingress part of the deal.
d

damp-manchester-26851

04/24/2023, 11:32 AM
Its soooo weird... I couldnt think that i could deal with such problem xD
b

bright-policeman-43626

04/24/2023, 11:32 AM
Well, we are happy to help you in your learning experiences with Garden -> Kubernetes ❤️
d

damp-manchester-26851

04/24/2023, 11:34 AM
I really appreciate that help!!
b

bright-policeman-43626

04/24/2023, 11:35 AM
Can you please do a
cat /etc/hosts
I think minikube might not be adding a Host entry to resolve DNS locally 🤔
d

damp-manchester-26851

04/24/2023, 11:36 AM
b

bright-policeman-43626

04/24/2023, 11:40 AM
can you please add this one?
Copy code
::1             localhost
d

damp-manchester-26851

04/24/2023, 11:41 AM
Just to change the line under
# The following lines are desirable for IPv6 capable hosts
?
b

bright-policeman-43626

04/24/2023, 11:42 AM
no don't change it
add it below FarHowl entry host
it has to have the same indentation
d

damp-manchester-26851

04/24/2023, 11:44 AM
b

bright-policeman-43626

04/24/2023, 11:44 AM
yes sir, beautiful
can you please try again?
d

damp-manchester-26851

04/24/2023, 11:45 AM
((
b

bright-policeman-43626

04/24/2023, 11:46 AM
sad stuff
Would you be willing to test different local kubernetes solutions? 😄
d

damp-manchester-26851

04/24/2023, 11:47 AM
I am thinking about it right now, huh))
b

bright-policeman-43626

04/24/2023, 11:47 AM
I have used this one in the past and it has worked perfectly with the Ingress
d

damp-manchester-26851

04/24/2023, 11:48 AM
Let me try! Is it a good soution?
b

bright-policeman-43626

04/24/2023, 11:51 AM
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

damp-manchester-26851

04/24/2023, 11:51 AM
Do i need to enable Kubernetes in Docker Desktop?
b

bright-policeman-43626

04/24/2023, 11:55 AM
yes, after you install it
you go to configuration and enable kubernetes check mark
d

damp-manchester-26851

04/24/2023, 11:59 AM
Now it works))
b

bright-policeman-43626

04/24/2023, 11:59 AM
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

damp-manchester-26851

04/24/2023, 12:00 PM
Yes, in docker-desktop
b

bright-policeman-43626

04/24/2023, 12:00 PM
can you please share your hosts again?
cat /etc/hosts
d

damp-manchester-26851

04/24/2023, 12:00 PM
b

bright-policeman-43626

04/24/2023, 12:02 PM
yes sir. Those lines added by docker desktop are the ones that makes the thing work
d

damp-manchester-26851

04/24/2023, 12:02 PM
I see!
b

bright-policeman-43626

04/24/2023, 12:02 PM
I'm testing minikube to make sure we don't have a bug
d

damp-manchester-26851

04/24/2023, 12:02 PM
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

bright-policeman-43626

04/24/2023, 12:34 PM
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

damp-manchester-26851

04/24/2023, 12:37 PM
b

bright-policeman-43626

04/24/2023, 12:41 PM
oh that won’t work from your browser
d

damp-manchester-26851

04/24/2023, 12:43 PM
Thats the clg from frontend function. Wont it work?...
b

bright-policeman-43626

04/24/2023, 12:44 PM
with the ingress it will
your browser is not going to be able to reach api-gateway itself
d

damp-manchester-26851

04/24/2023, 12:44 PM
Ok, thanks! So just using ingresses
b

bright-policeman-43626

04/24/2023, 12:48 PM
correct
let me know if that works 😄
d

damp-manchester-26851

04/24/2023, 12:57 PM
Yeah, that works!!!
b

bright-policeman-43626

04/24/2023, 1:13 PM
I’m glad❤️
3 Views