Sometimes, EKS works perfectly. But sometimes you need to manage your own cluster. And sometimes, you just want to manage your own cluster. So here's a quick and dirty k8s cluster you can spin up on your own.
Setting up the script with Terraform is pretty straight-forward. It goes something like this:
- Fork this repo
- Fill out the variables
- Apply the script with Terraform
What you'll need is an AWS access key and secret key, and the rest of the variables are just preference.
aws_access_key
: Your AWS Access Key IDaws_secret_key
: Your AWS Secret Keyaws_region
: The AWS region to run this demo in. Defaults to us-east-1aws_azs
: Availability zones for the worker nodes. Defaults to us-east-1a, us-east-1b, and us-east-1ckey_pair
: Your SSH key pair name in order to login to the instancesunit_prefix
: A unique name to prefix resource names with. This is to avoid name collisionsinstance_size
: Size of the instance for the machines in your cluster. Defaults to t3.micronum_worker_nodes
: Number of worker nodes for the cluster. Defaults to 2owner_email
: Your email address
Copy the terraform.tfvars.example
to terraform.tfvars
, edit the file, and fill it out with your settings.
Run terraform apply
and you should be up in running within about 5 minutes.
Create a workspace and connect it to your forked repo. In addition to the Required Variables listed above, you'll need three more bits of information:
BEARER_TOKEN
: This is your Terraform API Key. This can be created in User Settings → TokensORG_NAME
: The TF Organization you're working inWORKSPACE_NAME
: The name of the workspace you created
Copy the tfeapi.tfvars.sh.example
file to tfeapi.tfvars.sh
on a linux host (or your mac). Edit the file, and fill it out with your settings, including the additional 3 variables just mentioned.
Run tfeapi.tfvars.sh
to create all your variables in TFC. If the file isn't executable, you can run chmod +x tfeapi.tfvars.sh
, then try running it again.
Once your workspace is setup, you can Queue Plan in TFC.
The outputs will provide you with an ssh command to login to each box--the master, and one for each node you created. You may need to change the path to your key depending on where your .pem
files are located. It defaults to ~/keys/
.
I hope this is useful. Any feedback is welcome.
Enjoy!