This repo contains a demo of LocalStack running in Kubernetes. The demo includes:
- A MySQL database
- A Lambda function that connects to the database and performs a demonstration query
- Terraform code to deploy the infrastructure
- A Makefile and scripts to deploy everything
This demo is meant to highlight how LocalStack supports both Kubernetes and Docker environments.
architecture-beta
group api(cloud)[VPC]
service db(server)[Database] in api
service server(server)[Lambda] in api
server:R --> L:db
Note
LocalStack's Kubernetes integration is only available on our Enterprise tier.
- Make sure your
LOCALSTACK_AUTH_TOKENis in your shell environment - Install
- Ensure your environment is configured to communicate with LocalStack instead of AWS.
- Run
make initto set up the terraform providers
- Deploy the cluster:
make start- This starts a local Kubernetes cluster using
kindand fetches the Docker images for LocalStack and the demo application
- This starts a local Kubernetes cluster using
- Start the LocalStack operator:
make deploy-operator. By default this uses the latest version, but you can specifymake deploy-operator OPERATOR_VERSION=v0.4.0for example to use a specific version. - Deploy LocalStack:
make deploy-localstack-instance port-forward- This installs LocalStack into the Kubernetes cluster using our Kubernetes operator
- It also port forwards port 4566 to the host (blocks the shell)
- Deploy application:
make reset apply- This resets the terraform state and applies the Terraform configuration, which creates the database and Lambda function
- Invoke the lambda function:
make invoke- This invokes the Lambda function and demonstrates that it can connect to the database
- To remove the deployed application, run
make destroy-app - To remove LocalStack from the Kubernetes cluster, run
make destroy-localstack-instance - For removal of the Kubernetes cluster as well, run
make stopto delete the local Kubernetes cluster