diff --git a/castai/resource_node_configuration.go b/castai/resource_node_configuration.go index 50d7d83f..e54dd30b 100644 --- a/castai/resource_node_configuration.go +++ b/castai/resource_node_configuration.go @@ -228,6 +228,12 @@ func resourceNodeConfiguration() *schema.Resource { ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(10, 250)), Description: "Maximum number of pods that can be run on a node, which affects how many IP addresses you will need for each node. Defaults to 30", }, + "os_disk_type": { + Type: schema.TypeString, + Optional: true, + Description: "Type of managed os disk attached to the node. (See [disk types](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types)). One of: standard, standard-ssd, premium-ssd (ultra and premium-ssd-v2 are not supported for os disk)", + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"standard", "standard-ssd", "premium-ssd"}, false)), + }, }, }, }, @@ -667,9 +673,30 @@ func toAKSSConfig(obj map[string]interface{}) *sdk.NodeconfigV1AKSConfig { out.MaxPodsPerNode = toPtr(int32(v)) } + if v, ok := obj["os_disk_type"].(string); ok && v != "" { + out.OsDiskType = toAKSOSDiskType(v) + } + return out } +func toAKSOSDiskType(v string) *sdk.NodeconfigV1AKSConfigOsDiskType { + if v == "" { + return nil + } + + switch v { + case "standard": + return toPtr(sdk.OSDISKTYPESTANDARD) + case "standard-ssd": + return toPtr(sdk.OSDISKTYPESTANDARDSSD) + case "premium-ssd": + return toPtr(sdk.OSDISKTYPEPREMIUMSSD) + default: + return nil + } +} + func flattenAKSConfig(config *sdk.NodeconfigV1AKSConfig) []map[string]interface{} { if config == nil { return nil @@ -679,9 +706,29 @@ func flattenAKSConfig(config *sdk.NodeconfigV1AKSConfig) []map[string]interface{ m["max_pods_per_node"] = *config.MaxPodsPerNode } + if v := config.MaxPodsPerNode; v != nil { + m["os_disk_type"] = fromAKSDiskType(config.OsDiskType) + } + return []map[string]interface{}{m} } +func fromAKSDiskType(osDiskType *sdk.NodeconfigV1AKSConfigOsDiskType) string { + if osDiskType == nil { + return "" + } + switch *osDiskType { + case sdk.OSDISKTYPESTANDARD: + return "standard" + case sdk.OSDISKTYPESTANDARDSSD: + return "standard-ssd" + case sdk.OSDISKTYPEPREMIUMSSD: + return "premium-ssd" + default: + return "" + } +} + func toGKEConfig(obj map[string]interface{}) *sdk.NodeconfigV1GKEConfig { if obj == nil { return nil diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index 1cfe1a64..4054d4d9 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -70,6 +70,14 @@ const ( Worker ExternalclusterV1NodeType = "worker" ) +// Defines values for NodeconfigV1AKSConfigOsDiskType. +const ( + OSDISKTYPEPREMIUMSSD NodeconfigV1AKSConfigOsDiskType = "OS_DISK_TYPE_PREMIUM_SSD" + OSDISKTYPESTANDARD NodeconfigV1AKSConfigOsDiskType = "OS_DISK_TYPE_STANDARD" + OSDISKTYPESTANDARDSSD NodeconfigV1AKSConfigOsDiskType = "OS_DISK_TYPE_STANDARD_SSD" + OSDISKTYPEUNSPECIFIED NodeconfigV1AKSConfigOsDiskType = "OS_DISK_TYPE_UNSPECIFIED" +) + // Defines values for NodeconfigV1ContainerRuntime. const ( CONTAINERD NodeconfigV1ContainerRuntime = "CONTAINERD" @@ -1423,8 +1431,14 @@ type NodeconfigV1AKSConfig struct { // Defaults to 30. Values between 10 and 250 are allowed. // Setting values above 110 will require specific CNI configuration. Please refer to Microsoft documentation for additional guidance. MaxPodsPerNode *int32 `json:"maxPodsPerNode,omitempty"` + + // OsDiskType represent possible values for AKS node os disk type(this is subset of all available Azure disk types). + OsDiskType *NodeconfigV1AKSConfigOsDiskType `json:"osDiskType,omitempty"` } +// OsDiskType represent possible values for AKS node os disk type(this is subset of all available Azure disk types). +type NodeconfigV1AKSConfigOsDiskType string + // List of supported container runtimes kubelet should use. type NodeconfigV1ContainerRuntime string diff --git a/docs/resources/node_configuration.md b/docs/resources/node_configuration.md index 81979527..124d0691 100644 --- a/docs/resources/node_configuration.md +++ b/docs/resources/node_configuration.md @@ -87,6 +87,7 @@ resource "castai_node_configuration" "default" { Optional: - `max_pods_per_node` (Number) Maximum number of pods that can be run on a node, which affects how many IP addresses you will need for each node. Defaults to 30 +- `os_disk_type` (String) Type of managed os disk attached to the node. (See [disk types](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types)). One of: standard, standard-ssd, premium-ssd (ultra and premium-ssd-v2 are not supported for os disk)