[Working phase 03.01]
Your Amazon ECS tasks run on a cluster, which is the set of container instances running the Amazon ECS container agent. In this step, you will configure the cluster, review security settings, and set IAM roles.
Follow the configuration settings below:
- Under Amazon ECS > Clusters select Create Cluster
- Select EC2 Linux + Networking as cluster template
- Cluster name: Enter ticketmonster-cluster.
- EC2 instance type: The default t2.micro instance type will keep you within the free tier. Instance types with more CPU and memory resources can handle more tasks. For more information on the different instance types, see Amazon EC2 Instance Types.
- Number of instances: Leave the default value of 1 to launch one Amazon EC2 instance to launch into your cluster for tasks to be placed on. The more instances you have in your cluster, the more tasks you can place on them.
- Key pair: A key pair is required to SSH into your instances later on. You can continue by selecting None - unable to SSH, selecting an existing key pair, or by creating one in the Amazon EC2 console.
- (Optional) Security Group: The default value (Anywhere) allows access from the entire Internet. You also have the option to choose a CIDR block that restricts access to your instances.
- Click Create
Important Create a new RDS Instance as we did before but now in your Cluster VPC.
Wait here and let us create the RDS Instance together
A task definition is like a blueprint for your application. In this step, you will specify a task definition so Amazon ECS knows which Docker image to use for containers, how many containers to use in the task, and the resource allocation for each container.
- Select EC2 as launch type
- Configure task and container definitions
- Task Definition Name: ticketmonster
- Task Role: None
- Network Mode: awsvpc (will allow us to create service security groups)
- Task execution IAM role
- (ecsTaskExecutionRole) This role is required by tasks to pull container images and publish container logs to Amazon CloudWatch on your behalf. If you do not have the ecsTaskExecutionRole already, we can create one for you.
- (Optional) Task size
- Task memory (MiB): 1024
- Task CPU (unit): 1 vcpu
- Container Definitions
- Click Create
Now that you have created a task definition, you will configure the Amazon ECS service. A service launches and maintains copies of the task definition in your cluster. For example, by running an application as a service, Amazon ECS will auto-recover any stopped tasks and maintain the number of copies you specify.
- Under Task Definitions select ticketmonster and click Actions -> Create Service
- Configure service options:
- Configure network:
- Select existing Cluster VPC and all Subnets
- Security Group:
- Load balancing: You have the option to use a load balancer with your service. Amazon ECS can use an Elastic Load Balancing (ELB) load balancer to distribute the traffic across the container instances your task is launched on.
- Service Discovery
- Disable service discovery integration
- Auto Scaling
- Select Do not adjust the service’s desired count
- In this step, you will verify that the sample application is up and running by pointing your browser to the load balancer DNS name.
- SSH into the ECS Instance
- Find out container id
docker ps- Open a bash on the container
docker exec -it CONTAINER_ID /bin/bash- Find wildfly process ids and kill them
ps ax |grep wildfly
kill -9 82