Skip to content

Commit 3aa836a

Browse files
authored
[release/v1.8] Add an option to disable Flatcar auto-upgrades (#3393)
* Add an option to disable Flatcar auto-upgrades Signed-off-by: Marko Mudrinić <[email protected]> * Add an option to disable Flatcar auto-upgrades on Equinix Signed-off-by: Marko Mudrinić <[email protected]> --------- Signed-off-by: Marko Mudrinić <[email protected]>
1 parent fdfa048 commit 3aa836a

25 files changed

+99
-18
lines changed

examples/terraform/aws/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ No modules.
7171
| <a name="input_control_plane_type"></a> [control\_plane\_type](#input\_control\_plane\_type) | AWS instance type | `string` | `"t3.medium"` | no |
7272
| <a name="input_control_plane_vm_count"></a> [control\_plane\_vm\_count](#input\_control\_plane\_vm\_count) | number of control plane instances | `number` | `3` | no |
7373
| <a name="input_control_plane_volume_size"></a> [control\_plane\_volume\_size](#input\_control\_plane\_volume\_size) | Size of the EBS volume, in Gb | `number` | `100` | no |
74+
| <a name="input_disable_auto_update"></a> [disable\_auto\_update](#input\_disable\_auto\_update) | Disable automatic flatcar updates (and reboot) | `bool` | `false` | no |
7475
| <a name="input_disable_kubeapi_loadbalancer"></a> [disable\_kubeapi\_loadbalancer](#input\_disable\_kubeapi\_loadbalancer) | E2E tests specific variable to disable usage of any loadbalancer in front of kubeapi-server | `bool` | `false` | no |
7576
| <a name="input_initial_machinedeployment_operating_system_profile"></a> [initial\_machinedeployment\_operating\_system\_profile](#input\_initial\_machinedeployment\_operating\_system\_profile) | Name of operating system profile for MachineDeployments, only applicable if operating-system-manager addon is enabled.<br>If not specified default is used based on the OS specified for workers. | `string` | `""` | no |
7677
| <a name="input_initial_machinedeployment_replicas"></a> [initial\_machinedeployment\_replicas](#input\_initial\_machinedeployment\_replicas) | number of replicas per MachineDeployment | `number` | `1` | no |

examples/terraform/aws/main.tf

+6
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ resource "aws_instance" "control_plane" {
307307
http_put_response_hop_limit = var.control_plane_http_put_max_hops
308308
}
309309

310+
user_data = var.disable_auto_update ? file("./userdata_flatcar_upgrades.json") : null
311+
310312
tags = tomap({
311313
"Name" = "${var.cluster_name}-cp-${count.index + 1}",
312314
(local.kube_cluster_tag) = "shared",
@@ -334,6 +336,8 @@ resource "aws_instance" "static_workers1" {
334336
http_put_response_hop_limit = var.static_workers_http_put_max_hops
335337
}
336338

339+
user_data = var.disable_auto_update ? file("./userdata_flatcar_upgrades.json") : null
340+
337341
tags = tomap({
338342
"Name" = "${var.cluster_name}-workers1-${count.index + 1}",
339343
(local.kube_cluster_tag) = "shared",
@@ -356,6 +360,8 @@ resource "aws_instance" "bastion" {
356360
volume_size = 100
357361
}
358362

363+
user_data = var.disable_auto_update ? file("./userdata_flatcar_upgrades.json") : null
364+
359365
tags = tomap({
360366
"Cluster" = var.cluster_name,
361367
"Name" = "${var.cluster_name}-bastion",

examples/terraform/aws/output.tf

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ output "kubeone_workers" {
9696
operatingSystem = local.worker_os
9797
operatingSystemSpec = {
9898
distUpgradeOnBoot = false
99+
disableAutoUpdate = var.disable_auto_update
100+
disableLocksmithD = var.disable_auto_update
99101
provisioningUtility = var.provisioning_utility
100102
}
101103
labels = {
@@ -156,6 +158,8 @@ output "kubeone_workers" {
156158
operatingSystem = local.worker_os
157159
operatingSystemSpec = {
158160
distUpgradeOnBoot = false
161+
disableAutoUpdate = var.disable_auto_update
162+
disableLocksmithD = var.disable_auto_update
159163
provisioningUtility = var.provisioning_utility
160164
}
161165
labels = {
@@ -216,6 +220,8 @@ output "kubeone_workers" {
216220
operatingSystem = local.worker_os
217221
operatingSystemSpec = {
218222
distUpgradeOnBoot = false
223+
disableAutoUpdate = var.disable_auto_update
224+
disableLocksmithD = var.disable_auto_update
219225
provisioningUtility = var.provisioning_utility
220226
}
221227
labels = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ignition":{"version":"3.3.0"},"storage":{"files":[{"overwrite":true,"path":"/etc/flatcar/update.conf","contents":{"compression":"","source":"data:,SERVER%3Ddisabled%0A"},"mode":420}]}}

examples/terraform/aws/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,9 @@ Name of operating system profile for MachineDeployments, only applicable if oper
313313
If not specified default is used based on the OS specified for workers.
314314
EOF
315315
}
316+
317+
variable "disable_auto_update" {
318+
description = "Disable automatic flatcar updates (and reboot)"
319+
type = bool
320+
default = false
321+
}
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#cloud-config
21
%{ if os == "rhel" }
2+
#cloud-config
33
rh_subscription:
44
username: ${rhsm_username}
55
password: '${rhsm_password}'
66
auto-attach: false
77
%{ endif }
8+
%{ if disable_auto_update }
9+
{"ignition":{"version":"3.3.0"},"storage":{"files":[{"overwrite":true,"path":"/etc/flatcar/update.conf","contents":{"compression":"","source":"data:,SERVER%3Ddisabled%0A"},"mode":420}]}}
10+
%{ endif }

examples/terraform/azure/main.tf

+6-5
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,12 @@ resource "azurerm_virtual_machine" "control_plane" {
288288
os_profile {
289289
computer_name = "${var.cluster_name}-cp-${count.index}"
290290
admin_username = local.ssh_username
291-
custom_data = templatefile("./cloud-config.tftpl", {
292-
os = var.os
293-
rhsm_username = var.rhsm_username
294-
rhsm_password = var.rhsm_password
295-
})
291+
custom_data = base64encode(trimspace(templatefile("./cloud-config.tftpl", {
292+
os = var.os
293+
rhsm_username = var.rhsm_username
294+
rhsm_password = var.rhsm_password
295+
disable_auto_update = var.disable_auto_update
296+
})))
296297
}
297298

298299
os_profile_linux_config {

examples/terraform/azure/output.tf

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ output "kubeone_workers" {
6363
operatingSystemSpec = {
6464
distUpgradeOnBoot = false
6565
disableAutoUpdate = var.disable_auto_update
66+
disableLocksmithD = var.disable_auto_update
6667
rhelSubscriptionManagerUser = var.rhsm_username
6768
rhelSubscriptionManagerPassword = var.rhsm_password
6869
rhsmOfflineToken = var.rhsm_offline_token

examples/terraform/equinixmetal/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ No modules.
5151
| <a name="input_control_plane_operating_system"></a> [control\_plane\_operating\_system](#input\_control\_plane\_operating\_system) | Image to use for control plane provisioning | `string` | `""` | no |
5252
| <a name="input_control_plane_vm_count"></a> [control\_plane\_vm\_count](#input\_control\_plane\_vm\_count) | number of control plane instances | `number` | `3` | no |
5353
| <a name="input_device_type"></a> [device\_type](#input\_device\_type) | type (size) of the device | `string` | `"m3.small.x86"` | no |
54+
| <a name="input_disable_auto_update"></a> [disable\_auto\_update](#input\_disable\_auto\_update) | Disable automatic flatcar updates (and reboot) | `bool` | `false` | no |
5455
| <a name="input_image_references"></a> [image\_references](#input\_image\_references) | map with images | <pre>map(object({<br> image_name = string<br> ssh_username = string<br> worker_os = string<br> }))</pre> | <pre>{<br> "centos": {<br> "image_name": "centos_7",<br> "ssh_username": "root",<br> "worker_os": "centos"<br> },<br> "flatcar": {<br> "image_name": "flatcar_stable",<br> "ssh_username": "core",<br> "worker_os": "flatcar"<br> },<br> "rockylinux": {<br> "image_name": "rocky_8",<br> "ssh_username": "root",<br> "worker_os": "rockylinux"<br> },<br> "ubuntu": {<br> "image_name": "ubuntu_22_04",<br> "ssh_username": "root",<br> "worker_os": "ubuntu"<br> }<br>}</pre> | no |
5556
| <a name="input_initial_machinedeployment_operating_system_profile"></a> [initial\_machinedeployment\_operating\_system\_profile](#input\_initial\_machinedeployment\_operating\_system\_profile) | Name of operating system profile for MachineDeployments, only applicable if operating-system-manager addon is enabled.<br>If not specified, the default value will be added by machine-controller addon. | `string` | `""` | no |
5657
| <a name="input_initial_machinedeployment_replicas"></a> [initial\_machinedeployment\_replicas](#input\_initial\_machinedeployment\_replicas) | Number of replicas per MachineDeployment | `number` | `2` | no |

examples/terraform/equinixmetal/main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ resource "metal_device" "control_plane" {
4343
billing_cycle = "hourly"
4444
project_id = var.project_id
4545
tags = [local.kube_cluster_tag]
46+
47+
user_data = var.disable_auto_update ? file("./userdata_flatcar_upgrades.json") : null
4648
}
4749

4850
resource "metal_device" "lb" {
@@ -56,6 +58,8 @@ resource "metal_device" "lb" {
5658
project_id = var.project_id
5759
tags = [local.kube_cluster_tag]
5860

61+
user_data = var.disable_auto_update ? file("./userdata_flatcar_upgrades.json") : null
62+
5963
connection {
6064
type = "ssh"
6165
host = self.access_public_ipv4

examples/terraform/equinixmetal/output.tf

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ output "kubeone_workers" {
6060
operatingSystem = local.worker_os
6161
operatingSystemSpec = {
6262
distUpgradeOnBoot = false
63+
disableAutoUpdate = var.disable_auto_update
64+
disableLocksmithD = var.disable_auto_update
6365
}
6466
# nodeAnnotations are applied on resulting Node objects
6567
# nodeAnnotations = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ignition":{"version":"3.3.0"},"storage":{"files":[{"overwrite":true,"path":"/etc/flatcar/update.conf","contents":{"compression":"","source":"data:,SERVER%3Ddisabled%0A"},"mode":420}]}}

examples/terraform/equinixmetal/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,9 @@ Name of operating system profile for MachineDeployments, only applicable if oper
199199
If not specified, the default value will be added by machine-controller addon.
200200
EOF
201201
}
202+
203+
variable "disable_auto_update" {
204+
description = "Disable automatic flatcar updates (and reboot)"
205+
type = bool
206+
default = false
207+
}

examples/terraform/openstack/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ No modules.
7373
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the cluster | `string` | n/a | yes |
7474
| <a name="input_control_plane_flavor"></a> [control\_plane\_flavor](#input\_control\_plane\_flavor) | OpenStack instance flavor for the control plane nodes | `string` | `"m1.small"` | no |
7575
| <a name="input_control_plane_vm_count"></a> [control\_plane\_vm\_count](#input\_control\_plane\_vm\_count) | number of control plane instances | `number` | `3` | no |
76+
| <a name="input_disable_auto_update"></a> [disable\_auto\_update](#input\_disable\_auto\_update) | Disable automatic flatcar updates (and reboot) | `bool` | `false` | no |
7677
| <a name="input_external_network_name"></a> [external\_network\_name](#input\_external\_network\_name) | OpenStack external network name | `string` | n/a | yes |
7778
| <a name="input_image"></a> [image](#input\_image) | image name to use | `string` | `""` | no |
7879
| <a name="input_image_properties_query"></a> [image\_properties\_query](#input\_image\_properties\_query) | in absence of var.image, this will be used to query API for the image | `map(any)` | <pre>{<br> "os_distro": "ubuntu",<br> "os_version": "22.04"<br>}</pre> | no |

examples/terraform/openstack/bastion.tf

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ resource "openstack_compute_instance_v2" "bastion" {
3232
key_pair = openstack_compute_keypair_v2.deployer.name
3333
security_groups = [openstack_networking_secgroup_v2.securitygroup.name]
3434

35+
user_data = var.disable_auto_update ? templatefile("./userdata_flatcar_upgrades.json", {
36+
ssh_key = trimspace(file(pathexpand(var.ssh_public_key_file)))
37+
}) : null
38+
3539
network {
3640
port = openstack_networking_port_v2.bastion.id
3741
}

examples/terraform/openstack/control_plane.tf

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ resource "openstack_compute_instance_v2" "control_plane" {
3636
key_pair = openstack_compute_keypair_v2.deployer.name
3737
security_groups = [openstack_networking_secgroup_v2.securitygroup.name]
3838

39+
user_data = var.disable_auto_update ? templatefile("./userdata_flatcar_upgrades.json", {
40+
ssh_key = trimspace(file(pathexpand(var.ssh_public_key_file)))
41+
}) : null
42+
3943
network {
4044
port = element(openstack_networking_port_v2.control_plane[*].id, count.index)
4145
}

examples/terraform/openstack/output.tf

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ output "kubeone_workers" {
7272
operatingSystem = var.worker_os
7373
operatingSystemSpec = {
7474
distUpgradeOnBoot = false
75+
disableAutoUpdate = var.disable_auto_update
76+
disableLocksmithD = var.disable_auto_update
7577
}
7678
# nodeAnnotations are applied on resulting Node objects
7779
# nodeAnnotations = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ignition":{"version":"3.3.0"},"passwd":{"users":[{"name":"core","sshAuthorizedKeys":["${ssh_key}"]}]},"storage":{"files":[{"overwrite":true,"path":"/etc/flatcar/update.conf","contents":{"compression":"","source":"data:,SERVER%3Ddisabled%0A"},"mode":420}]}}

examples/terraform/openstack/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,9 @@ Name of operating system profile for MachineDeployments, only applicable if oper
190190
If not specified, the default value will be added by machine-controller addon.
191191
EOF
192192
}
193+
194+
variable "disable_auto_update" {
195+
description = "Disable automatic flatcar updates (and reboot)"
196+
type = bool
197+
default = false
198+
}

examples/terraform/vsphere_flatcar/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ No modules.
7979
| <a name="input_datastore_cluster_name"></a> [datastore\_cluster\_name](#input\_datastore\_cluster\_name) | datastore cluster name | `string` | `""` | no |
8080
| <a name="input_datastore_name"></a> [datastore\_name](#input\_datastore\_name) | datastore name | `string` | `"datastore1"` | no |
8181
| <a name="input_dc_name"></a> [dc\_name](#input\_dc\_name) | datacenter name | `string` | `"dc-1"` | no |
82+
| <a name="input_disable_auto_update"></a> [disable\_auto\_update](#input\_disable\_auto\_update) | Disable automatic flatcar updates (and reboot) | `bool` | `false` | no |
8283
| <a name="input_disk_size"></a> [disk\_size](#input\_disk\_size) | disk size | `number` | `50` | no |
8384
| <a name="input_folder_name"></a> [folder\_name](#input\_folder\_name) | folder name | `string` | `"kubeone"` | no |
8485
| <a name="input_initial_machinedeployment_operating_system_profile"></a> [initial\_machinedeployment\_operating\_system\_profile](#input\_initial\_machinedeployment\_operating\_system\_profile) | Name of operating system profile for MachineDeployments, only applicable if operating-system-manager addon is enabled.<br>If not specified, the default value will be added by machine-controller addon. | `string` | `""` | no |

examples/terraform/vsphere_flatcar/main.tf

+20-9
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,27 @@ resource "vsphere_virtual_machine" "control_plane" {
116116
]
117117
},
118118
storage = {
119-
files = [
120-
{
121-
filesystem = "root"
122-
path = "/etc/hostname"
123-
mode = 420
124-
contents = {
125-
source = "data:,${local.hostnames[count.index]}"
119+
files = concat(
120+
[
121+
{
122+
filesystem = "root"
123+
path = "/etc/hostname"
124+
mode = 420
125+
contents = {
126+
source = "data:,${local.hostnames[count.index]}"
127+
}
126128
}
127-
}
128-
]
129+
], var.disable_auto_update ?
130+
[
131+
{
132+
filesystem = "root"
133+
path = "/etc/flatcar/update.conf"
134+
mode = 420
135+
contents = {
136+
source = "data:,SERVER%3Ddisabled%0A"
137+
}
138+
}
139+
] : [])
129140
},
130141
passwd = {
131142
users = [

examples/terraform/vsphere_flatcar/outputs.tf

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ output "kubeone_workers" {
6464
operatingSystem = var.worker_os
6565
operatingSystemSpec = {
6666
distUpgradeOnBoot = false
67+
disableAutoUpdate = var.disable_auto_update
68+
disableLocksmithD = var.disable_auto_update
6769
}
6870
# nodeAnnotations are applied on resulting Node objects
6971
# nodeAnnotations = {

examples/terraform/vsphere_flatcar/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,9 @@ variable "is_vsphere_enterprise_plus_license" {
233233
type = bool
234234
default = true
235235
}
236+
237+
variable "disable_auto_update" {
238+
description = "Disable automatic flatcar updates (and reboot)"
239+
type = bool
240+
default = false
241+
}

test/e2e/testdata/openstack_flatcar.tfvars

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ image = "kubeone-e2e-flatcar"
55
worker_os = "flatcar"
66
ssh_username = "core"
77
bastion_user = "core"
8+
disable_auto_update = true

test/e2e/tests_definitions.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ var (
157157
path: "../../examples/terraform/aws",
158158
varFile: "testdata/aws_medium.tfvars",
159159
vars: []string{
160+
"disable_auto_update=true",
160161
"os=flatcar",
161162
},
162163
},
@@ -199,6 +200,7 @@ var (
199200
path: "../../examples/terraform/aws",
200201
varFile: "testdata/aws_medium.tfvars",
201202
vars: []string{
203+
"disable_auto_update=true",
202204
"os=flatcar",
203205
"worker_deploy_ssh_key=false",
204206
},
@@ -632,6 +634,7 @@ var (
632634
terraform: terraformBin{
633635
path: "../../examples/terraform/equinixmetal",
634636
vars: []string{
637+
"disable_auto_update=true",
635638
"os=flatcar",
636639
},
637640
},
@@ -652,9 +655,8 @@ var (
652655
terraform: terraformBin{
653656
path: "../../../kubeone-stable/examples/terraform/equinixmetal",
654657
vars: []string{
655-
"control_plane_operating_system=flatcar_stable",
656-
"worker_os=flatcar",
657-
"ssh_username=core",
658+
"disable_auto_update=true",
659+
"os=flatcar",
658660
},
659661
},
660662
protokol: protokolBin{
@@ -1015,6 +1017,7 @@ var (
10151017
path: "../../examples/terraform/vsphere_flatcar",
10161018
varFile: "testdata/vsphere.tfvars",
10171019
vars: []string{
1020+
"disable_auto_update=true",
10181021
"template_name=kkp-flatcar-stable",
10191022
},
10201023
},

0 commit comments

Comments
 (0)