Skip to content

Commit

Permalink
feat(ocean): autoscaler configuration (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: Bharat Kumar Govindaradjou <bgovindaradjou@ip-192-168-0-7.eu-west-1.compute.internal>
  • Loading branch information
bharatgovindaradjou and Bharat Kumar Govindaradjou authored Nov 2, 2021
1 parent 17f2991 commit 96ec4e2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 3 deletions.
33 changes: 30 additions & 3 deletions ocean.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,37 @@ EOF
key = "kubernetes.io/cluster/${local.cluster_name}"
value = "owned"
}

autoscaler {
autoscale_is_enabled = true
autoscale_is_auto_config = true
autoscale_is_enabled = var.autoscale_is_enabled
autoscale_is_auto_config = var.autoscale_is_enabled
auto_headroom_percentage = var.autoscaler_headroom_percentage
autoscale_cooldown = var.autoscaler_cooldown

dynamic "autoscale_headroom" {
for_each = var.autoscale_is_enabled && var.autoscaler_cpu_per_unit != null && var.autoscaler_memory_per_unit != null && var.autoscaler_num_of_units != null && var.autoscaler_gpu_per_unit != null ? [1] : []
content {
cpu_per_unit = var.autoscaler_cpu_per_unit
gpu_per_unit = var.autoscaler_gpu_per_unit
memory_per_unit = var.autoscaler_memory_per_unit
num_of_units = var.autoscaler_num_of_units
}
}

dynamic "autoscale_down" {
for_each = var.autoscale_is_enabled && var.autoscaler_max_scale_down_percentage != null ? [1] : []
content {
max_scale_down_percentage = var.autoscaler_max_scale_down_percentage
}
}

dynamic "resource_limits" {
for_each = var.autoscale_is_enabled && var.autoscaler_max_vcpu != null && var.autoscaler_max_memory_gib != null ? [1] : []
content {
max_vcpu = var.autoscaler_max_vcpu
max_memory_gib = var.autoscaler_max_memory_gib
}
}
}

dynamic "update_policy" {
Expand Down
60 changes: 60 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,66 @@ variable "spot_percentage" {
default = 100
}

variable "autoscale_is_enabled" {
type = bool
description = "Enables/disables the Ocean Kubernetes Auto Scaler. Default is true"
default = true
}

variable "autoscaler_headroom_percentage" {
type = number
description = "Sets the auto headroom percentage (a number in the range [0, 200]) which controls the percentage of headroom from the cluster. Relevant only when autoscale_is_auto_config toggled on"
default = null
}

variable "autoscaler_cooldown" {
type = number
description = "Sets cooldown period between scaling actions"
default = null
}

variable "autoscaler_cpu_per_unit" {
type = number
description = "Configures the number of CPUs to allocate the headroom. CPUs are denoted in millicores, where 1000 millicores = 1 vCPU"
default = null
}

variable "autoscaler_gpu_per_unit" {
type = number
description = "Configures the number of GPUs to allocate the headroom"
default = null
}

variable "autoscaler_memory_per_unit" {
type = number
description = "Configures the amount of memory (MB) to allocate the headroom"
default = null
}

variable "autoscaler_num_of_units" {
type = number
description = "Sets the number of units to retain as headroom, where each unit has the defined headroom CPU and memory."
default = null
}

variable "autoscaler_max_scale_down_percentage" {
type = number
description = "Sets the maximum % to scale-down. Number between 1-100"
default = null
}

variable "autoscaler_max_vcpu" {
type = number
description = "Sets the maximum cpu in vCPU units that can be allocated to the cluster."
default = null
}

variable "autoscaler_max_memory_gib" {
type = number
description = "Sets the maximum memory in GiB units that can be allocated to the cluster"
default = null
}

variable "update_policy" {
type = object({
should_roll = bool
Expand Down

0 comments on commit 96ec4e2

Please sign in to comment.