This is part of the Hobby Kube project. Functionality of the modules is described in the guide.
Deploy a secure Kubernetes cluster on Hetzner Cloud, Scaleway, DigitalOcean or Packet using Terraform.
The following packages are required to be installed locally:
brew install terraform kubectl jq wireguard-tools
Modules are using ssh-agent for remote operations. Add your SSH key with ssh-add -K
if Terraform repeatedly fails to connect to remote hosts.
Important: Modify only main.tf in project root, comment or uncomment sections as needed. All variables in variables.tf can be set either directly or from environment variable.
Export the following environment variables depending on the modules you're using:
export TF_VAR_node_count=3
The first N nodes will be part of the etcd cluster. 3 or 5 are good values, see here.
export TF_VAR_etcd_node_count=3
export TF_VAR_hcloud_token=<token>
export TF_VAR_hcloud_ssh_keys=<keys>
export TF_VAR_hcloud_ssh_keys='["<description-key1>", "<description-key2>"]'
# Defaults:
# export TF_VAR_hcloud_location="nbg1"
# export TF_VAR_hcloud_type="cx11"
# export TF_VAR_hcloud_image="ubuntu-18.04"
SSH keys are referenced by their description. Visit the Hetzner Cloud console at
https://console.hetzner.cloud/projects/<project-id>/access/sshkeys
export TF_VAR_scaleway_organization=<access_key>
export TF_VAR_scaleway_token=<token>
# Defaults:
# export TF_VAR_scaleway_region="ams1"
# export TF_VAR_scaleway_type="DEV1-S"
# export TF_VAR_scaleway_image="Ubuntu Bionic"
export TF_VAR_digitalocean_token=<token>
export TF_VAR_digitalocean_ssh_keys=<keys>
export TF_VAR_digitalocean_ssh_keys='["<id-key1>", "<id-key2>"]'
# Defaults:
# export TF_VAR_digitalocean_region="fra1"
# export TF_VAR_digitalocean_size="1gb"
# export TF_VAR_digitalocean_image="ubuntu-18-04-x64"
You can get SSH key IDs using this API.
export TF_VAR_packet_auth_token=<token>
export TF_VAR_packet_project_id=<uuid>
# Defaults:
# export TF_VAR_packet_facility="sjc1"
# export TF_VAR_packet_plan="c1.small.x86"
# export TF_VAR_packet_operating_system="ubuntu_18_04"
export TF_VAR_domain=<domain> # e.g. example.org
export TF_VAR_cloudflare_email=<email>
export TF_VAR_cloudflare_api_token=<token>
export TF_VAR_domain=<domain> # e.g. example.org shall be already added to hosted zones.
export TF_VAR_aws_access_key=<ACCESS_KEY>
export TF_VAR_aws_secret_key=<SECRET_KEY>
export TF_VAR_aws_region=<region> # e.g. eu-west-1
Each provider takes an optional variable to install further packages during provisioning:
module "provider" {
# ...
apt_packages = ["ceph-common", "nfs-common"]
}
From the root of this project...
# fetch the required modules
$ terraform init
# see what `terraform apply` will do
$ terraform plan
# execute it
$ terraform apply
Modules in this repository can be used independently:
module "kubernetes" {
source = "github.com/hobby-kube/provisioning/service/kubernetes"
}
After adding this to your plan, run terraform get
to fetch the module.