Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Deploying a Multi Tenant App to Amazon Elastic Container Service

This blog will help a user deploy a multi tenant application to Amazon Elastic Container Service using Jenkins for automated deployment.

What is a multi tenant application model ?

A multi tenant application model refers to a software architecture in which a single instance of software runs on a server and serves multiple tenants. A tenant is a group of users who share a common access with specific privileges to the software instance.

Why Amazon Elastic Container Service (ECS) ?

Elastic Container Service uses a cluster of EC2 instances to deploy docker containers hence can be configured to autoscale. Also, we can use spot-instances to reduce the TCO.

Fig. (1) ECS Dashboard

Elastic Container Service provides multi tenancy i.e. each user will have his/her own set of container/s that will have scalability and high availability. It does so by providing the ability to create a “Service”. The service can be scaled by applying “service auto scaling” and can provide high availability by applying “service load balancing”.

How does Jenkins help ?

Jenkins allows a user to provide custom inputs that can be used as parameters in the automation scripts while deploying the application.

Jenkins helps you to deploy an application with a single click. All the automation scripts are fetched from git. Once the setup is done, Jenkins will provide the user with a link to his application can be accessed from anywhere.

Pre-requisites

– A Docker image containing the latest version of the application configured and uploaded to Docker Hub [Refer Fig.(2)]

Fig. (2) Docker Hub Dashboard

– A Route53 Hosted Zone for creating application URL’s

Configuration

Step 1 : Creating an ECS Cluster :

– Create an ECS cluster from the ECS console [Refer Fig. (3)]

Fig. (3) Creating an ECS Cluster

– Launch EC2 instances in autoscaling

  • Create a launch configuration that helps you launch spot instances and specify a max bid for acquiring the spot instances [Refer Fig. (4)]

Fig. (4) Creating a Launch Configuration
  • Also, provide custom user data that includes the ECS cluster name to register the instance with & docker hub authentication information   [Refer Fig. (5)]

Fig. (5) Editing User Data of an EC2 Instance
  • Further create an autoscaling group that helps launch instances using the above created launch configuration [Refer Fig. (6)]

Fig. (6) Creating an Auto Scaling Group

 

Step 2 : Running the Jenkins build :

– Once the ECS cluster is up and running, start the Jenkins build that will start deploying the application containers to ECS.

Step 2a : Create a task definition within ECS :

A task definition is required to run Docker containers in Amazon ECS. Some of the parameters you can specify in a task definition include:

  • Docker Image : Docker images to use with the containers in your task
  • Memory Limits : Memory to use with each container
  • Networking Mode : The Docker networking mode to use for the containers in your task
  • Port Mapping : Ports (if any) from the container that are mapped to the host container instance
  • Entrypoint : The command the container should run when it is started
  • nvironment variables (if any) that are to be passed to the container when it starts

Fig. (7) Creating a Task Definition – Step 1

Fig. (8) Creating a Task Definition – Step 2

Step 2b : Create a Service

Amazon ECS allows you to run and maintain a user specified number (the “desired count”) of instances of a task definition simultaneously in an ECS cluster. This is called as a service.

If any of your tasks should fail or stop for any reason, the Amazon ECS service scheduler launches another instance of your task definition to replace it and maintain the desired count of tasks in the service.

Fig. (9) Creating a Service

Configure Service Load Balancing :

Your Amazon ECS service can optionally be configured to use Elastic Load Balancing to distribute traffic evenly across the tasks in your service.

An Application Load Balancer can be created and used to configure service load balancing.

Fig. (10) Configuring Service Load Balancing

Configure Service Auto Scaling :

Your Amazon ECS service can optionally be configured to use Service Auto Scaling to adjust its desired count up or down in response to CloudWatch alarms.

Two alarms per service based on the CPU Utilization need to be created, viz.

– Increase in Load

– Decrease in Load

Associate the two alarms with the corresponding scaling policies, viz.

– Scale Out

– Scale In

Fig. (11) Configuring Service Auto Scaling

Step 2c : Create an Alias record using Route 53 :

Create an Alias record set for the Application Load Balancer’s CNAME using the parameter provided through Jenkins and return it to the user.

Fig. (12) Creating an Alias resource record set

Conclusion :

Jenkins and automation scripts combined with Amazon ECS provide a simple yet effective way of deploying multi-tenant applications.

Also, it saves time by reducing the hassle of manual configuration for every request & provides high availability and scalability.

The post Deploying a Multi Tenant App to Amazon Elastic Container Service appeared first on DevOpsTech Solutions.



This post first appeared on Migrating XEN Virtual Machines To The AWS Cloud, please read the originial post: here

Share the post

Deploying a Multi Tenant App to Amazon Elastic Container Service

×

Subscribe to Migrating Xen Virtual Machines To The Aws Cloud

Get updates delivered right to your inbox!

Thank you for your subscription

×