Running AWS ECS Anywhere on Premises Using a Raspberry Pi 4 - cfloquetprojects/homelab GitHub Wiki
Introduction
Today we will be exploring how to leverage our own hardware resources (in this case a Raspberry Pi 4 to use as compute hardware for an ECS (Elastic Container Service) Cluster.
Amazon Elastic Container Service (ECS) works well in orchestrating containerized application development & deployment, but up until recently has been strictly limited to running solely on AWS managed hardware.
We will be adding to our existing homelab setup (none of which has involved AWS thus far) a single Raspberry Pi 4 host which will serve as a trial run for our journey into AWS ECS to begin.
Pre-Flight Check:
It's important that we have taken the time to install Ubuntu Server
on the Raspberry Pi 4 that we will be using to run our ECS Cluster.
💡 The easiest way to accomplish this is simply using the user-friendly Raspberry Pi Imager which just requires an SD to image for the pi itself.
Ensure you have created a free AWS account, and have applied basic IAM principles to your environment.
Creating a Cluster
Now that we have our named user account with proper permissions to access the ECS
service, we can begin the configuration, but be sure to check your current region within the AWS console. Currently I am operating within the us-east-1
region, just pick the one that suits your geographic region best:
Once you have confirmed the correct region for your purposes, and Create Cluster
to begin the process.
Since we will be using an externally hosted system (Raspberry Pi 4), we should choose Networking Only
Now we get the chance to name our cluster, which I have done using a fairly basic nomenclature, and also create a VPC for our cluster to use. I've chosen to create some specific subnets within the larger CIDR block, but this is entirely up to you and what your personal preferences or requirements are.
After clicking Create Cluster
we should be greeted with a ECS Status
screen, which outlines the resources being created for that particular cluster, as well as the status of the cluster and CloudFormation Stack.
Once it is complete, we can hit View Cluster
which will take us back to the Clusters page, where we need to then navigate to the ECS Instances
tab, where we can then choose to Register External Instances
:
This page we can keep default, but just outlines the choices we are given for activation key period, number of instances we will be registering (which is only one in our case) as well as the specific role for that instance.
After hitting next we are provided with a curl
command to download the necessary scripts from AWS to complete the external instance registration process. You will need to run the command as root on your Raspberry Pi, the easiest method to do so would be to establish a CLI connection over SSH.
💡 PuTTY is a terrific SSH client for Windows that is jam-packed with helpful features, but is also completely free. I'd recommend using this to connect to your Raspberry Pi 4 host over the network to run these commands, rather than typing them in by hand manually.
💣 If you end up deleting/deregistering your ECS cluster, you will need to clear your external host of the configuration as well, which you can read about in Deregistering an external instance