Skip to content

Commit 169c254

Browse files
authored
Merge pull request #1338 from lennart/feature/sys-upgrade-disable-eviction-flag
adds system_upgrade_enable_eviction flag
2 parents 136c1eb + 7b82c72 commit 169c254

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

init.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ resource "null_resource" "kustomization" {
218218
content = templatefile(
219219
"${path.module}/templates/plans.yaml.tpl",
220220
{
221-
channel = var.initial_k3s_channel
221+
channel = var.initial_k3s_channel
222+
disable_eviction = !var.system_upgrade_enable_eviction
222223
})
223224
destination = "/var/post_install/plans.yaml"
224225
}

kube.tf.example

+6
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ module "kube-hetzner" {
556556
# The default is "true" (in HA setup i.e. at least 3 control plane nodes & 2 agents, just keep it enabled since it works flawlessly).
557557
# automatically_upgrade_k3s = false
558558

559+
# During k3s via system-upgrade-manager pods are evicted by default.
560+
# On small clusters this can lead to hanging upgrades and indefinitely unschedulable nodes,
561+
# in that case, set this to false to immediately delete pods before upgrading.
562+
# NOTE: Turning this flag off might lead to downtimes of services (which may be acceptable for your use case)
563+
# system_upgrade_enable_eviction = false
564+
559565
# The default is "true" (in HA setup it works wonderfully well, with automatic roll-back to the previous snapshot in case of an issue).
560566
# IMPORTANT! For non-HA clusters i.e. when the number of control-plane nodes is < 3, you have to turn it off.
561567
# automatically_upgrade_os = false

templates/plans.yaml.tpl

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ spec:
2626
args: ["prepare", "k3s-server"]
2727
drain:
2828
force: true
29+
disableEviction: ${disable_eviction}
2930
skipWaitForDeleteTimeout: 60
3031
upgrade:
3132
image: rancher/k3s-upgrade

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ variable "initial_k3s_channel" {
508508
}
509509
}
510510

511+
variable "system_upgrade_enable_eviction" {
512+
type = bool
513+
default = true
514+
description = "Whether to directly delete pods during system upgrade (k3s) or evict them. Defaults to true. Disable this on small clusters to avoid system upgrades hanging since pods resisting eviction keep node unschedulable forever. NOTE: turning this off, introduces potential downtime of services of the upgraded nodes."
515+
}
516+
511517
variable "automatically_upgrade_k3s" {
512518
type = bool
513519
default = true

0 commit comments

Comments
 (0)