Skip to content

spotinst/terraform-spotinst-ocean-aks-np-k8s-vng

Repository files navigation

Spot Ocean k8s Virtual Node Group Terraform Module

Spotinst Terraform Module to integrate existing k8s node groups with Ocean launchspec/Virtual Node group (VNG).

Usage

provider "spotinst" {
  token   = "redacted"
  account = "redacted"
}
terraform {
  required_version = ">= 0.13.1"
  required_providers {
    spotinst = {
      source  = "spotinst/spotinst"
      version = ">=1.115.0"
    }
  }
}

module "ocean-aks-np-vng" {
  
  source = "spotinst/ocean-aks-np-k8s-vng/spotinst"
  ocean_vng_name                            = "testVng"
  ocean_id                                  = "o-134abcd"
  autoscale_headrooms_cpu_per_unit          = 1024
  autoscale_headrooms_memory_per_unit       = 512
  autoscale_headrooms_gpu_per_unit          = 0
  autoscale_headrooms_num_of_units          = 2
  availability_zones                        = ["1", "2", "3"]
  max_pods_per_node                         = 30
  enable_node_public_ip                     = true
  os_disk_size_gb                           = 30
  os_disk_type                              = "Managed"
  os_type                                   = "Linux"
  os_sku                                    = "Ubuntu"
  kubernetes_version                        = "1.26"
  pod_subnet_ids                            = ["/subscriptions/123456-1234-1234-1234-123456789/resourceGroups/ExampleResourceGroup/providers/Microsoft.Network/virtualNetworks/ExampleVirtualNetwork/subnets/default"]
  vnet_subnet_ids                           = ["/subscriptions/123456-1234-1234-1234-123456789/resourceGroups/ExampleResourceGroup/providers/Microsoft.Network/virtualNetworks/ExampleVirtualNetwork/subnets/default"]
  linux_os_config                          = {
    vm_max_map_count                       = 79550}
  node_min_count                            = 1
  node_max_count                            = 100
  spot_percentage                           = 50
  fallback_to_ondemand                      = true
  tags                                      = { "tagKey": "env", "tagValue": "staging" }
  labels                                    = { "key": "env","value": "test"}
  taints                                    = [{"key":"taintKey","value":"taintValue", "effect" : "NoSchedule"}]
  vmsizes_filters_min_vcpu                  = 2
  vmsizes_filters_max_vcpu                  = 16
  vmsizes_filters_min_memory_gib            = 10
  vmsizes_filters_max_memory_gib            = 18
  vmsizes_filters_series                    = ["D v3", "Dds_v4", "Dsv2"]
  vmsizes_filters_architectures             = ["X86_64"]
  should_roll                               = true
  conditioned_roll                          = false
  batch_size_percentage                     = 25
  batch_min_healthy_percentage              = 100
  vng_ids                                   = ["vng-12345"]
  shutdown_hours                            = { is_enabled = false 
                                               time_windows = ["Fri:15:30-Sat:13:30", "Sun:15:30-Mon:13:30"] }

}

Providers

Name Version
spotinst/spotinst >= 1.115.0

Modules

  • ocean-aks-np-k8s - Creates Ocean Cluster Doc
  • ocean-controller - Create and installs spot ocean controller pod Doc
  • ocean-aks-np-k8s-vng - (Optional) Add custom virtual node groups Doc

Documentation

If you're new to Spot and want to get started, please checkout our Getting Started guide, available on the Spot Documentation website.

Getting Help

We use GitHub issues for tracking bugs and feature requests. Please use these community resources for getting help:

Community

Contributing

Please see the contribution guidelines.

Modules

No modules.

Inputs

Name Description Type Default Required
ocean_vng_name Enter a name for the virtual node group. string null yes
ocean_id The Ocean cluster identifier. Required for Launch Spec creation. string null yes
autoscale_headrooms_num_of_units The number of units to retain as headroom, where each unit has the defined headroom CPU, memory. number null no
autoscale_headrooms_cpu_per_unit Configure the number of CPUs to allocate for each headroom unit. CPUs are denoted in millicores, where 1000 millicores = 1 vCPU. number null no
autoscale_headrooms_gpu_per_unit Amont of GPU to allocate for headroom unit. number null no
autoscale_headrooms_memory_per_unit Configure the amount of memory (MiB) to allocate the headroom number null no
max_pods_per_node The maximum number of pods per node in the node pools. number null no
enable_node_public_ip Enable node public IP. bool null no
os_disk_size_gb The size of the OS disk in GB. number null no
os_disk_type The type of the OS disk. string null no
os_type The os type of the os disk. string null no
os_sku The OS SKU of the OS type. Must correlate with the os type. string null no
kubernetes_version The desired Kubernetes version of the launched nodes. In case the value is null, the Kubernetes version of the control plane is used. string null no
pod_subnet_ids The IDs of subnets in an existing VNet into which to assign pods in the cluster (requires azure network-plugin). list(string) null no
vnet_subnet_ids The IDs of subnets in an existing VNet into which to assign nodes in the cluster (requires azure network-plugin). list(string) null no
vm_max_map_count Maximum number of memory map areas a process may have. Can be configured only if OS type is Linux. number null no
node_min_count Minimum node count limit. number null no
node_max_count Maximum node count limit. number null no
spot_percentage Percentage of spot VMs to maintain. number 100 no
fallback_to_ondemand If no spot instance markets are available, enable Ocean to launch on-demand instances instead. bool true no
taints Add taints to a virtual node group. list(map(string)) null no
tags A maximum of 10 unique key-value pairs for VM tags in the virtual node group. map(string) null no
labels An array of labels to add to the virtual node group.Only custom user labels are allowed, and not Kubernetes built-in labels or Spot internal labels. map(string) null no
availability_zones An Array holding Availability Zones, this configures the availability zones the Ocean may launch instances in per VNG. list(string) null no
vmsizes_filters_min_vcpu Minimum number of vcpus available. number null no
vmsizes_filters_max_vcpu Maximum number of vcpus available. number null no
vmsizes_filters_min_memory_gib Minimum amount of Memory (GiB). number null no
vmsizes_filters_max_memory_gib Maximum amount of Memory (GiB). number null no
vmsizes_filters_architectures The filtered vm sizes will support at least one of the architectures from this list. x86_64 includes both intel64 and amd64. list(string) null no
vmsizes_filters_series Vm sizes belonging to a series from the list will be available for scaling list(string) null no
vmsizes_filters_exclude_series Vm sizes belonging to a series from the list will not be available for scaling. list(string) null no
vmsizes_filters_accelereated_networking In case acceleratedNetworking is set to Enabled, accelerated networking applies only to the VM that enables it. string null no
vmsizes_filters_disk_performance The filtered vm sizes will support at least one of the classes from this list. string null no
vmsizes_filters_min_gpu Minimum number of GPUs available. number null no
vmsizes_filters_max_gpu Maximum number of GPUs available. number null no
vmsizes_filters_min_nics Minimum number of network interfaces. number null no
vmsizes_filters_min_disk Minimum number of data disks available. number null no
vmsizes_filters_vm_types The filtered vm types will belong to one of the vm types from this list. list(string) null no
vmsizes_filters_gpu_types The filtered gpu types will belong to one of the gpu types from this list. Supported GPU Types: nvidia-tesla-v100, amd-radeon-instinct-mi25, nvidia-a10, nvidia-tesla-a100, nvidia-tesla-k80, nvidia-tesla-m60, nvidia-tesla-p100, nvidia-tesla-p40, nvidia-tesla-t4, nvidia-tesla-h100. list(string) null no
should_roll If set to true along with the vng update, roll will be triggered. bool false no
conditioned_roll Default: false. Spot will perform a cluster Roll in accordance with a relevant modification of the cluster’s settings. When set to true , only specific changes in the cluster’s configuration will trigger a cluster roll (such as availability_zones, max_pods_per_node, enable_node_public_ip, os_disk_size_gb, os_disk_type, os_sku, kubernetes_version, vnet_subnet_ids, pod_subnet_ids, labels, taints and tags). bool null no
respect_pdb During the roll, if the parameter is set to true we honor PDB during the nodes replacement bool true no
batch_size_percentage Value as a percent to set the size of a batch in a roll. Valid values are 0-100. In case of null as value, the default value in the backend will be 20%. number 20 no
vng_ids List of virtual node group identifiers to be rolled. Each identifier is a string. vngIds can be null, and cannot be used together with nodeNames and nodePoolNames. list(string) null no
batch_min_healthy_percentage Default: 50. Indicates the threshold of minimum healthy nodes in single batch. If the amount of healthy nodes in single batch is under the threshold, the roll will fail. If exists, the parameter value will be in range of 1-100. In case of null as value, the default value in the backend will be 50%. Value of param should represent the number in percentage (%) of the batch. number null no
comment Add a comment description for the roll. The comment is limited to 256 chars and optional. string null no
node_pool_names List of node pools to be rolled. Each node pool name is a string. nodePoolNames can be null, and cannot be used together with nodeNames and vngIds. list(string) null no
respect_restrict_scale_down During the roll, if the parameter is set to true we honor Restrict Scale Down label during the nodes replacement. bool false no
node_names List of node names to be rolled. Each identifier is a string. nodeNames can be null, and cannot be used together with nodePoolNames and vngIds. list(string) null no
shutdown_hours shutdown_hours object object null no
time_windows The times that the shutdown hours will apply. list(string) null no
is_enabled Flag to enable or disable the shutdown hours mechanism. When False, the mechanism is deactivated, and the cluster remains in its current state. bool null no

Outputs

Name Description

| vng_id | The VirtualNodeGroup ID |

License

Code is licensed under the Apache License 2.0.