Skip to content

kevincloud/k8s-cluster-aws

Repository files navigation

Kubernetes Cluster for AWS

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.

Getting Started

Setting up the script with Terraform is pretty straight-forward. It goes something like this:

  1. Fork this repo
  2. Fill out the variables
  3. 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.

Required Variables

  • aws_access_key: Your AWS Access Key ID
  • aws_secret_key: Your AWS Secret Key
  • aws_region: The AWS region to run this demo in. Defaults to us-east-1
  • aws_azs: Availability zones for the worker nodes. Defaults to us-east-1a, us-east-1b, and us-east-1c
  • key_pair: Your SSH key pair name in order to login to the instances
  • unit_prefix: A unique name to prefix resource names with. This is to avoid name collisions
  • instance_size: Size of the instance for the machines in your cluster. Defaults to t3.micro
  • num_worker_nodes: Number of worker nodes for the cluster. Defaults to 2
  • owner_email: Your email address

Terraform OSS

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.

Terraform Cloud

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 → Tokens
  • ORG_NAME: The TF Organization you're working in
  • WORKSPACE_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.

Outputs

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/.

Conclusion

I hope this is useful. Any feedback is welcome.

Enjoy!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published