From de4a4401e76d9b82f45b292d4aff1c43a6f215e5 Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Thu, 3 Jun 2021 21:50:09 +0300 Subject: [PATCH] Update docs --- README.md | 87 ++++++++++++++++++++++++++++++++++++++++++------ hetzner/Makefile | 18 ++++++++++ 2 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 hetzner/Makefile diff --git a/README.md b/README.md index dce420d..5d6a4eb 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,89 @@ -# terraform-talos +# Terraform examples -Terraform examples to run Talos +Local utilities * terraform * talosctl * kubectl * yq -## Talos on Hetzner Cloud +# Talos on Hetzner Cloud -```bash -cd hetzner +This terraform example install Talos on [HCloud](https://www.hetzner.com/cloud) with IPv4/IPv6 support. -# create the cluster configuration -talosctl gen config --output-dir _cfgs --with-docs=false --with-examples=false talos-k8s-hezner https://127.0.0.1:6443 -yq ea -P '. as $item ireduce ({}; . * $item )' _cfgs/controlplane.yaml templates/controlplane.yaml.tpl > templates/controlplane.yaml +## Kubernetes addons + +* [cilium](https://github.com/cilium/cilium) 1.10.0 +* [kubelet-serving-cert-approver](https://github.com/alex1989hu/kubelet-serving-cert-approver) +* [metrics-server](https://github.com/kubernetes-sigs/metrics-server) 0.5.0 +* [rancher.io/local-path](https://github.com/rancher/local-path-provisioner) 0.0.19 +* [hcloud-cloud-controller-manage](https://github.com/hetznercloud/hcloud-cloud-controller-manager) v1.10.0 + +## Prepare the base image + +First, prepare variables to your environment + +```shell +export TF_VAR_hcloud_token=KEY ``` -```bash -kubectl -n kube-system create secret generic hcloud --from-literal=network= --from-literal=token= +Terraform will run the VM in recovery mode, replace the base image and take a snapshote. Do not run terraform destroy after. It will delete the snapshot. + +```shell +make prepare-image +``` + +## Install control plane + +Generate the default talos config + +```shell +make create-config +``` + +open config file **terraform.tfvars** and add params + +```hcl +# counts and type of kubernetes master nodes +controlplane = { + count = 1, + type = "cpx11" +} + +# regions to use +regions = ["nbg1", "fsn1", "hel1"] + +# counts and type of worker nodes by redion +instances = { + "nbg1" = { + web_count = 1, + web_instance_type = "cx11", + worker_count = 1, + worker_instance_type = "cx11", + }, + "fsn1" = { + web_count = 1, + web_instance_type = "cx11", + worker_count = 1, + worker_instance_type = "cx11", + } + "hel1" = { + web_count = 1, + web_instance_type = "cx11", + worker_count = 1, + worker_instance_type = "cx11", + } +} +``` + +And deploy the kubernetes master nodes + +```shell +make create-controlplane +``` + +Then deploy all other instances + +```shell +make create-infrastructure ``` diff --git a/hetzner/Makefile b/hetzner/Makefile new file mode 100644 index 0000000..aaffb46 --- /dev/null +++ b/hetzner/Makefile @@ -0,0 +1,18 @@ + +prepare-image: + ssh-keygen -f /.ssh/terraform -N '' -t rsa + + cd prepare + terraform init + terraform apply -auto-approve + +create-config: + talosctl gen config --output-dir _cfgs --with-docs=false --with-examples=false talos-k8s-hezner https://127.0.0.1:6443 + yq ea -P '. as $item ireduce ({}; . * $item )' _cfgs/controlplane.yaml templates/controlplane.yaml.tpl > templates/controlplane.yaml + +create-controlplane: + terraform init + terraform apply -target=null_resource.controlplane_apply + +create-infrastructure: + terraform apply