Skip to content

Commit 1e22a98

Browse files
chore: remove usage of deprecated autoscaler policies settings (#120)
* chore: remove usage of deprecated autoscaler policies settings * chore: regenerate docs --------- Co-authored-by: Daniel Voros <daniel.voros@cast.ai>
1 parent fd36745 commit 1e22a98

File tree

3 files changed

+91
-88
lines changed

3 files changed

+91
-88
lines changed

README.md

Lines changed: 90 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,6 @@ module "castai-aks-cluster" {
9090
9191
unschedulable_pods = {
9292
enabled = true
93-
94-
headroom = {
95-
enabled = true
96-
cpu_percentage = 10
97-
memory_percentage = 10
98-
}
99-
100-
headroom_spot = {
101-
enabled = true
102-
cpu_percentage = 10
103-
memory_percentage = 10
104-
}
10593
}
10694
10795
node_downscaler = {
@@ -343,6 +331,93 @@ module "castai-aks-cluster" {
343331
}
344332
```
345333

334+
Migrating from 9.x.x to 10.x.x
335+
---------------------------
336+
337+
Version 10.x.x removes deprecated autoscaler fields that have been moved to node templates.
338+
339+
**Removed:**
340+
* `autoscaler_policies_json` - Use `autoscaler_settings` instead
341+
* `autoscaler_settings.unschedulable_pods.custom_instances_enabled` - No longer needed
342+
* `autoscaler_settings.unschedulable_pods.headroom` - Use low-priority placeholder workloads instead
343+
* `autoscaler_settings.unschedulable_pods.headroom_spot` - Use low-priority placeholder workloads instead
344+
* `autoscaler_settings.unschedulable_pods.node_constraints` - Use `node_templates` constraints instead
345+
* `autoscaler_settings.spot_instances` - Use `node_templates` constraints instead
346+
347+
**Migration guide:**
348+
349+
Old configuration:
350+
```hcl
351+
module "castai-aks-cluster" {
352+
source = "castai/aks/castai"
353+
354+
autoscaler_settings = {
355+
enabled = true
356+
357+
unschedulable_pods = {
358+
enabled = true
359+
custom_instances_enabled = true
360+
361+
headroom = {
362+
enabled = true
363+
cpu_percentage = 10
364+
memory_percentage = 10
365+
}
366+
367+
node_constraints = {
368+
min_cpu_cores = 4
369+
max_cpu_cores = 32
370+
}
371+
}
372+
373+
spot_instances = {
374+
enabled = true
375+
spot_backups = {
376+
enabled = true
377+
}
378+
}
379+
}
380+
}
381+
```
382+
383+
New configuration:
384+
```hcl
385+
module "castai-aks-cluster" {
386+
source = "castai/aks/castai"
387+
388+
autoscaler_settings = {
389+
enabled = true
390+
391+
unschedulable_pods = {
392+
enabled = true
393+
}
394+
}
395+
396+
node_templates = {
397+
default_by_castai = {
398+
configuration_id = module.castai-aks-cluster.castai_node_configurations["default"]
399+
is_default = true
400+
401+
constraints = {
402+
min_cpu = 4
403+
max_cpu = 32
404+
spot = true
405+
use_spot_fallbacks = true
406+
}
407+
}
408+
}
409+
}
410+
411+
# For headroom: Deploy low-priority placeholder workloads
412+
# See: https://docs.cast.ai/docs/autoscaler-faq#how-can-i-maintain-cluster-headroom
413+
```
414+
415+
**Key changes:**
416+
* Node constraints (`min_cpu_cores`, `max_cpu_cores`, `min_ram_mib`, `max_ram_mib`) are now configured in `node_templates.constraints` as `min_cpu`, `max_cpu`, `min_memory`, `max_memory`
417+
* Spot instance settings (`spot`, `use_spot_fallbacks`) are now configured in `node_templates.constraints`
418+
* The default node template is named `default_by_castai`
419+
* For headroom functionality, deploy low-priority placeholder workloads as described in the [CAST AI documentation](https://docs.cast.ai/docs/autoscaler-faq#how-can-i-maintain-cluster-headroom)
420+
346421
# Examples
347422

348423
Usage examples are located in [terraform provider repo](https://github.com/castai/terraform-provider-castai/tree/master/examples/aks)
@@ -365,9 +440,9 @@ Usage examples are located in [terraform provider repo](https://github.com/casta
365440
|------|---------|
366441
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | ~> 3 |
367442
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.7.0 |
368-
| <a name="provider_castai"></a> [castai](#provider\_castai) | 7.62.0 |
369-
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.17.0 |
370-
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.4 |
443+
| <a name="provider_castai"></a> [castai](#provider\_castai) | >= 8.3 |
444+
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 3.0.0 |
445+
| <a name="provider_null"></a> [null](#provider\_null) | ~> 3 |
371446

372447
## Modules
373448

@@ -422,7 +497,6 @@ No modules.
422497
| <a name="input_aks_cluster_name"></a> [aks\_cluster\_name](#input\_aks\_cluster\_name) | Name of the cluster to be connected to CAST AI. | `string` | n/a | yes |
423498
| <a name="input_aks_cluster_region"></a> [aks\_cluster\_region](#input\_aks\_cluster\_region) | Region of the AKS cluster | `string` | n/a | yes |
424499
| <a name="input_api_url"></a> [api\_url](#input\_api\_url) | URL of alternative CAST AI API to be used during development or testing | `string` | `"https://api.cast.ai"` | no |
425-
| <a name="input_autoscaler_policies_json"></a> [autoscaler\_policies\_json](#input\_autoscaler\_policies\_json) | Optional json object to override CAST AI cluster autoscaler policies. Deprecated, use `autoscaler_settings` instead. | `string` | `null` | no |
426500
| <a name="input_autoscaler_settings"></a> [autoscaler\_settings](#input\_autoscaler\_settings) | Optional Autoscaler policy definitions to override current autoscaler settings | `any` | `null` | no |
427501
| <a name="input_azuread_owners"></a> [azuread\_owners](#input\_azuread\_owners) | A set of object IDs of principals that will be granted ownership of the Azure AD service principal and application. Defaults to current user. | `list(string)` | `null` | no |
428502
| <a name="input_castai_api_token"></a> [castai\_api\_token](#input\_castai\_api\_token) | Optional CAST AI API token created in console.cast.ai API Access keys section. Used only when `wait_for_cluster_ready` is set to true | `string` | `""` | no |

main.tf

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,6 @@ resource "helm_release" "castai_pod_mutator_self_managed" {
907907
resource "castai_autoscaler" "castai_autoscaler_policies" {
908908
cluster_id = castai_aks_cluster.castai_cluster.id
909909

910-
// Deprecated -- kept for backward compatibility
911-
autoscaler_policies_json = var.autoscaler_policies_json
912-
913910
dynamic "autoscaler_settings" {
914911
for_each = var.autoscaler_settings != null ? [var.autoscaler_settings] : []
915912

@@ -922,40 +919,7 @@ resource "castai_autoscaler" "castai_autoscaler_policies" {
922919
for_each = try([autoscaler_settings.value.unschedulable_pods], [])
923920

924921
content {
925-
enabled = try(unschedulable_pods.value.enabled, null)
926-
custom_instances_enabled = try(unschedulable_pods.value.custom_instances_enabled, null)
927-
928-
dynamic "headroom" {
929-
for_each = try([unschedulable_pods.value.headroom], [])
930-
931-
content {
932-
enabled = try(headroom.value.enabled, null)
933-
cpu_percentage = try(headroom.value.cpu_percentage, null)
934-
memory_percentage = try(headroom.value.memory_percentage, null)
935-
}
936-
}
937-
938-
dynamic "headroom_spot" {
939-
for_each = try([unschedulable_pods.value.headroom_spot], [])
940-
941-
content {
942-
enabled = try(headroom_spot.value.enabled, null)
943-
cpu_percentage = try(headroom_spot.value.cpu_percentage, null)
944-
memory_percentage = try(headroom_spot.value.memory_percentage, null)
945-
}
946-
}
947-
948-
dynamic "node_constraints" {
949-
for_each = try([unschedulable_pods.value.node_constraints], [])
950-
951-
content {
952-
enabled = try(node_constraints.value.enabled, null)
953-
min_cpu_cores = try(node_constraints.value.min_cpu_cores, null)
954-
max_cpu_cores = try(node_constraints.value.max_cpu_cores, null)
955-
min_ram_mib = try(node_constraints.value.min_ram_mib, null)
956-
max_ram_mib = try(node_constraints.value.max_ram_mib, null)
957-
}
958-
}
922+
enabled = try(unschedulable_pods.value.enabled, null)
959923

960924
dynamic "pod_pinner" {
961925
for_each = try([unschedulable_pods.value.pod_pinner], [])
@@ -985,35 +949,6 @@ resource "castai_autoscaler" "castai_autoscaler_policies" {
985949
}
986950
}
987951

988-
dynamic "spot_instances" {
989-
for_each = try([autoscaler_settings.value.spot_instances], [])
990-
991-
content {
992-
enabled = try(spot_instances.value.enabled, null)
993-
max_reclaim_rate = try(spot_instances.value.max_reclaim_rate, null)
994-
spot_diversity_enabled = try(spot_instances.value.spot_diversity_enabled, null)
995-
spot_diversity_price_increase_limit = try(spot_instances.value.spot_diversity_price_increase_limit, null)
996-
997-
dynamic "spot_backups" {
998-
for_each = try([spot_instances.value.spot_backups], [])
999-
1000-
content {
1001-
enabled = try(spot_backups.value.enabled, null)
1002-
spot_backup_restore_rate_seconds = try(spot_backups.value.spot_backup_restore_rate_seconds, null)
1003-
}
1004-
}
1005-
1006-
dynamic "spot_interruption_predictions" {
1007-
for_each = try([spot_instances.value.spot_interruption_predictions], [])
1008-
1009-
content {
1010-
enabled = try(spot_interruption_predictions.value.enabled, null)
1011-
spot_interruption_predictions_type = try(spot_interruption_predictions.value.spot_interruption_predictions_type, null)
1012-
}
1013-
}
1014-
}
1015-
}
1016-
1017952
dynamic "node_downscaler" {
1018953
for_each = try([autoscaler_settings.value.node_downscaler], [])
1019954

variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ variable "subscription_id" {
4848
description = "Azure subscription ID"
4949
}
5050

51-
variable "autoscaler_policies_json" {
52-
type = string
53-
description = "Optional json object to override CAST AI cluster autoscaler policies. Deprecated, use `autoscaler_settings` instead."
54-
default = null
55-
}
56-
5751
variable "autoscaler_settings" {
5852
type = any
5953
description = "Optional Autoscaler policy definitions to override current autoscaler settings"

0 commit comments

Comments
 (0)