All right.
So now we're going to run our task and for this we're going to define an easy a service that will basically
define how many tasks should run and how they should be run.
And the easiest service will ensure that the number of days our task is always running consistently
across our fleet of easy to instance.
That will also help us when we do updates to our task.
So easy a service can also be linked to an ESB and there'll be an A or B.
So little down says basically if needed and we'll see this in practice.
So let's make our first service OK.
So in our case we're going to go back to our cluster and we're going to click on cluster demo and in
there we want to create a service so civics gets created at the level of a cluster.
So we'll create a service and the lunch type is going to be easy to the task definition is going to
be my issue TPD which comes from the test definition we just created and the revision is one which is
the latest the cluster we assign this to is cluster demo and their service name.
I'll just call it HPD service.
Now the type of service we're going to run is replica and replicable means that we're going to run as
many task as possible so if I say five is going to try to run five tasks but if I run daemon it's different
the number of task is automatic it is going to try to run one task on each e yes instance easy to instance
in our use yes cluster.
So Damon is like when you want to run maybe monitoring across all your instances and gather metrics.
But for our case because we just want to run our application or just run replicate the number of task
I will choose for now is one.
Now the M.O. healthy.
I'll just set this a zero.
You don't need to understand why we're just at a zero.
This will allow us basically to do rolling restarts and the maximum person will be 200.
Now four deployments we defined how is our service deployed.
And so the deployment type is going to be rolling update that squad comes with basically with ease.
Yes but now there's a new rolling deployment called Blue Green deployment that is powered by code deploy.
This is out of scope for now but just know that's code deployed can be used to deploy HECS as well.
We'll keep this as rolling updates task placements.
We'll just leave it as default which is basically this for defending a strategy of how to place task
on different e yes instances.
So you can choose whatever you want for now or just use AC balance spread.
Okay.
Click on next up and we scroll back up.
Now we can figure the network.
So basically we can choose a load balancer type.
And for now I'll choose none.
And this is intended but will add a load balancer later on.
But we could choose application network or classic load balancer will enable I will disable a service
discovery integration because this is out of scope and a little bit too complicated.
So click on next and we'll not set up the scaling but it is possible to set up Otis going for your easiest
service as well.
Next step.
Okay.
Everything looks good.
We're running this test definition this is the name of our service.
We're going to run one task it's a replica type minimum healthy and maximum healthy zero to hundred
network is not configured and is not configured either.
That makes a service really simple.
Let's create the service.
The service was created we can view service and as we can see now very very quickly a task is in pending
state.
So our service is going to start a task to basically launch our HPD task.
Okay let's go back to um cluster demo and in there we can see that we have our service name GDP service
that's running the desired number of task is one and the number of running task is one as well.
So our task is running.
If you go to tasks now we can see in this tab that indeed our task is running this task definition and
it's running on this container instance right here.
So what I could do is click on this container instance and get some information around the public IP
and stuff but we know it's our easy to instance we just created.
So as we can see this instance had one 24 ACP but now we're using a limit.
So it has less CPSU available and the memory as well has decreased because we've reserved some stuff.
OK so this is good.
Let's go back to a cluster demo.
Everything looks good the task is created.
So how about we check out our service.
So for this if we go to the uh public IP of our instance so let's begin our instance here is the public
IP and we go to Port 88.
If you're attentive this should work but it doesn't.
Why.
Well because it's a security group issue obviously.
So we click on the security group we go to inbound edits we're going to add a rule and custom GPL say
for Port ADHD from anywhere we'll just allow as you TPD click on save.
And now we've added that rule.
So if I if I go back.
Yes.
Now it says it works.
So our first docker container is running are easy to instance and it's mapped to port 88.
And this is it works saying as you TPD works that's just what it does.
It is just as it works.
Now if we go back into our instance and want to have a look at what's happening would you Ducker.
Yes.
And now we can see that on top of the Amazon.
Yes.
Agents.
There is HPD.
Two point four that is running in the foreground and has started so we could also curl you know this
container from our local host and do quote local host ADHD and we get it works back as an answer.
So very cool right.
We have one easy to instance running in our cluster and is running a task of HPD.
Very very awesome.
So now you may ask me can we scale our service.
Can we run two tasks.
So let's take on the service update it and then when I want to do now is a number of tasks to click
on.
Next up click on Next Step and click on Next up an update service.
So now we're saying to our service I want to have two tasks running.
But the problem is as we can see nothing will happen.
So nothing happens there's just one task happening no other task spending.
And it says okay it was unable to place a task because no container instance met its requirements.
The container is already using a port required by your task.
So if you remember in our task definition right here when we have defined our task we said hey by the
way I want you to map the container port to the host port 88.
So we can only have one task per.
Yes.
Instance because if I try to launch a second task it will try to use again that port ADHD but it's already
used by our instance so this will not work.
So this is a bit of a problem but for now let's do something pretty cool instead of launching to task
on the same issue to instance where we can do is scale our cluster so we can go to E yes instances I'll
click on scale easy to use yes instances in how I have to instance this will basically create another
two to micro that will come up and hopefully should join the cluster and then run our task.
So let's wait a little bit.
Okay.
So if I refresh this.
Now I see two instances.
And what happened is that our oldest killing group so if we go back to our orders killing group right
here our Earth is killing group was updated to have a desired count of two.
So it has created to issue two instances total.
Now if we go back to East yes we see that instance get registered into medically and actually all of
the sudden you know magically a second task is running.
So now we have to task HPD running on two different container instances.
So let's have a quick look at the IP of this one so I think it was this this instance just got launched.
Well we'll have a look at the IP so here is the public IP top right.
And I'll go to the port 88.
And yes it works too.
So now we have two instances running our HDTV image and it works.
So that's it for this beginning but we'll see how to relaunch this with a little load balancer and see
how we can make this more fun.
So I will see you in the next lecture.