terraform-linode-k8s
terraform-linode-k8s copied to clipboard
Variable disk size
General:
Add variables to enable the override of default disk sizes for master and node servers.
disk_size_master, disk_size_node - minimum value 8192 If the variable is set less than 8192 the setting is ignored.
@recipedude 8192/8191 can actually be derived from the image min size, (but should likely be padded with a few gb)
https://www.terraform.io/docs/providers/linode/d/image.html
data "linode_image" "k8_master" {
id = "linode/containerlinux"
}
resource "linode_instance" "k8s_master" {
... image = "${data.linode_image.k8s_master.size + 2048}"
}
Generally speaking, if we don't allocate the full disk to the base operating system, it will make sense for Terraform to define a second (more?) disks and pass those options on to the user.
For example,
disk {
label = "boot"
size = "${data.linode_instance_type.master.disk}"
size = "${var.disk_size_master > 8191 ? var.disk_size_master : data.linode_instance_type.master.disk}"
authorized_keys = ["${chomp(file(var.ssh_public_key))}"]
image = "linode/containerlinux"
}
disk {
label = "data" // starts getting very opinionated
// and local disks eat at the number of potential block devices that can be attached
size = "${var.disk_size_master_data}"
type = "raw" // this may be better suited for a ceph cluster across all nodes
}
If that were the case, I would hope the user could effectively disable this second device with a 0
size, but I don't believe hcl
offers a way to make that entire disk
stanza conditional, and I don't believe the Linode provider will skip a 0 sized disk when resolving the requested disks (it will attempt to create a 0 sized disk and the API will throw an error, or the provider may have >0 validation on this field, I don't recall).
@displague, I was wondering about determining the min. image size that was just chosen arbitrarily by what my gut told me would be an absolutely minimal workable system. Feels much better/deliberate/cleaner to derive from the data source.
Initially took a quick stab at allocating the remaining disk in the terraform module itself but was unsure how to implement and, as you point out, the conditional on the 2nd disk stanza becomes problematic.
Thanks for the comment, much appreciated.