Update docs

This commit is contained in:
Serge Logvinov
2021-06-03 21:50:09 +03:00
parent 9cb66ccd3b
commit de4a4401e7
2 changed files with 95 additions and 10 deletions

View File

@@ -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
```

18
hetzner/Makefile Normal file
View File

@@ -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