diff --git a/k8s.tf b/k8s.tf index 2911a5e..fb2057f 100644 --- a/k8s.tf +++ b/k8s.tf @@ -231,6 +231,7 @@ resource "kops_instance_group" "masters" { cluster_name = kops_cluster.k8s.id name = "master-${var.region}${each.key}" role = "Master" + image = var.master_image != null ? var.master_image : var.image min_size = 1 max_size = 1 machine_type = var.master_types[0] @@ -265,6 +266,7 @@ resource "kops_instance_group" "nodes" { cluster_name = kops_cluster.k8s.id name = "nodes-${each.key}" role = "Node" + image = var.node_image != null ? var.node_image : var.image min_size = lookup(local.min_nodes, each.key) max_size = lookup(local.max_nodes, each.key) machine_type = var.node_types[0] @@ -303,6 +305,7 @@ resource "kops_instance_group" "additional_nodes" { cluster_name = kops_cluster.k8s.id name = "nodes-${each.key}" role = "Node" + image = each.value.image != null ? each.value.image : var.image min_size = each.value.min_size max_size = each.value.max_size machine_type = each.value.types[0] diff --git a/vars.tf b/vars.tf index 6d48263..7041678 100644 --- a/vars.tf +++ b/vars.tf @@ -48,6 +48,12 @@ variable "dns_zone" { description = "Name of DNS zone to use for cluster" } +variable "image" { + type = string + description = "The image to use for instances (can be overridden by master_image, node_image and image in additional_nodes)" + default = "" +} + variable "master_types" { type = list(string) default = ["t3.medium"] @@ -78,10 +84,16 @@ variable "master_max_instance_lifetime_hours" { default = 168 } +variable "master_image" { + type = string + description = "The image to use for master instances" + default = "" +} + variable "node_types" { type = list(string) default = ["t3.medium"] - description = "Instance types for master instances. Specifying more than one instance type will result in a mixed instance policy." + description = "Instance types for node instances. Specifying more than one instance type will result in a mixed instance policy." } variable "node_size" { @@ -111,6 +123,12 @@ variable "node_max_instance_lifetime_hours" { default = 168 } +variable "node_image" { + type = string + description = "The image to use for node instances" + default = "" +} + variable "additional_nodes" { type = map(object({ min_size = number @@ -121,6 +139,7 @@ variable "additional_nodes" { on_demand_base = number on_demand_above_base = number max_instance_lifetime_hours = optional(number, 168) + image = optional(string) })) description = "Additional node groups" default = {}