Skip to content

Commit

Permalink
KUBE-355: GKE node config's preferred availability zones for new nodes (
Browse files Browse the repository at this point in the history
#307)

* update sdk to the latest api

* gke node config preferred availability zones

---------

Co-authored-by: Furkhat Kasymov Genii Uulu <furkhat@cast.ai>
  • Loading branch information
furkhat and Furkhat Kasymov Genii Uulu authored May 8, 2024
1 parent 2550274 commit f98f1e8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions castai/resource_node_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ func resourceNodeConfiguration() *schema.Resource {
Description: "Type of boot disk attached to the node. (See [disk types](https://cloud.google.com/compute/docs/disks#pdspecs)). One of: pd-standard, pd-balanced, pd-ssd, pd-extreme ",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"pd-standard", "pd-balanced", "pd-ssd", "pd-extreme"}, false)),
},
"zones": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "List of preferred availability zones to choose from when provisioning new nodes.",
},
},
},
},
Expand Down Expand Up @@ -811,6 +819,9 @@ func toGKEConfig(obj map[string]interface{}) *sdk.NodeconfigV1GKEConfig {
if v, ok := obj["disk_type"].(string); ok && v != "" {
out.DiskType = toPtr(v)
}
if v, ok := obj["zones"].([]interface{}); ok {
out.Zones = toPtr(toStringList(v))
}

return out
}
Expand All @@ -829,6 +840,9 @@ func flattenGKEConfig(config *sdk.NodeconfigV1GKEConfig) []map[string]interface{
if v := config.DiskType; v != nil {
m["disk_type"] = *v
}
if v := config.Zones; v != nil {
m["zones"] = *v
}

return []map[string]interface{}{m}
}
Expand Down
3 changes: 3 additions & 0 deletions castai/resource_node_configuration_gke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestAccResourceNodeConfiguration_gke(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gke.0.disk_type", "pd-balanced"),
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.0", "ab"),
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.1", "bc"),
resource.TestCheckResourceAttr(resourceName, "gke.0.zones.#", "0"),
),
},
{
Expand All @@ -48,6 +49,7 @@ func TestAccResourceNodeConfiguration_gke(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gke.0.disk_type", "pd-ssd"),
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.0", "bb"),
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.1", "dd"),
resource.TestCheckResourceAttr(resourceName, "gke.0.zones.0", "us-central1-c"),
),
},
},
Expand Down Expand Up @@ -105,6 +107,7 @@ resource "castai_node_configuration" "test" {
max_pods_per_node = 32
network_tags = ["bb", "dd"]
disk_type = "pd-ssd"
zones = ["us-central1-c"]
}
}
`, rName))
Expand Down
3 changes: 3 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 f98f1e8

Please sign in to comment.