Skip to content

localstack-samples/localstack-on-eks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Overview

This blueprint has two solutions:

  1. Deploy LocalStack to AWS EKS with Fargate.
  2. Deploy LocalStack on an engineer's laptop on EKS Anywhere with Docker.

Solution-1 provides a hybrid integration environment where teams can run component/integration/system tests. The solution is managed in AWS to allow for easy management of the entire platform across multiple AWS accounts. This is further subdivided into two categories: workloads that run on Fargate backend and workloads that run on EC2 backend.

Solution-2 is identical to Solution-1 but it runs on engineers laptops with EKS Anywhere.

The two solutions having nearly identical tooling allows enterprise teams to create a manageable solution testing platform.

LocalStack on AWS EKS Fargate

Multiple namespaces isolate testing of different solutions.

LSonEKS

LocalStack on Engineer's Laptop with EKS Anywhere

LSonEKSAny

🔑 Key Components

  • LocalStack on K8S LocalStack provides AWS Service emulation to create aan amazing DevX with powerful solution testing.
  • Dev Container Provides standard tooling to build, deploy, and test solutions.
  • Amazon Elastic Kubernetes Service K8S common platform for DevSecOps tooling to support unit, component, and integration testing.

Getting Started 🏁

This guide assumes that you have cloned this repository and are in the project root directory. The following steps will guide you through the process of building, deploying, and test Solution-1 (Solution-2 link). Solution-1 is not free. It will cost money to run EKS in AWS. Make sure to destroy your resources in the cleanup section to control your costs.

Solution-1

This solution has the EKS cluster deployed on AWS.

Prerequisites for Solution-1 🧰

Solution-1 Steps

Let's create the AWS cluster. This blueprint builds namespaces in the format of ls<NS_NUM>. So, we're going to choose a namespace number for the following targets.

make aws-create-cluster

Let's create a namespace ls0 of whose resources are deployed with Fargate:

export FARGATE_WORKLOAD=0
# Create the namespace and the Fargate profile.
make aws-create-fargate-profile NS_NUM=$FARGATE_WORKLOAD

Now let's create a namespace ls1 of whose resources are deployed on EC2 nodes:

export EC2_WORKLOAD=1
# Create the namespace for the workloads on EC2.
make create-namespace NS_NUM=$EC2_WORKLOAD

Then let's deploy Localstack on the namespace that runs its workloads on Fargate:

# Generate manifests and apply Localstack/DevPod deployments.
make deploy-localstack NS_NUM=$FARGATE_WORKLOAD

# Exec into dev environment
make exec-devpod-interactive NS_NUM=$FARGATE_WORKLOAD

Once inside the DevPod environment, let's clone our Localstack sample project:

git clone https://github.com/localstack-samples/lambda-ddb.git
cd lambda-ddb

make integ-awscdk-bootstrap
make integ-awscdk-deploy
make integ-awscdk-test

Now, let's deploy Localstack on the namespace that runs its workloads on EC2 nodes:

# Generate manifests and apply Localstack/DevPod deployments.
make deploy-localstack NS_NUM=$EC2_WORKLOAD

# Exec into dev environment
make exec-devpod-interactive NS_NUM=$EC2_WORKLOAD

And like before, once inside the DevPod environment, let's clone our Localstack sample project:

git clone https://github.com/localstack-samples/lambda-ddb.git
cd lambda-ddb

make integ-awscdk-bootstrap
make integ-awscdk-deploy
make integ-awscdk-test

After the test passes, let's delete the EKS cluster from AWS:

make deploy-cleanup NS_NUM=$FARGATE_WORKLOAD
make deploy-cleanup NS_NUM=$EC2_WORKLOAD
make aws-delete-cluster

Solution-2

This solution has the EKS cluster deployed on your local machine, using the EKS anywhere plugin.

Prerequisites for Solution-2 🧰

Solution-2 Steps

Let's create the AWS cluster using EKS Anywhere locally. This blueprint builds namespaces in the format of ls<NS_NUM>. So, we're going to choose a namespace number for the following targets.

make local-create-cluster

# Create the namespace.
make create-namespace NS_NUM=0

# Generate manifests and apply Localstack/DevPod deployments.
make deploy-localstack NS_NUM=0

# Exec into dev environment
make exec-devpod-interactive NS_NUM=0

Once inside the DevPod environment, let's clone our Localstack sample project:

git clone https://github.com/localstack-samples/lambda-ddb.git
cd lambda-ddb

make integ-awscdk-bootstrap
make integ-awscdk-deploy
make integ-awscdk-test

After the test passes, let's delete the EKS cluster from the local machine:

make deploy-cleanup NS_NUM=0
make local-delete-cluster

Multiple Namespaces

To deploy multiple Localstack instances with their own dev environment, you can do something like this:

function create_environment () {
    local namespace_idx="$1"
    make create-namespace NS_NUM=$namespace_idx
    make deploy-localstack NS_NUM=$namespace_idx
    make exec-devpod-interactive NS_NUM=$namespace_idx
}

function check_localstack () {
    local namespace_idx="$1"
    make exec-devpod-noninteractive NS_NUM=$namespace_idx CMD="curl -i localstack$namespace_idx:4566"
}

# Create a 100 environments
for i in `seq 0 100`; do
    create_environment "$i"
done

# Execute the `ls -la` command on all 1000
for i in `seq 0 100`; do
    check_localstack "$i"
done

About

DevOps blueprint to run LocalStack on EKS in AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published