TK8 Cattle AWS Provisioner with Terraform Rancher Provider

Arash
Kubernauts
Published in
3 min readJun 10, 2019

--

Photo by and thanks to Peter Forster on Unsplash

Updated on June 16th: TK8 v0.7.1 support for Spot Instances, Cloudwatch Monitoring, instance type, and AMI Id was added!

My colleague Shantanu Deshpande was working hard on this nice TK8 Cattle AWS Provisioner contribution in the last few weeks to automate the Terraform Rancher Provider implementation with our Swiss Knife TK8. Terraform Rancher Provider was released a few weeks ago to use Rancher Resources to create RKE clusters anywhere you love via IaC (Infrastructure as Code).

The purpose of this short write up is to explain how to get started with Rancher Server and Rancher Kubernetes Engine and TK8 to deploy Enterprise Grade Rancher environments on AWS (Azure, GCP and Bare-Metal support will be possible too).

With this implementation you’d be able to save up-to 90% of your Kubernetes Worker Instances Cloud Cost on AWS with Spot Instances support!

Let’s get started

If you have a Rancher Server running, you need Terraform 0.12 and the latest TK8 binary v0.7.0 from the release page in your path along with the cattle-aws config.yaml file as config.yaml in a new folder, e.g. tk8-cattle-aws and provide your rancher_api_url similar to this config.yaml file:

cattle-aws:
request_spot_instances: true
spot_price:
cloudwatch_monitoring: false
root_disk_size: 20
iam_instance_profile_name: "rancher-controlplane-role"
iam_instance_profile_worker: # specify if overlap_cp_etcd_worker is false and existing_vpc is true
rancher_cluster_name: "cattle-aws-cluster-with-spot-instances"
rancher_api_url: "https://rancher.kubernauts.de/v3"
rancher_access_key:
rancher_secret_key:
rke_network_plugin: "canal"
region: "eu-central-1"
existing_vpc: "false"
vpc_id:
subnet_id:
security_group_name:
ami_id: # specify if you know the specific AMI ID. If used, keep below os field empty (not that setting it would impact).
os: "ubuntu" # specify the OS. Supported values: ubuntu, centos, coreos. Keep above field empty if this is being used.
controlplane_instance_type: "t2.medium"
worker_instance_type: "t2.medium"
overlap_cp_etcd_worker: "false"
overlap_node_pool:
hostname_prefix:
quantity:
master_node_pool:
hostname_prefix: "cattle-aws-master"
quantity: 1
worker_node_pool:
hostname_prefix: "cattle-aws-worker"
quantity: 1

To set your environment variables, please create an env_vars file like this, adapt it and source it:

Deploy your Cattle AWS Cluster with TK8

$ tk8 cluster install cattle-aws

That’s it!

Updated on June 20.:
N.B.: on Ubuntu it didn’t work :-(

Destroy your Cattle AWS Cluster with TK8

$ tk8 cluster destroy cattle-aws

No time to give it a try? Please have a look on this recording:

You don’t have a Rancher Server running?

Then it’s time to get started, please refer to our Enterprise Grade Rancher Deployment Guide and Rancher Labs documentation page.

N.B.: Rancher’s AWS Quick Start is a brilliant way to use Terraform to deploy a Rancher Server very quickly on AWS.

Related Resources

Deploy RKE with a single TK8 command on AWS
Deploy an HA Kubernetes Cluster with RKE and TK8 CLI

Need Rancher Control Plane as a Service?

Get in touch and apply to join our beta program for Kubernauts’ Kubernetes Services.

Credits

We’d love to thank our lovely Shantanu Deshpande, Rancher Labs, HashiCorp and the whole Kubernetes Community for supporting us to build the TK8 Swiss Knife!

We’re hiring

If you’d like to join us and work on exciting K8s and Rancher projects, please have a look here.

Questions?

Please feel free to join uns on Kubernauts’ Slack and ask any questions.

We’re hiring!

We are looking for engineers who love to work in Open Source communities like Kubernetes, Rancher, Docker, etc.

If you wish to work on such projects please do visit our job offerings page.

--

--