Update readme

This commit is contained in:
Serge Logvinov
2021-12-25 00:41:26 +02:00
parent d1249d91df
commit 60aa6ef237
6 changed files with 54 additions and 31 deletions

View File

@@ -9,8 +9,7 @@ prepare:
create-lb: ## Create load balancer
terraform init
terraform apply -auto-approve -target=output.controlplane_endpoint
terraform output controlplane_endpoint
terraform apply -auto-approve -target=hcloud_floating_ip.api -target=hcloud_load_balancer.api
create-config: ## Genereate talos configs
talosctl gen config --output-dir _cfgs --with-docs=false --with-examples=false talos-k8s-hetzner https://${ENDPOINT}:6443
@@ -31,11 +30,11 @@ create-templates:
@yq eval -o=json '{"kubernetes": .}' _cfgs/tfstate.vars > terraform.tfvars.json
create-controlplane: ## Bootstrap first controlplane node
terraform apply -target=hcloud_server.controlplane
terraform apply -auto-approve -target=hcloud_server.controlplane
create-infrastructure: ## Bootstrap all nodes
cd modules/worker && terraform init
terraform apply
create-kubeconfig:
create-kubeconfig: ## Prepare kubeconfig
talosctl --talosconfig _cfgs/talosconfig --nodes 172.16.0.11 kubeconfig

View File

@@ -23,33 +23,18 @@ This terraform example install Talos on [HCloud](https://www.hetzner.com/cloud)
## Prepare the base image
First, prepare variables to your environment
Use packer (system_os/hetzner) to upload image.
```shell
export TF_VAR_hcloud_token=KEY
```
## Create control plane lb
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 create-templates
```
open config file **terraform.tfvars** and add params
open config file **terraform.tfvars** and add params.
```hcl
# counts and type of kubernetes master nodes
controlplane = {
count = 1,
type = "cpx11"
count = 1,
type = "cpx11"
type_lb = ""
}
# regions to use
@@ -58,15 +43,15 @@ regions = ["nbg1", "fsn1", "hel1"]
# counts and type of worker nodes by redion
instances = {
"nbg1" = {
web_count = 1,
web_count = 0,
web_instance_type = "cx11",
worker_count = 1,
worker_count = 0,
worker_instance_type = "cx11",
},
"fsn1" = {
web_count = 1,
web_count = 0,
web_instance_type = "cx11",
worker_count = 1,
worker_count = 0,
worker_instance_type = "cx11",
}
"hel1" = {
@@ -78,13 +63,36 @@ instances = {
}
```
```shell
make create-lb
```
## Install control plane
Generate the default talos config
```shell
make create-config create-templates
```
And deploy the kubernetes master nodes
```shell
make create-controlplane
```
Then deploy all other instances
Bootstrap the first node
```shell
talosctl --talosconfig _cfgs/talosconfig config endpoint $controlplane_firstnode
talosctl --talosconfig _cfgs/talosconfig --nodes $controlplane_firstnode bootstrap
```
```shell
make create-kubeconfig
```
## Deploy all other instances
```shell
make create-infrastructure

View File

@@ -26,6 +26,7 @@ resource "hcloud_server" "controlplane" {
lbv6 = local.lbv6
hcloud_network = hcloud_network.main.id
hcloud_token = var.hcloud_token
labels = "topology.kubernetes.io/region=${element(var.regions, count.index)}"
})
)

View File

@@ -5,6 +5,12 @@ output "controlplane_endpoint" {
depends_on = [hcloud_load_balancer.api]
}
output "controlplane_firstnode" {
description = "Kubernetes controlplane first node"
value = hcloud_server.controlplane[0].ipv4_address
}
output "controlplane_nodes" {
description = "Kubernetes controlplane nodes"
value = [

View File

@@ -14,6 +14,12 @@ machine:
extraArgs:
node-ip: "${ipv4_local}"
rotate-server-certificates: true
node-labels: "${labels}"
clusterDNS:
- 169.254.2.53
- ${cidrhost(split(",",serviceSubnets)[0], 10)}
nodeIP:
validSubnets: ${format("%#v",split(",",nodeSubnets))}
network:
hostname: "${name}"
interfaces:
@@ -49,6 +55,9 @@ machine:
keys:
- nodeID: {}
slot: 0
options:
- no_read_workqueue
- no_write_workqueue
cluster:
controlPlane:
endpoint: https://${ipv4_vip}:6443

View File

@@ -45,7 +45,7 @@ variable "controlplane" {
default = {
count = 0,
type = "cpx11"
type_lb = ""
type_lb = "" # lb11, if "" use floating-ip
}
}