Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AKS os disk type parameter #263

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading