Spot Ocean aks np k8s Terraform Module
Spotinst Terraform Module to integrate existing k8s with Ocean
Prerequisites
Installation of the Ocean controller is required by this resource. You can accomplish this by using the spotinst/ocean-controller module. The kubernetes provider will need to be initilaized before calling the ocean-controller module as follows:
provider "spotinst" {
token = "redacted"
account = "redacted"
}
module "ocean-aks-np" {
source = "spotinst/ocean-aks-np-k8s/spotinst"
...
}
##################
## Option 1 to initialize kubernetes provider ##
provider "kubernetes" {
config_path = "~/.kube/config"
}
##################
module "ocean-controller" {
source = "spotinst/ocean-controller/spotinst"
# Credentials.
spotinst_token = "redacted"
spotinst_account = "redacted"
# Configuration.
cluster_identifier = "cluster name"
}
~> You must configure the same cluster_identifier
both for the Ocean controller and for the spotinst_ocean_aks_np
resource. The ocean-aks-np
module will use the cluster name as the identifier. Ensure this is also used in the controller config
Usage
### Create Azure Ocean on spot console ###
module "ocean-aks-np" {
source = "spotinst/ocean-aks-np-k8s/spotinst"
# Credentials.
spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
# Configuration
ocean_cluster_name = "test"
aks_region = "eastus"
controller_cluster_id = "test-123124"
aks_cluster_name = "test-cluster"
aks_infrastructure_resource_group_name = "MC_TestResourceGroup_test-cluster_eastus"
aks_resource_group_name = "TestResourceGroup"
autoscaler_is_enabled = true
autoscaler_resource_limits_max_vcpu = 750
autoscaler_resource_limits_max_memory_gib= 1500
autoscaler_headroom_automatic_is_enabled = true
autoscaler_max_scale_down_percentage = 30
autoscaler_headroom_automatic_percentage = 5
health_grace_period = 600
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"]
node_min_count = 1
node_max_count = 100
spot_percentage = 50
fallback_to_ondemand = true
autoscale_headrooms_cpu_per_unit = 6
autoscale_headrooms_memory_per_unit = 10
autoscale_headrooms_gpu_per_unit = 4
autoscale_headrooms_num_of_units = 10
availability_zones = [1, 2, 3]
tags = { "tagKey": "env", "tagValue": "staging" }
labels = { "key": "env","value": "test"}
shutdown_hours = { is_enabled = false
time_windows = ["Fri:15:30-Sat:13:30", "Sun:15:30-Mon:13:30"] }
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"]
}
Providers
Name | Version |
---|---|
spotinst/spotinst | >= 1.102.0 |
Modules
ocean-aks-np-k8s
- Creates Ocean Cluster Dococean-controller
- Create and installs Spot Ocean controller pod Dococean-aws-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:
- Ask a question on Stack Overflow and tag it with terraform-spotinst.
- Join our Spot community on Slack.
- Open an issue.
Community
Contributing
Please see the contribution guidelines.
Modules
No modules.
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
ocean_cluster_name | The Ocean cluster. | string |
null |
yes |
aks_region | The cluster's region | string |
null |
yes |
controller_cluster_id | Enter a unique Ocean cluster identifier. Cannot be updated. | string |
null |
yes |
aks_cluster_name | The name of the AKS Cluster | string |
null |
yes |
aks_infrastructure_resource_group_name | The name of the cluster's infrastructure resource group. | string |
null |
yes |
aks_resource_group_name | The name of the cluster's resource group. | string |
null |
yes |
autoscaler_is_enabled | Enable the Ocean Kubernetes Autoscaler. | bool |
true |
yes |
autoscaler_resource_limits_max_vcpu | The maximum cpu in vCpu units that can be allocated to the cluster. | number |
null |
no |
autoscaler_resource_limits_max_memory_gib | The maximum memory in GiB units that can be allocated to the cluster. | number |
null |
no |
autoscaler_max_scale_down_percentage | The maximum percentage allowed to scale down in a single scaling action. | number |
null |
no |
autoscaler_headroom_automatic_is_enabled | Enable automatic headroom. When set to True, Ocean configures and optimizes headroom automatically. | bool |
false |
no |
autoscaler_headroom_automatic_percentage | Optionally set a number between 0-100 to control the percentage of total cluster resources dedicated to headroom. | number |
null |
no |
health_grace_period | The amount of time to wait, in seconds, from the moment the instance has launched until monitoring of its health checks begins. | number |
600 |
no |
availability_zones | An Array holding Availability Zones, this configures the availability zones the Ocean may launch instances in per VNG. | list(string) |
null |
yes |
max_pods_per_node | he 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 |
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 |
scheduling_shutdown_hours_time_windows | The times that the shutdown hours will apply. | list(string) |
null |
no |
scheduling_shutdown_hours_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 |
shutdown_hours | shutdown_hours object. | object |
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 virtual machine types will support at least one of the architectures from this list. | 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 |
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 |
Outputs
Name | Description |
---|
| ocean_id | The Ocean cluster ID |
License
Code is licensed under the Apache License 2.0.