Eight PowerShell scripts, two CloudFormation templates, and a k3s v1.33 node on localhost:4566

If you want to learn EKS without an AWS bill, the usual advice is "set a budget alarm and be careful". I wanted to remove the risk instead. This repo rebuilds NextWork's "Launch a Kubernetes Cluster" project against Floci, a local AWS emulator. You get a working EKS cluster, a node group, an access entry and a node that comes back after kubectl delete node, all on http://localhost:4566 with dummy credentials.

Along the way eksctl stops working, a few CloudFormation properties get silently ignored, and one EKS API call returns UnknownOperationException. Those gaps shaped the design more than the happy path did, so this post covers them.

The problem with learning EKS on real AWS

The original project has you launch an EC2 instance, install nothing, run eksctl create cluster, and watch CloudFormation build the network. It is a good exercise. It also needs an AWS account, and an EKS control plane plus NAT gateway bills by the hour whether you remember to delete it or not.

Floci removes the account. It exposes EC2, EKS, CloudFormation, IAM and Auto Scaling on one port, and it runs EC2 instances and EKS clusters as Docker containers. The EKS cluster is a k3s container, so kubectl talks to a real Kubernetes API.

The catch is that an emulator is not AWS. eksctl targets real AWS endpoints, so it cannot be the tool here. The project has to do by hand what eksctl does for you.

Project overview

The repo is a numbered set of PowerShell scripts plus two CloudFormation templates:

# Script Result
01 01-start-floci.ps1 Floci up, ec2, eks, cloudformation, iam, autoscaling all running
02 02-launch-instance.ps1 t3.micro instance with an AdministratorAccess profile
03 03-eksctl-error.ps1 eksctl: command not found, exit code 127
04 04-create-cluster.ps1 Two stacks CREATE_COMPLETE, cluster and node group ACTIVE
05 05-track-stacks.ps1 Stack events and resources listed
06 06-access-entry.ps1 IAM user nextwork-admin with an EKS access entry
07 07-node-resilience.ps1 Node deleted, new node Ready
08 08-cleanup.ps1 Everything removed

Requirements: Docker Desktop, AWS CLI v2, kubectl and PowerShell 5.1+. I tested on Windows 11 with AWS CLI 2.39.5 and Floci 2.3.0.

Architecture

Visual instruction: Export this Mermaid diagram to PNG, or reuse images/architecture.png, which is the Excalidraw version from the repo.

Architecture

Everything runs through one shared file, scripts/env.ps1. It sets the dummy credentials, the endpoint and the resource names, and every script dot-sources it:

$env:AWS_ACCESS_KEY_ID = 'test' $env:AWS_SECRET_ACCESS_KEY = 'test' $env:AWS_DEFAULT_REGION = 'us-east-1' $env:AWS_ENDPOINT_URL = 'http://localhost:4566' 

The AWS CLI v2 honours AWS_ENDPOINT_URL, so no --endpoint-url flag is needed on any call. That one variable is what points every command at the emulator.

Step 3: the eksctl failure is the point

Floci runs each EC2 instance as a Docker container, so docker exec stands in for EC2 Instance Connect:

$container = docker ps --filter "name=$id" --format '{{.Names}}' | Select-Object -First 1 docker exec $container bash -c "$cmd 2>&1" "exit code: $LASTEXITCODE (expected 127: command not found)" 

Merging stderr inside bash matters. Under $ErrorActionPreference = 'Stop', PowerShell 5.1 treats native stderr as an error and would abort the script before it printed the exit code.

Visual instruction: Capture this exact code section in VS Code using the OneDark-Pro theme. Use a readable font size and crop unnecessary editor UI.

Here is the real terminal output from the run:

Steps 1 to 3: Floci up, instance launched, eksctl not found

Step 4: replacing eksctl with two templates

eksctl creates two CloudFormation stacks: one for the cluster networking and one for the node group. The repo writes both by hand in templates/.

cluster.yaml builds a VPC 192.168.0.0/16, two /19 subnets in us-east-1a and us-east-1b, an internet gateway, a NAT gateway with an Elastic IP, a route table, a security group and the EKS service role:

SubnetA: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 192.168.0.0/19 AvailabilityZone: us-east-1a 

nodegroup.yaml holds only the node instance role. The stack names follow eksctl's pattern, eksctl-nextwork-eks-cluster-cluster and eksctl-nextwork-eks-cluster-nodegroup-nextwork-nodegroup, so the CloudFormation views look like the original project.

Where the emulator forced a different design

Floci's CloudFormation ignores AccessConfig.AuthenticationMode on create, and it ignores the node group's ScalingConfig and InstanceTypes. If the stack created the cluster, step 6 would have no API mode to work with, and the node group would ignore its sizing.

So the stacks hold the network and IAM roles, and the cluster and node group come from the EKS API:

Invoke-Aws eks create-cluster --name $Cluster --kubernetes-version 1.33 --role-arn (Get-Output 'ServiceRoleArn') ` --resources-vpc-config "subnetIds=$($subnets -join ','),securityGroupIds=$(Get-Output 'SecurityGroupId')" ` --access-config authenticationMode=API_AND_CONFIG_MAP | Out-Null 

The stack outputs feed the API call, so the two halves still connect: subnet IDs, the security group ID and the service role ARN all come from describe-stacks.

One more ordering detail. The node group needs an ACTIVE cluster, and the k3s control plane takes a moment to answer. A small Wait-Cluster loop polls describe-cluster every 5 seconds for up to 60 tries. After create-nodegroup the script waits again, because Floci restarts the k3s container to apply the node group.

Visual instruction: Capture the eks create-cluster and eks create-nodegroup section of scripts/04-create-cluster.ps1 in VS Code using the OneDark-Pro theme. Use a readable font size and crop unnecessary editor UI.

Step 4: both stacks complete, cluster and node group ACTIVE

Step 6: the access entry and a known gap

The script creates IAM user nextwork-admin and an EKS access entry of type STANDARD. On Floci 2.3.0, associate-access-policy returns UnknownOperationException for every user or role ARN, so AmazonEKSClusterAdminPolicy is never attached. The entry is created and listed, and the script prints a note about the limitation. Floci does not enforce access policies anyway, so nothing downstream breaks.

Step 6: access entry created

Step 7: deleting the node

On real AWS you would terminate the instance and let the Auto Scaling group replace it. Floci rejects TerminateInstances on cluster nodes, and Auto Scaling never replaces them. So the script does the closest honest thing: delete the Kubernetes node object, restart the k3s container, and let the kubelet register a fresh node.

Auth needed a workaround too. Floci rejects the shared test/test pair for kubectl, so the script signs in with an access key generated for nextwork-admin:

Remove-AccessKeys $key = Invoke-Aws iam create-access-key --user-name nextwork-admin | ConvertFrom-Json $env:AWS_ACCESS_KEY_ID = $key.AccessKey.AccessKeyId $env:AWS_SECRET_ACCESS_KEY = $key.AccessKey.SecretAccessKey 

Remove-AccessKeys runs first because IAM allows two keys per user, and a second run would otherwise hit LimitExceeded.

The core of the test is four commands:

kubectl delete node $node Get-Nodes # No resources found docker restart "floci-aws-eks-$Cluster" | Out-Null Wait-Node # polls until ' Ready' 

In my run the node was 29 minutes old at v1.33.1+k3s1. After the delete, kubectl get nodes printed No resources found. After the restart, a node with the same name came back Ready at age 5s.

Visual instruction: Capture the delete, restart and wait section of scripts/07-node-resilience.ps1 in VS Code using the OneDark-Pro theme. Use a readable font size and crop unnecessary editor UI.

Step 7: node deleted, then a fresh node Ready

Engineering decisions and trade-offs

  • Hand-written templates over eksctl. eksctl cannot target an emulator. The cost is maintaining two templates. The benefit is that you read every resource eksctl would create.
  • Split between CloudFormation and the EKS API. Forced by the ignored properties. It also makes the split visible: networking and roles are infrastructure, the cluster is a runtime object.
  • Scripts run once, in order. Running 04 twice fails with AlreadyExists. Idempotency would have meant more code for a learning project, so 08-cleanup.ps1 is the reset instead.
  • Reuse port 4566. Step 01 reuses whatever already serves it instead of failing.

Results and limitations

What was verified, by running each script against Floci 2.3.0:

  • Both stacks reach CREATE_COMPLETE, and the cluster and node group reach ACTIVE.
  • kubectl reaches a k3s v1.33 control plane and sees one Ready node.
  • The node recovers after deletion plus a container restart.

What is not the same as AWS:

  • One node, not three. Floci runs one k3s container per cluster, so the node group reports 3 desired, 1 minimum and 3 maximum while a single node exists. t3.micro is metadata only.
  • The recovery in step 7 is not an Auto Scaling replacement. It shows a node returning, not an ASG replacing an instance.
  • Floci is in-memory, so a restart loses everything. Re-run from 02.
  • Behaviour was checked against Floci 2.3.0 only, not real AWS, and not on other Windows, PowerShell or Floci versions.

Run it yourself

git clone https://github.com/axololtos/launch-k8s-cluster-floci.git cd launch-k8s-cluster-floci/scripts Set-ExecutionPolicy -Scope Process Bypass .\01-start-floci.ps1 .\02-launch-instance.ps1 .\03-eksctl-error.ps1 .\04-create-cluster.ps1 # then 05 to 08 

The first 04 is slow because Floci pulls the rancher/k3s image. When you finish, 08-cleanup.ps1 removes the node group, cluster, stacks, instance, role and user, then prints clusters, stacks, Elastic IPs and live instances. All four lines should be empty.

Future improvements

Nothing below is built. Candidates are a Bash version of the scripts for macOS and Linux, and re-testing when Floci supports associate-access-policy and honours ScalingConfig in CloudFormation.

Source

Code, templates and all screenshots: axololtos/launch-k8s-cluster-floci. If it saves you an AWS bill, star the repo, and follow me here on DEV for more local-cloud builds.

Based on the NextWork project "Launch a Kubernetes Cluster". This is an independent rebuild and is not affiliated with NextWork.