Deploy the LocalStack into your Kubernetes cluster;
How to use the local AWS services in LocalStack.
Install the Helm and use it to deploy the LocalStack into k8s
The LocalStack is a fully functional local cloud stack, which we can use to develop and test the serverless apps offline. We can use Helm to deploy the LocalStack into k8s
To better and easy use the LocalStack, we can install the tool aws-local
1 2 3 4 5
pip install awscli-local # Special environments for the aws-local export LOCALSTACK_HOST=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") export EDGE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services localstack)
Create a bucket
1 2 3
awslocal s3 mb s3://test-bucket # The output should be: >> make_bucket: test-bucket
Copy files or sync folder into the bucket
1
awslocal s3 sync ./public s3://test-bucket
List files from the bucket
1 2 3 4 5 6 7 8 9 10 11 12
awslocal s3 ls s3://test-bucket # The output will be: PRE 2022/ PRE archives/ PRE css/ PRE img/ PRE js/ PRE libs/ PRE tags/ 2022-04-21 10:20:02 766 favicon.ico 2022-04-21 10:20:02 4650 index.html
Use the local S3 from the client SDK. For example: aws-sdk-php The S3 SDK default use virtual hosted-style as the S3 url. bucket-name.s3.region.localhost.localstack.cloud We can override the configures to force use the path-style endpoint