Small sample code to run a Localstack provisioned "EKS Fargate" cluster (k3d)
- Pulumi
- Localstack Pro
- (Optional) Set Pulumi for local backend
export PULUMI_BACKEND_URL=file://`pwd`
export PULUMI_CONFIG_PASSPHRASE=lsdevtest
- Create project dir
mkdir test-eks
- Init project
pulumi init aws-python -y -s dev -C test-eks
- Pin pulumi version
cat <<EOF > test-eks/requirements.txt
pulumi>=3.0.0,<4.0.0
pulumi-aws==6.0.4 #Must be pinned due to pulumi-eks hardcoded dependency
pulumi-eks
pulumi-kubernetes
EOF
- Add pulumi code to
__main__.py
- Run
pulumilocal preview -C test-eks -s test
and interrupt it (^C) after it starts to hang - Clean up unnecessary endpoints from
Pulumi.test.yaml
- We are now set to run the code ✅
- (optional) Set AWS variables if there is no default profile configured
export AWS_SECRET_ACCESS_KEY=test
export AWS_ACCESS_KEY_ID=test
export AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
- Run Localstack
localstack start -d
- Run pulumi
pulumi up -y -C test-eks -s test
- Visit
http://localhost:8081
- Profit 💵
Simply run:
pulumi destroy -y -C test-eks -s test
- Env variables
AWS_ENDPOINT_URL
,AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
are necessary before running the code as kubernetes deployment not inheriting AWS creds - AWS version pinned to 6.0.4 due to hard coded dependency in pulumi-eks so pulumilocal could generate the right endpoints first (then we removed the ones we didn't need)
- Run with
pulumi
and notpulumilocal
due to performance degradation in this version of AWS package with increasing number of custom endpoints (adding all 2xx endpoints withpulumilocal
would make this sample run 20-30 mins) - if configuring the endpoints manually and not using pulumilocal the version pin is not necessary
- for
NodePort
services one must expose the server port manually with:
k3d cluster edit <CLUSTER_NAME> --port-add <HOST_PORT>:<NODE_PORT>@server:0
LoadBalancer
type services currently are not supported