Skip to content

A simple project to spin your k8s cluster with terraform, kubeadm on hcloud

License

Notifications You must be signed in to change notification settings

aslubsky/terraform-k8s-hcloud

 
 

Repository files navigation

Terraform Kubernetes on Hetzner Cloud

This repository will help to setup an opionated Kubernetes Cluster with kubeadm on Hetzner Cloud.

Usage

$ git clone https://github.com/solidnerd/terraform-k8s-hcloud.git
$ terraform init
$ terraform apply

Example

$ terraform init
$ terraform apply
$ KUBECONFIG=secrets/admin.conf kubectl get nodes
$ KUBECONFIG=secrets/admin.conf kubectl get pods --namespace=kube-system -o wide
$ KUBECONFIG=secrets/admin.conf helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
$ KUBECONFIG=secrets/admin.conf helm repo update
$ KUBECONFIG=secrets/admin.conf helm install -n kube-system tmp-ingress ingress-nginx/ingress-nginx -f demo-ingress.yml
$ KUBECONFIG=secrets/admin.conf kubectl apply -f demo-app.yml

Variables

Name Default Description Required
hcloud_token `` API Token that will be generated through your hetzner cloud project https://console.hetzner.cloud/projects Yes
master_count 1 Amount of masters that will be created No
master_image ubuntu-20.04 Predefined Image that will be used to spin up the machines (Currently supported: ubuntu-20.04, ubuntu-18.04) No
master_type cx11 Machine type for more types have a look at https://www.hetzner.de/cloud No
node_count 1 Amount of nodes that will be created No
node_image ubuntu-20.04 Predefined Image that will be used to spin up the machines (Currently supported: ubuntu-20.04, ubuntu-18.04) No
node_type cx11 Machine type for more types have a look at https://www.hetzner.de/cloud No
ssh_private_key ~/.ssh/id_ed25519 Private Key to access the machines No
ssh_public_key ~/.ssh/id_ed25519.pub Public Key to authorized the access for the machines No
docker_version 19.03 Docker CE version that will be installed No
kubernetes_version 1.18.6 Kubernetes version that will be installed No
feature_gates `` Add your own Feature Gates for Kubeadm No
calico_enabled false Installs Calico Network Provider after the master comes up No

All variables cloud be passed through environment variables or a tfvars file.

An example for a tfvars file would be the following terraform.tfvars

# terraform.tfvars
hcloud_token = "<yourgeneratedtoken>"
master_type = "cx21"
master_count = 1
node_type = "cx31"
node_count = 2
kubernetes_version = "1.18.6"
docker_version = "19.03"

Or passing directly via Arguments

$ terraform apply \
  -var hcloud_token="<yourgeneratedtoken>" \
  -var docker_version=19.03 \
  -var kubernetes_version=1.18.6 \
  -var master_type=cx21 \
  -var master_count=1 \
  -var node_type=cx31 \
  -var node_count=2

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Tested with

About

A simple project to spin your k8s cluster with terraform, kubeadm on hcloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 71.6%
  • Shell 28.4%