Skip to content

Manage S3 Emulator

This document is a step-by-step guide on how to configure, deploy and cleanup LocalStack, within a kind cluster. LocalStack emulates AWS services locally, which allows the Etcd cluster to interact with AWS S3. This setup is ideal for local development and testing.

00-Prerequisites

Ensure that you have setup the development environment as per the documentation.

Note: It is assumed that you have already created kind cluster and the KUBECONFIG is pointing to this Kubernetes cluster.

Installing AWS CLI

To interact with LocalStack you must also install the AWS CLI (version >=1.29.0 or version >=2.13.0) On macOS run:

Bash
brew install awscli

For other OS, please check the AWS CLI installation documentation.

01-Deploy LocalStack

Bash
make deploy-localstack

The above make target will deploy LocalStack in the target Kubernetes cluster.

02-Setup S3 Bucket

Configure AWS CLI to interact with LocalStack by setting the necessary environment variables. This configuration redirects S3 commands to the LocalStack endpoint and provides the required credentials for authentication.

Bash
export AWS_ENDPOINT_URL_S3="http://localhost:4566"
export AWS_ACCESS_KEY_ID=ACCESSKEYAWSUSER
export AWS_SECRET_ACCESS_KEY=sEcreTKey
export AWS_DEFAULT_REGION=us-east-2

Create a S3 bucket using the following command:

Bash
aws s3api create-bucket --bucket <bucket-name> --region <region> --create-bucket-configuration LocationConstraint=<region> --acl private

To verify if the bucket has been created, you can use the following command:

Bash
aws s3api head-bucket --bucket <bucket-name>

03-Configure Secret

Connection details for an Azure S3 Object Store are put into a Kubernetes Secret. Apply the Kubernetes Secret manifest through:

Bash
kubectl apply -f config/samples/etcd-secret-localstack.yaml

Note: The secret created should be referred to in the Etcd CR in spec.backup.store.secretRef.

04-Cleanup

In addition to the kind cluster cleanup you should also unset the environment variable set in step-03 above.

Bash
unset AWS_ENDPOINT_URL_S3 AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION