Scripts and terraform files to create a rancher cluster over Google Cloud. This will create a rancher kubernetes cluster with 1 master and 3 workers.
- Google Cloud Platform Account
- ssh keypair
- terminal which understands bash (Mac users can open regular command prompt), while Windows users need a bash emulator like gitbash or cygwin or [MobaXterm] (http://mobaxterm.mobatek.net/download.html)
- Clone this repo
- Go to Google Cloud Platform Console and create a new project
- Click "Enable and Manage Google APIs"
- Click Enable API
- In next screen, select "Google Compute Engine API"
- Click Enable (this will take a minute or two)
- Now click button shown below
- Select IAM and Admin
- Click Service Accounts on the left side pane
- Click Create Service Account
- Provide Name as "terraform" Role as Project owner, select "Furnish a new key" of type JSON as shown below
- Click Create, this will download a JSON file.
- Copy this JSON file to credentials folder and rename it as terraform.json
- Copy your public and private keys to the credentials folder as well.
- cd to the repo folder and create a file called terraform.tfvars with below content
region = "us-central1"
region_zone = "us-central1-a"
project = "YOUR_PROJECT_NAME"
image = "ubuntu-os-cloud/ubuntu-1404-trusty-v20161020"
credentials_file_path = "credentials/terraform.json"
public_key_path = "credentials/YOUR_PUBIC_KEY_FILE.txt"
private_key_path = "credentials/YOUR_PRIVATE_KEY.ppk"
#
# If you want to change number of nodes, then uncomment below line and set required value
#node_count = 4
#
# The default project name for the rancher project is k8srancher
# If you want to overwrite that name, uncomment below line and set required value
#rs_proj_name = "YOUR_CHOSEN_PROJECT_NAME"
- Run
terraform apply
This will do following steps:- Create one compute instance as master and start rancher server on it
- Once master instance is created, script waits for the rancher server to boot up.
- API are triggered to create a rancher environment called "k8srancher" (or your chosen project name if you choose to overwrite it in terraform.tfvars), and rancher server is activated as first host of the cluster.
- Remaining compute instances are created and joined to the cluster.
- At the end you will get the IP of the rancher master, you can now go to http://RANCHER_MASTER_IP:8080 and work on your rancher cluster.
- Run
terraform destroy
. There will be a prompt from terraform for confirmation, typeyes
and all resources will be destroyed.