Skip to content

Commit

Permalink
Add AKS os disk type parameter (#263)
Browse files Browse the repository at this point in the history
* Add AKS os disk type parameter
  • Loading branch information
apasyniuk authored Dec 15, 2023
1 parent 62affe9 commit a734050
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
47 changes: 47 additions & 0 deletions castai/resource_node_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
},
},
},
},
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions castai/sdk/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/resources/node_configuration.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a734050

Please sign in to comment.