Skip to content

Commit

Permalink
Merge pull request #63 from opzkit/specific-image
Browse files Browse the repository at this point in the history
feat: allow to specify what image to use for instances
  • Loading branch information
argoyle authored Oct 3, 2023
2 parents 50d9b3f + 6a9bae1 commit 6787b74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions k8s.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
21 changes: 20 additions & 1 deletion vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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
Expand All @@ -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 = {}
Expand Down

0 comments on commit 6787b74

Please sign in to comment.