From bde522b516f84a902017256a04fbaa9624b2b327 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sat, 9 Oct 2021 23:18:05 +0200
Subject: [PATCH] terraform: Add a way to deploy worker nodes

---
 terraform/main.tf      | 19 +++++++++++++++++++
 terraform/variables.tf |  8 ++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/terraform/main.tf b/terraform/main.tf
index 1a873bb30..e4d98f1a0 100644
--- a/terraform/main.tf
+++ b/terraform/main.tf
@@ -24,3 +24,22 @@ module "nodes" {
   # subnet         = hcloud_network_subnet.subnet.id
   user_data      = file("templates/cloud-init.tpl")
 }
+
+module "workers" {
+  source         = "./modules/hcloud_instance"
+  instance_count = var.replicas_worker
+  location       = var.location
+  name           = "worker"
+  dns_domain     = var.dns_domain
+  dns_zone_id    = var.dns_zone_id
+  image          = var.image
+  labels          = {
+    "k8s.io/node" = "true",
+    "k8s.io/worker" = "true"
+  }
+  placement_group_id = hcloud_placement_group.k8s.id
+  ssh_keys       = data.hcloud_ssh_keys.all_keys.ssh_keys.*.name
+  server_type    = "cx21"
+  # subnet         = hcloud_network_subnet.subnet.id
+  user_data      = file("templates/cloud-init.tpl")
+}
diff --git a/terraform/variables.tf b/terraform/variables.tf
index b8e7f003b..c1f6b4ff2 100644
--- a/terraform/variables.tf
+++ b/terraform/variables.tf
@@ -4,10 +4,10 @@ variable "replicas_nodes" {
   description = "Count of nodes"
 }
 
-variable "bootstrap" {
-  type        = bool
-  default     = false
-  description = "Whether to deploy a bootstrap instance"
+variable "replicas_worker" {
+  type        = number
+  default     = 0
+  description = "Count of nodes"
 }
 
 variable "dns_domain" {
-- 
GitLab