Skip to content

Terraform Module to deploy a Kubernetes Cluster using RKE Provider in Hetzner Cloud

Notifications You must be signed in to change notification settings

brotandgames/terraform-hcloud-rke

Repository files navigation

terraform-hcloud-rke

Terraform Module to deploy a Kubernetes Cluster using RKE Provider in Hetzner Cloud.

Usage

See test/main.tf for example usage of the module.

You might want to include the CSI driver for automatic provisioning of volumes by adding https://raw.githubusercontent.com/hetznercloud/csi-driver/v1.2.3/deploy/kubernetes/hcloud-csi.yml to addons_include variable. (Note: A configmap containing the api key needs to be added as well.)

Requirements

Name Version
terraform ~> 1.0
hcloud ~> 1.31
local ~> 2.1
null ~> 3.1
rke ~> 1.2
template ~> 2.2

Providers

Name Version
hcloud 1.31.1
rke 1.2.4

Modules

No modules.

Resources

Name Type
hcloud_server.this resource
hcloud_ssh_key.this resource
rke_cluster.this resource

Inputs

Name Description Type Default Required
addons_include List of URLs to yaml resources to include eg. install Kubernetes Dashboard list(string)
[
"https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml",
"https://gist.githubusercontent.com/superseb/499f2caa2637c404af41cfb7e5f4a938/raw/930841ac00653fdff8beca61dab9a20bb8983782/k8s-dashboard-user.yml"
]
no
docker_version Docker version to install on the nodes string "19.03.13" no
image Image string "ubuntu-20.04" no
nodes Map of node objects including their name, role and server_type
map(object({
name = string,
role = list(string),
server_type = string,
node_name = string,
hostname_override = string
}))
{
"master1": {
"hostname_override": "worker2",
"name": "master1",
"node_name": "master1",
"role": [
"controlplane",
"etcd"
],
"server_type": "cx21"
},
"worker1": {
"hostname_override": "worker1",
"name": "worker1",
"node_name": "worker1",
"role": [
"worker"
],
"server_type": "cx21"
}
}
no
ssh_private_key_path SSH private key path string "~/.ssh/id_rsa" no
ssh_public_key_path SSH public key path string "~/.ssh/id_rsa.pub" no

Outputs

Name Description
api_server_url RKE k8s cluster api server url
ca_cert RKE k8s cluster CA certificate
client_cert RKE k8s cluster client certificate
client_key RKE k8s cluster client key
kube_config_yaml RKE k8s cluster kube config yaml
this List of node objects

Where to go further?

After deploying your Kubernetes Cluster you can login to the Kubernetes Dashboard using the following steps:

  1. Get Kubernetes Dashboard token
kubectl --kubeconfig kube_config_cluster.yml -n kube-system describe secret $(kubectl --kubeconfig kube_config_cluster.yml -n kube-system get secret | grep admin-user | awk '{print $1}') | grep ^token: | awk '{ print $2 }'
  1. Set up kubectl proxy
kubectl --kubeconfig kube_config_cluster.yml proxy"
  1. Login with the token copied in the step before at http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Contributing

We encourage you to contribute to this project in whatever way you like!

Report bugs/feature requests in the issues section.

When contributing to this repository, please first discuss the change you wish to make via issue with the owners of this repository before making a change.

Versioning

Semantic Versioning 2.x

In a nutshell:

Given a version number MAJOR.MINOR.PATCH, increment the:

  1. MAJOR version when you make incompatible API changes,
  2. MINOR version when you add functionality in a backwards-compatible manner, and
  3. PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Maintainer

https://github.com/brotandgames

About

Terraform Module to deploy a Kubernetes Cluster using RKE Provider in Hetzner Cloud

Resources

Stars

Watchers

Forks

Packages

No packages published