Skip to content

Commit

Permalink
Merge pull request #76 from opzkit/spot-allocation-strategy
Browse files Browse the repository at this point in the history
feat: change to the new price-capacity-optimized strategy
  • Loading branch information
argoyle authored Jun 18, 2024
2 parents 9c1a588 + 57b16e5 commit 7d4815c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions k8s.tf
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ resource "kops_instance_group" "masters" {
on_demand_above_base {
value = var.master_on_demand_above_base
}
spot_allocation_strategy = "capacity-optimized"
spot_allocation_strategy = var.master_spot_allocation_strategy
}
subnets = [
"${local.node_group_subnet_prefix}${each.key}"
Expand Down Expand Up @@ -284,7 +284,7 @@ resource "kops_instance_group" "nodes" {
on_demand_above_base {
value = var.node_on_demand_above_base
}
spot_allocation_strategy = "capacity-optimized"
spot_allocation_strategy = var.node_spot_allocation_strategy
}
subnets = [
"${local.node_group_subnet_prefix}${each.key}"
Expand Down Expand Up @@ -323,7 +323,7 @@ resource "kops_instance_group" "additional_nodes" {
on_demand_above_base {
value = each.value.on_demand_above_base
}
spot_allocation_strategy = "capacity-optimized"
spot_allocation_strategy = each.value.spot_allocation_strategy
}
subnets = tolist([for k, v in var.public_subnet_ids : "${local.node_group_subnet_prefix}${k}"])
cloud_labels = {
Expand Down
13 changes: 13 additions & 0 deletions vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ variable "master_on_demand_above_base" {
description = "Percentage of instances in each group above base to keep as on demand. Specifying 0 will only use spot instances."
}

variable "master_spot_allocation_strategy" {
default = "price-capacity-optimized"
type = string
description = "The spot allocation strategy to use."
}

variable "master_count" {
type = number
default = 1
Expand Down Expand Up @@ -117,6 +123,12 @@ variable "node_on_demand_above_base" {
description = "Percentage of instances in each group above base to keep as on demand. Specifying 0 will only use spot instances."
}

variable "node_spot_allocation_strategy" {
default = "price-capacity-optimized"
type = string
description = "The spot allocation strategy to use."
}

variable "node_max_instance_lifetime_hours" {
type = number
description = "The maximum amount of time that an instance can be in service."
Expand All @@ -139,6 +151,7 @@ variable "additional_nodes" {
on_demand_base = number
on_demand_above_base = number
max_instance_lifetime_hours = optional(number, 168)
spot_allocation_strategy = optional(string, "price-capacity-optimized")
image = optional(string)
}))
description = "Additional node groups"
Expand Down

0 comments on commit 7d4815c

Please sign in to comment.