Skip to content

moabukar/eks-localstack

Repository files navigation

EKS on localstack

  • Terraform + AWS / LocalStack

Prerequisites

For 🍎 macOS users, you can use the Brewfile script to simplify the installation of all the necessary dependencies.

If you have Homebrew installed, follow these steps:

brew bundle

🚀 Getting Started

🏠 LocalStack

  • Install LocalStack AWS CLI (awslocal) and tflocal

  • Run LocalStack:

    • 🆓 Community:

      docker-compose -f localstack-compose.yml up
    • 💸 Pro:

      required, for example, for the EKS component. more info: LocalStack Coverage

      ⚠️ You need to provide LOCALSTACK_API_KEY value.

      # Set up the API Key
      export LOCALSTACK_API_KEY=<your-api-key>
      
      # Run LocalStack Pro
      docker-compose -f localstack-pro-compose.yml up
##or you can just do 

you need localstack pro (you can get free trial)

export LOCALSTACK_AUTH_TOKEN=<>
localstack start # in another terminal
  • Initialize Terraform:
tflocal init
  • Generate Terraform plan:
tflocal plan
  • Apply Terraform configuration:
tflocal apply -auto-approve

☁️ AWS

  • Create S3 state bucket
aws s3api create-bucket --bucket tf-state
  • Initialize Terraform:
terraform init
  • Generate Terraform plan:
terraform plan
  • Apply Terraform configuration:
terraform apply -auto-approve

Connecting to EKS on LocalStack using kubectl

1. Update kubeconfig for EKS Cluster

First, you need to add the my-eks cluster information to your ~/.kube/config to enable kubectl to know where your cluster is and how to access it.

awslocal eks update-kubeconfig --name my-eks

2. Configure AWS CLI for LocalStack

Before interacting with LocalStack, configure the AWS CLI to use dummy credentials. Though LocalStack doesn't validate these credentials, it expects them to be set.

Run the configuration command:

aws configure

When the AWS CLI prompts you for the credentials, use dummy credentials:

AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test

3. Set current k8s context


brew install kubectx

kubectx arn:aws:eks:us-east-1:000000000000:cluster/my-eks

4. Validate kubectl Configuration

List resources across all namespaces to validate the connection:

kubectl get all -A

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published