Mesos in AWS: Deploying a North-South Application
This article describes how to deploy and verify load-balanced application in a Mesos / Marathon cloud hosted by Amazon Web Services (AWS).
Applications must be created through Marathon, for example with a curl command through the CLI or using the “avi_proxy” label in a CloudFormation template. This article includes steps for creating a simple test application using the Marathon CLI. To create an application using labels, see here.
To deploy a service in this environment:
-
Create the application through Marathon.
-
Set the health check and application port numbers in the AWS EC2 instance to the port number assigned to the application by Marathon.
-
Use a browser to navigate to the application.
Detailed steps are provided below.
Requirements
The article assumes that Avi Vantage is already installed in the Mesos / Marathon cloud.
The steps in this article require access to the following resources:
- Marathon account with privileges to create an application through Marathon
- AWS account through which Avi Vantage was installed
- User account on Avi Controller
- Docker application (if creating a new application using the CLI)
Create an Application Through Marathon
The following commands are entered in an SSH session with Marathon to create a test application:
-
Download Docker.json (https://s3uswest1.amazonaws.com/avitm/Docker.json) and save it in the /Downloads directory.
-
Create a Docker image file such as the following for the application:
{ "id": "webapp-ew1", "cpus": 0.5, "mem": 64.0, "instances": 2, "container": { "type": "DOCKER", "docker": { "image": "avinetworks/server", "network": "BRIDGE", "portMappings": [ { "containerPort": 80, "hostPort": 0, "servicePort": 0, "protocol": "tcp" } ] } }, "labels": {}" }, "healthChecks": [ { "protocol": "HTTP", "portIndex": 0, "path": "/", "gracePeriodSeconds": 5, "intervalSeconds": 20, "maxConsecutiveFailures": 3 } ] }
- Start the application to create a virtual service for it:
curl -H "ContentType: application/json" -X POST -d@Downloads/Docker.json http://marathon-ip-or-hostname:8080/v2/apps
The H and X options are required. The H option inserts a ContentType header for the Avi SE application. The X option changes the HTML method of the request from GET (the default) to POST. Replace marathon-ip-or-hostname with the IP address or hostname of Marathon.
Set the Health-check and Application Port Numbers
-
Locate the port number assigned to the application by Marathon:
a. Log into the Avi Controller web interface.
b. Navigate to Applications > Dashboard, and click on the icon for the virtual service.
c. Hover over the virtual service name, to the left of the Edit button. Copy or write down the port number.
-
Log into your AWS account, and browse to EC2 Load Balancing instance.
-
Click on to go to the AWS home page.
-
Select EC2 and click on Load Balancing in the left pane.
-
Click on stack-name-public instance in the Load Balancer field as shown in this example:
-
Click on the Listeners tab and edit the application port number to the application port number assigned by Marathon.
-
Click on the Health Check tab and edit the ELB health check port number to the application port number assigned by Marathon.