Transcript for:
ECS Service Connect Overview and Implementation

Hi Procomers, so in this video I'm gonna show you that how different services of a cluster can communicate with each other so using this solution you can let the other service which is from other cluster can communicate with the other services which is from another cluster something like that so don't get confused so keep it simple how we can let these services communicate with each other so that is the scenario we're gonna implement and start implementing it so before that let me quickly give you a flow diagram so that you will understand what i'm trying to say okay so what we did was we created a simple um right this this cluster right so that that that cluster will be having service a and service v in our case we have had user api and the second one was the books api correct now it will it has one uh like different tasks running right so the tasks are running fine and everything Now, AWS has given one of the best solution that is like ECS Service Connect. So what it does is like we have to enable ECS Service Connect, which is something like this, saying that, OK, I have to configure number of services to start communicating with each other via a namespace. So that namespace is nothing but a prefix. Sorry. or some suffix that is saying that if you are inside that namespace then all the services inside that uh namespace can start communicating with each other how so don't worry i'm going to give you that scenario as well so as soon as you configure a container uh or i would say a service saying that hey utilize this service connect what it does behind the scene is it it will launch an agent where it will launch an agent inside this particular container.

So you are configuring there inside the service itself. So whatever the containers will be inside the service, it will be having that agent. That agent will be having the namespace which we are defining inside the service connect.

So that agent will be responsible for maintaining all the network. on behalf of you so you don't have to worry so the end point will be like how you can come start communicating with the other services is something like that for example service a needs to communicate with the service B so what you have to do is that you can open a terminal of service B and then go inside the terminal let me go inside the terminal here the terminal will be inside the terminal you can find you can perform any curl operation and then hit that service a via something like HTTP colon forward slash service name dot okay service name dot name space and whatever the path you have so in our case that the path is related to users or something like that as soon as you hit this one you will get a pinging option to your container saying that yes that is accessible right so that's how the communication will be done inside the ecs uh uh service um inside the ecs uh cluster with multiple services say okay now let's see practically how we can do that one uh you might have remembered that i previously told you that at the time of creating the cluster for example if i go quickly here and then show you that if i'm typing something here ttt something like that this particular thing is automatically be populated here right so this is the nothing but that uh cluster is being sorry namespacing being created for that cluster so it's saying like hey um if you are mentioning the that name space within a service then all the services can inter communicate with each other so now you can see this name space over here previously we have created a book shop right so book shop same exact name was created or not we will see over here so if I go and yes that was created here right so now that cluster already has a name space at the time of creating a new service we will attach that name space how let's quickly do it so first I'm gonna create a new service create users over here I'm gonna type users API now inside this service connect you have to turn on the service connect here client and server you have to select then only it will give you a endpoint something like something like for example I'm gonna share you here so the endpoint will be like HTTP forward slash and the service name dot name space and whatever the url path you have had um sorry the um the port number right this report number is 9000 whatever the port number you have had so in our case so http forward slash service name was so very you can find the service name the service name i was talking about is um If I go back on the cluster here, so inside this cluster, so whatever the service name I'm creating here, that service name like for example books.books-api.the namespace is bookshop. right which is this one here and the container for that bookshop which was i was talking about the container for this this bookshop will be there right so now you have to go inside and let's start creating that one now if i go i was already creating yep i was already creating that one now the thing is that see as soon as i select the client and server it already populated and pre-selected the bookshop namespace now over here you have to add a port like where or like on what port it was exposed to so user api so that discovery name you can put that one as an optional field but yeah so discovery name and the name space you have to add over here based on this one only you can go and you know hit that api or make this service available for the other services something like that so same thing user api dot the name space which i was talking about that was book this one but not the NS one but this one right so and it was exposed to 9001 correct and that's pretty much it you don't have to do anything else apart from this one so just create this one new service now create a new service same like that one but this time we are creating books now here books will be created on books api service like this this time I'm creating service connect here see already populated that bookshop and that is case sensitive so make sure that should be having the same like all lowercase if you provided our case so it's up to you but I prefer lower cases because you know most of the URL comes in the lower case right so I'm selecting books books API selecting books API and not NS that was something else previously created now 9001 9001 not 9001 am i right that was created that was running on 9000 right so that's pretty much it and then just get it just try refreshing it so user is being user service is being created just try refreshing it yeah so book service is also being created now um but how to test that one so i'm gonna tell you in the later video that how we can test that one via the ssh in into it what we have to do what role we have to add and everything okay so let me quickly try refreshing it because i wanted to show you the endpoint which which it will give us so that using that endpoint, we can try to communicate with the other services, right? So if I go here, configuration, and see this is the endpoint I was talking about. So it formed the endpoint exactly the same, HTTP service connector, so users-ap and books shop 9001. So that's how you have to connect that one, right?

The one which I was talking about, like how we can SSH into it. and check that one first of all I'm gonna quickly go and try I'm gonna delete this one I those I don't require that okay so if I open that one let me quickly check whether that is running or not that is running on which one was that uh sorry i'm gonna go over here task definition and then for binding here so that is there 9001 but let me check yeah so that those aren't working fine now that no one is working fine so it should the other one is that should work now the agent which i was talking about see this one eca service connect agent that was the one which i was talking about uh that will be injected directly which is which this one was talking about right automatically inside the container and that's how the other service now if I show you the other service see this one the books you know if I go inside this one go inside the container and show you sees those two cut it is staying to those two container because that is the agent is nothing but a slight lightweight container itself right so that was already there yep so that's pretty much it both services that are working fine in the next video we will test that how we can test that service on and how we can utilize that one using ssh okay so stay tuned and thanks for watching