Add support for CPU Platform in google_container_node_pool (#622)

* update container/v1 API

* add support for CPU Platform in `google_container_node_pool`

* fix broken links
This commit is contained in:
David Quarles 2017-10-25 14:08:48 -07:00 committed by Dana Hoffman
parent 7bac0a2db6
commit 1a8f3b8d18
5 changed files with 36 additions and 9 deletions

View File

@ -92,6 +92,12 @@ var schemaNodeConfig = &schema.Schema{
ForceNew: true,
Default: false,
},
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
},
}
@ -159,6 +165,10 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
// Preemptible Is Optional+Default, so it always has a value
nc.Preemptible = nodeConfig["preemptible"].(bool)
if v, ok := nodeConfig["min_cpu_platform"]; ok {
nc.MinCpuPlatform = v.(string)
}
return nc
}
@ -170,15 +180,16 @@ func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
}
config = append(config, map[string]interface{}{
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
"image_type": c.ImageType,
"labels": c.Labels,
"tags": c.Tags,
"preemptible": c.Preemptible,
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
"image_type": c.ImageType,
"labels": c.Labels,
"tags": c.Tags,
"preemptible": c.Preemptible,
"min_cpu_platform": c.MinCpuPlatform,
})
if len(c.OauthScopes) > 0 {

View File

@ -593,6 +593,7 @@ func testAccCheckContainerCluster(n string) resource.TestCheckFunc {
{"node_config.0.labels", cluster.NodeConfig.Labels},
{"node_config.0.tags", cluster.NodeConfig.Tags},
{"node_config.0.preemptible", cluster.NodeConfig.Preemptible},
{"node_config.0.min_cpu_platform", cluster.NodeConfig.MinCpuPlatform},
{"node_version", cluster.CurrentNodeVersion},
}
@ -1008,6 +1009,7 @@ resource "google_container_cluster" "with_node_config" {
}
tags = ["foo", "bar"]
preemptible = true
min_cpu_platform = "Intel Broadwell"
}
}`, acctest.RandString(10))

View File

@ -238,6 +238,7 @@ func testAccCheckContainerNodePoolMatches(n string) resource.TestCheckFunc {
{"node_config.0.labels", nodepool.Config.Labels},
{"node_config.0.tags", nodepool.Config.Tags},
{"node_config.0.preemptible", nodepool.Config.Preemptible},
{"node_config.0.min_cpu_platform", nodepool.Config.MinCpuPlatform},
}
for _, attrs := range nodepoolTests {
@ -517,6 +518,7 @@ resource "google_container_node_pool" "np_with_node_config" {
"https://www.googleapis.com/auth/monitoring"
]
preemptible = true
min_cpu_platform = "Intel Broadwell"
}
}`, acctest.RandString(10), acctest.RandString(10))

View File

@ -159,6 +159,12 @@ which the cluster's instances are launched
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
for more information. Defaults to false.
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
The instance may be scheduled on the specified or newer CPU platform. Applicable
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
for more information.
**Addons Config** supports the following addons:
* `http_load_balancing` - (Optional) The status of the HTTP Load Balancing

View File

@ -114,6 +114,12 @@ resource "google_container_cluster" "primary" {
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
for more information. Defaults to false.
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
The instance may be scheduled on the specified or newer CPU platform. Applicable
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
for more information.
The `autoscaling` block supports:
* `min_node_count` - (Required) Minimum number of nodes in the NodePool. Must be >=1 and