From 816eb06bdd9a1730d3c56b01c6488e636e06ed93 Mon Sep 17 00:00:00 2001 From: jwdobken Date: Sat, 15 Oct 2022 12:16:59 +0200 Subject: [PATCH] cleanr up --- demo/README.md | 24 ---------- demo/demo.tfvars | 7 --- demo/main.tf | 87 ------------------------------------ main.tf | 2 +- modules/cluster/main.tf | 2 +- modules/cluster/variables.tf | 2 +- modules/cluster/version.tf | 2 +- variables.tf | 2 +- 8 files changed, 5 insertions(+), 123 deletions(-) delete mode 100644 demo/README.md delete mode 100644 demo/demo.tfvars delete mode 100644 demo/main.tf diff --git a/demo/README.md b/demo/README.md deleted file mode 100644 index 710a195..0000000 --- a/demo/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Demo kubernetes cluster - -From the [Hetzner Cloud portal](https://console.hetzner.cloud/projects), create a new project and select it. Go to "Security" > "API Tokens" > "Generate API Token" and create a token with _Read & Write_ permissions and copy the token. - -There are a couple of options to pass the token, but you can create an environmental variable: - -``` -export TF_VAR_hcloud_token="tBho3vJzmloeywgIRy62NoRygPKdu2c0klXQ9JCvjyEbALwwna2tpSzrsf2yb8o9" -``` - -Now, change the settings in the file `demo.tfvars`. Make sure the path to the SSH public key is correct and the private key is added to your keychain. - -Now run: - -```cmd -terraform init -terraform apply -var-file="demo.tfvars" -``` - -You can destroy the created resources with: - -```cmd -terraform destroy -var-file="demo.tfvars" -``` diff --git a/demo/demo.tfvars b/demo/demo.tfvars deleted file mode 100644 index 7d1c20b..0000000 --- a/demo/demo.tfvars +++ /dev/null @@ -1,7 +0,0 @@ -cluster_name = "k8s-terraform-demo" -control_plane_type = "cx11" -worker_type = "cx21" -worker_count = 3 -load_balancer_name = "demo_lb" -load_balancer_type = "lb11" -load_balancer_location = "nbg1" diff --git a/demo/main.tf b/demo/main.tf deleted file mode 100644 index 61a1323..0000000 --- a/demo/main.tf +++ /dev/null @@ -1,87 +0,0 @@ -# providers -terraform { - required_version = ">= 1.3.2" - required_providers { - hcloud = { - source = "hetznercloud/hcloud" - version = ">= 1.35.2" - } - } -} - -variable "hcloud_token" { - type = string -} - -variable "cluster_name" { - type = string -} - -variable "control_plane_type" { - type = string -} - -variable "worker_type" { - type = string -} - -variable "worker_count" { - type = number -} - -variable "load_balancer_name" { - type = string -} - -variable "load_balancer_type" { - type = string -} - -variable "load_balancer_location" { - type = string -} - -provider "hcloud" { - token = var.hcloud_token -} - -# Create a new SSH key -resource "hcloud_ssh_key" "demo_keys" { - name = "demo-key" - public_key = file("~/.ssh/hcloud.pub") -} - -# Create a kubernetes cluster -module "hcloud_kubernetes_cluster" { - source = "JWDobken/kubernetes/hcloud" - version = "v0.3.0" - cluster_name = var.cluster_name - hcloud_token = var.hcloud_token - hcloud_ssh_keys = [hcloud_ssh_key.demo_keys.id] - control_plane_type = var.control_plane_type - worker_type = var.worker_type - worker_count = var.worker_count -} - -resource "hcloud_load_balancer" "load_balancer" { - name = var.load_balancer_name - load_balancer_type = var.load_balancer_type - location = var.load_balancer_location -} - -resource "hcloud_load_balancer_network" "cluster_network" { - load_balancer_id = hcloud_load_balancer.load_balancer.id - network_id = module.hcloud_kubernetes_cluster.network_id -} - -output "load_balancer" { - value = hcloud_load_balancer.load_balancer -} - -output "kubeconfig" { - value = module.hcloud_kubernetes_cluster.kubeconfig -} - -output "hcloud_kubernetes_cluster" { - value = module.hcloud_kubernetes_cluster -} diff --git a/main.tf b/main.tf index 1717c3c..1568f8a 100644 --- a/main.tf +++ b/main.tf @@ -13,7 +13,7 @@ module "cluster" { control_plane_name_format = var.control_plane_name_format worker_type = var.worker_type worker_count = var.worker_count - workername_format = var.workername_format + worker_name_format = var.worker_name_format } module "firewall" { diff --git a/modules/cluster/main.tf b/modules/cluster/main.tf index 52fa26e..9c8fa5b 100644 --- a/modules/cluster/main.tf +++ b/modules/cluster/main.tf @@ -40,7 +40,7 @@ resource "hcloud_server" "control_plane_node" { resource "hcloud_server" "worker_node" { count = var.worker_count - name = format(var.workername_format, count.index + 1) + name = format(var.worker_name_format, count.index + 1) location = var.location image = var.image server_type = var.worker_type diff --git a/modules/cluster/variables.tf b/modules/cluster/variables.tf index 1023592..54b3a3d 100644 --- a/modules/cluster/variables.tf +++ b/modules/cluster/variables.tf @@ -56,7 +56,7 @@ variable "worker_count" { type = number } -variable "workername_format" { +variable "worker_name_format" { type = string } diff --git a/modules/cluster/version.tf b/modules/cluster/version.tf index 3ae3be3..f5369a1 100644 --- a/modules/cluster/version.tf +++ b/modules/cluster/version.tf @@ -1,6 +1,6 @@ # cluster/version.tf terraform { - required_version = ">= 1.2.8" + required_version = ">= 1.1.9" required_providers { hcloud = { source = "hetznercloud/hcloud" diff --git a/variables.tf b/variables.tf index 1f82f1b..a367444 100644 --- a/variables.tf +++ b/variables.tf @@ -76,7 +76,7 @@ variable "worker_count" { type = number } -variable "workername_format" { +variable "worker_name_format" { description = "(Optional) - Format for the worker node names, defaults to 'worker-0'." type = string default = "worker-%d"