Skip to content

Commit

Permalink
chore: update hetzner configuration
Browse files Browse the repository at this point in the history
Update the example Packer and Terraform configuration.
- Remove "wait" from talos_cluster_kubeconfig
- Update Talos version from v1.3.0 to v1.6.0
- Update Hetzner server types
- Update Hetzner Terraform provider
- Set talos_version and kubernetes_version

Signed-off-by: Andrew Longwill <[email protected]>
  • Loading branch information
alongwill committed Sep 16, 2024
1 parent b14dd77 commit 6412d99
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 41 deletions.
1 change: 0 additions & 1 deletion examples/terraform/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ resource "talos_cluster_kubeconfig" "this" {
depends_on = [talos_machine_bootstrap.this]
client_configuration = talos_machine_secrets.this.client_configuration
node = [for k, v in var.node_data.controlplanes : k][0]
wait = true
}
6 changes: 3 additions & 3 deletions examples/terraform/hcloud/packer/hcloud_talosimage.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packer {

variable "talos_version" {
type = string
default = "v1.3.0"
default = "v1.6.0"
}

locals {
Expand All @@ -20,9 +20,9 @@ locals {

source "hcloud" "talos" {
rescue = "linux64"
image = "debian-11"
image = "debian-12"
location = "fsn1"
server_type = "cx11"
server_type = "cx22"
ssh_username = "root"

snapshot_name = "talos system disk ${var.talos_version}"
Expand Down
40 changes: 20 additions & 20 deletions examples/terraform/hcloud/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion examples/terraform/hcloud/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | A name to provide for the Talos cluster | `string` | `"talos-hloud-cluster"` | no |
| <a name="input_controlplane_ip"></a> [controlplane\_ip](#input\_controlplane\_ip) | n/a | `string` | `"10.0.0.3"` | no |
| <a name="input_controlplane_type"></a> [controlplane\_type](#input\_controlplane\_type) | Control plane | `string` | `"cpx31"` | no |
| <a name="input_controlplane_type"></a> [controlplane\_type](#input\_controlplane\_type) | Control plane | `string` | `"cx32"` | no |
| <a name="input_image_id"></a> [image\_id](#input\_image\_id) | Talos specific variables | `string` | n/a | yes |
| <a name="input_kubernetes_version"></a> [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the cluster, if not set the k8s version shipped with the talos sdk version will be used | `string` | `null` | no |
| <a name="input_load_balancer_type"></a> [load\_balancer\_type](#input\_load\_balancer\_type) | n/a | `string` | `"lb11"` | no |
| <a name="input_location"></a> [location](#input\_location) | Workers | `string` | `"fsn1"` | no |
| <a name="input_network_zone"></a> [network\_zone](#input\_network\_zone) | Load balancer | `string` | `"eu-central"` | no |
| <a name="input_private_network_ip_range"></a> [private\_network\_ip\_range](#input\_private\_network\_ip\_range) | n/a | `string` | `"10.0.0.0/16"` | no |
| <a name="input_private_network_name"></a> [private\_network\_name](#input\_private\_network\_name) | Networking | `string` | `"talos-network"` | no |
| <a name="input_private_network_subnet_range"></a> [private\_network\_subnet\_range](#input\_private\_network\_subnet\_range) | n/a | `string` | `"10.0.0.0/24"` | no |
| <a name="input_talos_version_contract"></a> [talos\_version\_contract](#input\_talos\_version\_contract) | Talos API version to use for the cluster, if not set the the version shipped with the talos sdk version will be used | `string` | `"v1.6"` | no |
| <a name="input_worker_extra_volume_size"></a> [worker\_extra\_volume\_size](#input\_worker\_extra\_volume\_size) | Size of SSD volume to attach to workers | `number` | `10` | no |
| <a name="input_workers"></a> [workers](#input\_workers) | Worker definition | `any` | n/a | yes |

Expand Down
25 changes: 15 additions & 10 deletions examples/terraform/hcloud/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ resource "hcloud_load_balancer_service" "controlplane_load_balancer_service_maya

# Talos
# create the machine secrets
resource "talos_machine_secrets" "this" {}
resource "talos_machine_secrets" "this" {
talos_version = var.talos_version_contract
}

# create the controlplane config, using the loadbalancer as cluster endpoint
data "talos_machine_configuration" "controlplane" {
cluster_name = var.cluster_name
cluster_endpoint = "https://${hcloud_load_balancer.controlplane_load_balancer.ipv4}:6443"
machine_type = "controlplane"
machine_secrets = talos_machine_secrets.this.machine_secrets
cluster_name = var.cluster_name
cluster_endpoint = "https://${hcloud_load_balancer.controlplane_load_balancer.ipv4}:6443"
machine_type = "controlplane"
machine_secrets = talos_machine_secrets.this.machine_secrets
talos_version = var.talos_version_contract
kubernetes_version = var.kubernetes_version
config_patches = [
templatefile("${path.module}/templates/controlplanepatch.yaml.tmpl", {
loadbalancerip = hcloud_load_balancer.controlplane_load_balancer.ipv4, subnet = var.private_network_subnet_range
Expand Down Expand Up @@ -117,10 +121,12 @@ resource "talos_machine_bootstrap" "bootstrap" {

# create the worker config and apply the worker patch
data "talos_machine_configuration" "worker" {
cluster_name = var.cluster_name
cluster_endpoint = "https://${hcloud_load_balancer.controlplane_load_balancer.ipv4}:6443"
machine_type = "worker"
machine_secrets = talos_machine_secrets.this.machine_secrets
cluster_name = var.cluster_name
cluster_endpoint = "https://${hcloud_load_balancer.controlplane_load_balancer.ipv4}:6443"
machine_type = "worker"
machine_secrets = talos_machine_secrets.this.machine_secrets
talos_version = var.talos_version_contract
kubernetes_version = var.kubernetes_version
config_patches = [
templatefile("${path.module}/templates/workerpatch.yaml.tmpl", {
subnet = var.private_network_subnet_range
Expand Down Expand Up @@ -164,5 +170,4 @@ resource "hcloud_volume" "volumes" {
resource "talos_cluster_kubeconfig" "this" {
client_configuration = talos_machine_secrets.this.client_configuration
node = hcloud_server.controlplane_server.ipv4_address
wait = true
}
6 changes: 3 additions & 3 deletions examples/terraform/hcloud/terraform/three_workers.tfvars
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
workers = {
1 = {
server_type = "cpx31",
server_type = "cx32",
name = "talos-worker-1",
location = "fsn1",
labels = { "type" : "talos-worker" },
taints = [],
},
2 = {
server_type = "cpx31",
server_type = "cx32",
name = "talos-worker-2",
location = "fsn1",
labels = { "type" : "talos-worker" },
taints = [],
},
3 = {
server_type = "cpx31",
server_type = "cx32",
name = "talos-worker-3",
location = "fsn1",
labels = { "type" : "talos-worker" },
Expand Down
16 changes: 14 additions & 2 deletions examples/terraform/hcloud/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ variable "cluster_name" {
default = "talos-hloud-cluster"
}

variable "talos_version_contract" {
description = "Talos API version to use for the cluster, if not set the the version shipped with the talos sdk version will be used"
type = string
default = "v1.6"
}

variable "kubernetes_version" {
description = "Kubernetes version to use for the cluster, if not set the k8s version shipped with the talos sdk version will be used"
type = string
default = null
}

# Control plane
variable "controlplane_type" {
default = "cpx31"
default = "cx32"
}

variable "controlplane_ip" {
Expand Down Expand Up @@ -51,7 +63,7 @@ variable "workers" {
}

variable "worker_extra_volume_size" {
description = " Size of SSD volume to attach to workers"
description = "Size of SSD volume to attach to workers"
type = number
default = 10
}
2 changes: 1 addition & 1 deletion examples/terraform/hcloud/terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.35.2"
version = "1.48.1"
}
talos = {
source = "siderolabs/talos"
Expand Down

0 comments on commit 6412d99

Please sign in to comment.