From 0b19d364162982344cc32807646a839c8c05404d Mon Sep 17 00:00:00 2001 From: Karim Naufal Date: Wed, 23 Feb 2022 21:35:42 +0100 Subject: [PATCH] ability to chose k3s install channel --- README.md | 2 +- init.tf | 2 +- locals.tf | 4 ++-- terraform.tfvars.example | 7 +++---- variables.tf | 9 +++++++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ae53fd4..c64005a 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ There is also a branch where openSUSE MicroOS came preinstalled with the k3s RPM ## Contributing -✅ There is something you can do right away to help this project succeed! **Just take a few minutes to send a support request to Hetzner, asking them to please add openSUSE MicroOS as a default image**, not just an ISO. If that succeeds, we will be able to deploy in less than 2 minutes instead of 5, without passing by the rescue mode. The more requests they receive the likelier they are to add it. The official link to openSUSE MicroOS is . +🌱 There is something you can do right away to help this project succeed! **Just take a few minutes to send a support request to Hetzner, asking them to please add openSUSE MicroOS as a default image**, not just an ISO. If that succeeds, we will be able to deploy in less than 2 minutes instead of 5, without passing by the rescue mode. The more requests they receive the likelier they are to add it. The official link to openSUSE MicroOS is . About code contributions, they are **greatly appreciated**. diff --git a/init.tf b/init.tf index cb3eec9..f2029be 100644 --- a/init.tf +++ b/init.tf @@ -110,7 +110,7 @@ resource "null_resource" "kustomization" { content = templatefile( "${path.module}/templates/plans.yaml.tpl", { - channel = var.k3s_upgrade_channel + channel = var.initial_k3s_channel }) destination = "/tmp/post_install/plans.yaml" } diff --git a/locals.tf b/locals.tf index 72c2e61..7cc21cb 100644 --- a/locals.tf +++ b/locals.tf @@ -27,7 +27,7 @@ locals { "[ -e /etc/rancher/k3s/k3s.yaml ] && exit 0", ] - install_k3s_server = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_SKIP_START=true INSTALL_K3S_EXEC=server sh -"]) + install_k3s_server = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_SKIP_START=true INSTALL_K3S_CHANNEL=${var.initial_k3s_channel} INSTALL_K3S_EXEC=server sh -"]) - install_k3s_agent = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_SKIP_START=true INSTALL_K3S_EXEC=agent sh -"]) + install_k3s_agent = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_SKIP_START=true INSTALL_K3S_CHANNEL=${var.initial_k3s_channel} INSTALL_K3S_EXEC=agent sh -"]) } diff --git a/terraform.tfvars.example b/terraform.tfvars.example index 323955c..89c9f26 100644 --- a/terraform.tfvars.example +++ b/terraform.tfvars.example @@ -30,9 +30,8 @@ agents_num = 2 # If you want to allow non-control-plane workloads to run on the control-plane nodes set "true" below. The default is "false". # allow_scheduling_on_control_plane = true -# If you want to disable automatic upgrade of k3s (stable channel), you can set this to false, default is "true". +# If you want to disable automatic upgrade of k3s, you can set this to false, default is "true". # automatically_upgrade_k3s = false -# If you would like to specify the k3s upgrade channel from the get go, you can do so, the default is "stable". -# For a list of available channels, see https://rancher.com/docs/k3s/latest/en/upgrades/basic/ and https://update.k3s.io/v1-release/channels -# k3s_upgrade_channel = "latest" +# Allows you to specify either stable, latest, or testing (defaults to stable), see https://rancher.com/docs/k3s/latest/en/upgrades/basic/ +# initial_k3s_channel = "latest" diff --git a/variables.tf b/variables.tf index 9346e5d..7f0e2f3 100644 --- a/variables.tf +++ b/variables.tf @@ -91,10 +91,15 @@ variable "allow_scheduling_on_control_plane" { description = "Whether to allow non-control-plane workloads to run on the control-plane nodes" } -variable "k3s_upgrade_channel" { +variable "initial_k3s_channel" { type = string default = "stable" - description = "Allows you to specify the k3s upgrade channel" + description = "Allows you to specify an initial k3s channel" + + validation { + condition = contains(["stable", "latest", "testing"], var.initial_k3s_channel) + error_message = "The initial k3s channel must be one of stable, latest or testing." + } } variable "automatically_upgrade_k3s" {