hamburger icon close icon
Multicloud Storage

AWS ECS Anywhere Getting Started Walkthrough

AWS ECS Anywhere: How to Get Started

Designing a microservices architecture is a popular choice due to the inherent service decoupling and flexibility it provides. To implement that architecture, a container-based approach is usually adopted. Yet, because each container is a single logical unit, this type of architecture can only be fulfilled with a platform capable of enabling the orchestration of multiple container workloads. Today, such platforms also play a key role fulfilling compute and storage needs across different locations and multicloud environments.

While Kubernetes remains a top contender for container orchestration, it might be an overly complex approach if your solution only has a few containers or does not require any of the Kubernetes advanced functionalities.

The Amazon Elastic Container Service (ECS) is a prime choice to run, manage, and orchestrate container workloads in AWS. But until now, that functionality has been limited to the AWS ecosystem. That’s all changing with Amazon ECS Anywhere from AWS. Anywhere makes it possible for customers to work outside of AWS.

Read on as we cover:

What Is AWS ECS Anywhere?

ECS now goes beyond AWS. Anywhere is a new feature released for Elastic Container Service (ECS) and Elastic Kubernetes Service (EKS) clusters that allows these services to be used on non-AWS environments.

EKS and ECS typically use virtual instances (EC2) or serverless compute technologies (Fargate) to run the containers. However, with the Anywhere feature, customers can now choose to connect non-AWS computing environments (edge, on-premises, other public clouds) to their ECS and EKS clusters. This enables container execution to happen anywhere (hence the name) while still managing and operating the workload using the same AWS tooling and capabilities.

AWS ECS Architecture with Anywhere Capabilities

ECS Anywhere gives you the ability to extend a typical AWS ECS cluster outside the boundaries of AWS. In terms of ECS architecture, the biggest change is that non-AWS machines can now be registered into the cluster.

ecs anywhere archAWS ECS Anywhere cluster high-level architecture

The process of registering non-AWS machines is fairly straightforward and easy. In this article we are going to guide you through the process of making an AWS ECS deployment using the Anywhere feature with a non-AWS machine.

How to Set Up AWS ECS Anywhere in a Non-AWS Environment

This AWS ECS tutorial starts with the creation of a new empty cluster and preparations to enable the registration of external machines.

1. Configuring and Deploying a New AWS ECS Cluster

The first step to setting up your AWS ECS Anywhere deployment begins with an ECS cluster. For this example, we’ll create a new cluster. 

1.1 In the AWS Console, navigate to the Elastic Container Service and press the “Create Cluster” button.

Screenshot_5_7_2021__15_51Starting the AWS ECS cluster creation process

1.2 The process to create a new AWS ECS cluster will be initiated. The first step is to choose what type of cluster is needed. Select the “Networking only” type, which is suitable to use with container tasks that are run externally (i.e., outside AWS) using ECS Anywhere.

Cursor-Aug-24-2021-07-03-37-57-AMSelecting ECS cluster type

1.3 Fill in the AWS ECS cluster name and keep the other settings with the default values. Press the button “Create” to finish the set up.

Screenshot_5_7_2021__15_53AWS ECS cluster settings

1.4 If successful, the AWS ECS cluster will be created and set as active.

Screenshot_5_7_2021__16_07ECS cluster overview

2. Enabling the ECS Anywhere Feature

Once your cluster is ready to use in ECS, you can enable the Anywhere functionality.

2.1 To enable the Anywhere feature, navigate to the ECS Instances tab and press the Register Externals Instances button to add a non-AWS machine to the ECS cluster.

Screenshot_5_7_2021__15_59-2Instances view in ECS cluster

2.2 The external instances registration process enables you to change the duration of the activation key and the number of instances you want to add. Keep the default values and move forward by clicking “Next Step.”

pasted image 0 (3)Key duration and number of externals instances

2.3 The last panel will contain an auto-generated command that will be used by the non-AWS machine to register it in the ECS cluster. Copy the command using the “Copy” button.

pasted image 0 (2)Auto-generated command to register an external machine

3. Preparing the Non-AWS Environment

Next, you’ll need to set up the non-AWS environment that is going to be leveraged by ECS.

3.1 Log in to a non-AWS machine using SSH and escalate your privileges to administrator (i.e. root) using the command sudo -i

3.2 Paste the command obtained from the AWS console and execute it.

pasted image 0 (1)Escalate as root and run the ECS registration command

3.3 If successfully executed, the ECS agent will be installed, and the machine will be registered in the ECS cluster.

pasted image 0-1ECS Agent successfully running

3.4 Navigate to the AWS console and verify that the non-AWS machine is now visible in the ECS Instances tab of the cluster.

Amazon_ECSNon-AWS machine visible in ECS Instances

4. Run a Task

Now that your cluster is set up to work outside of AWS, let’s have it run a task.

4.1 In the AWS console, navigate to the Task Definitions view in ECS. Press the button to initiate the process of creating a new task definition.

Amazon_ECS-2Task Definitions view in ECS

4.2 Select EXTERNAL as the launch type and proceed to the next step.

Amazon_ECS-5Launch compatibility

4.3 Configure the task and container definitions, starting by choosing a task definition name.

Amazon_ECS-6Task and container definitions: task settings

4.4 Press the “Add Container” button to open a new panel. Choose a container name and image. The AWS ECR public gallery has a variety of options you can choose from. As a suggestion, you can use NGINX (public.ecr.aws/nginx/nginx:latest), a popular web server application.

4.5 Choose the memory limits for the container task and any port mappings needed. Because NGINX is a web server, the port 80 (http) is used. Click “Add” when you are done.

Amazon_ECS-7 Task and container definitions: container settings

4.5 Go to the end of the page and press the “Create” button to create the new task definition.

Amazon_ECS-8-1Finalize the task and container definitions creation

5. Test and Validate the Setup

If you’ve followed all of the steps above, you should have a working ECS container enabled by Anywhere for use in a non-AWS environment. To test and validate that everything works, follow the steps below:

5.1 Run a new task from the newly created task definition using the dropdown “Actions” menu button.

Screenshot 2021-07-16 at 0.17.58Task Definition dropdown actions

5.2 Choose EXTERNAL as the launch type.

Amazon_ECS-9Run task panel: launch type

5.3 Start the new task.

Amazon_ECS-10Finalizing the run task process

5.4 A new container task will be launched in the ECS cluster and placed in the non-AWS external machine.

Amazon_ECS-11External task running in ECS cluster

5.5 Go to the non-AWS machine and verify that the task is indeed running there by using the docker ps command.

bruno_instance-1___-1Docker ps command output

5.6 If you choose the NGINX public container image, use the curl http://localhost command to verify that the container task was successfully started.

bruno_instance-1___-2Curl command output

Conclusion

These days, the clouds are more apt to share services across borders than ever before. This is evident in the new services provided by Google Anthos and Azure Arc, and the same is true for AWS. Anywhere is already proving to be aptly named.

With ECS Anywhere, AWS took a bold step to enable building hybrid and multicloud architectures. The ability to centrally manage and operate container-based workloads in AWS regardless of the environment they are located in is quite powerful. The same AWS cloud-native processes and tooling can now be used to achieve a consistent developer experience in traditional on-premises environments or other public cloud providers.

The role of storage is quite important in these hybrid scenarios. AWS ECS Anywhere focuses on the computational aspect and leaves the data storage challenges up to engineering teams to solve. Cloud Volumes ONTAP, the data management solution by NetApp, is an ideal tool to complement your ECS Anywhere based solution.

Similar to what AWS ECS offers for computational tasks, Cloud Volumes ONTAP provides a central data management solution that works across on-premises and cloud environments such as AWS, Google and Microsoft Azure. This enables customers to benefit from enterprise grade features such as high availability, cost-cutting storage efficiencies, data protection and many others that make Cloud Volumes ONTAP a popular choice for hybrid and multicloud storage management requirements and architectures.

New call-to-action

Bruno Almeida, Technology Advisor

Technology Advisor

-