Skip to content

Commit 1a8f3b8

Browse files
davidquarlesdanawillow
authored andcommitted
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
1 parent 7bac0a2 commit 1a8f3b8

5 files changed

+36
-9
lines changed

google/node_config.go

+20-9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ var schemaNodeConfig = &schema.Schema{
9292
ForceNew: true,
9393
Default: false,
9494
},
95+
96+
"min_cpu_platform": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
ForceNew: true,
100+
},
95101
},
96102
},
97103
}
@@ -159,6 +165,10 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
159165
// Preemptible Is Optional+Default, so it always has a value
160166
nc.Preemptible = nodeConfig["preemptible"].(bool)
161167

168+
if v, ok := nodeConfig["min_cpu_platform"]; ok {
169+
nc.MinCpuPlatform = v.(string)
170+
}
171+
162172
return nc
163173
}
164174

@@ -170,15 +180,16 @@ func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
170180
}
171181

172182
config = append(config, map[string]interface{}{
173-
"machine_type": c.MachineType,
174-
"disk_size_gb": c.DiskSizeGb,
175-
"local_ssd_count": c.LocalSsdCount,
176-
"service_account": c.ServiceAccount,
177-
"metadata": c.Metadata,
178-
"image_type": c.ImageType,
179-
"labels": c.Labels,
180-
"tags": c.Tags,
181-
"preemptible": c.Preemptible,
183+
"machine_type": c.MachineType,
184+
"disk_size_gb": c.DiskSizeGb,
185+
"local_ssd_count": c.LocalSsdCount,
186+
"service_account": c.ServiceAccount,
187+
"metadata": c.Metadata,
188+
"image_type": c.ImageType,
189+
"labels": c.Labels,
190+
"tags": c.Tags,
191+
"preemptible": c.Preemptible,
192+
"min_cpu_platform": c.MinCpuPlatform,
182193
})
183194

184195
if len(c.OauthScopes) > 0 {

google/resource_container_cluster_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ func testAccCheckContainerCluster(n string) resource.TestCheckFunc {
593593
{"node_config.0.labels", cluster.NodeConfig.Labels},
594594
{"node_config.0.tags", cluster.NodeConfig.Tags},
595595
{"node_config.0.preemptible", cluster.NodeConfig.Preemptible},
596+
{"node_config.0.min_cpu_platform", cluster.NodeConfig.MinCpuPlatform},
596597
{"node_version", cluster.CurrentNodeVersion},
597598
}
598599

@@ -1008,6 +1009,7 @@ resource "google_container_cluster" "with_node_config" {
10081009
}
10091010
tags = ["foo", "bar"]
10101011
preemptible = true
1012+
min_cpu_platform = "Intel Broadwell"
10111013
}
10121014
}`, acctest.RandString(10))
10131015

google/resource_container_node_pool_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func testAccCheckContainerNodePoolMatches(n string) resource.TestCheckFunc {
238238
{"node_config.0.labels", nodepool.Config.Labels},
239239
{"node_config.0.tags", nodepool.Config.Tags},
240240
{"node_config.0.preemptible", nodepool.Config.Preemptible},
241+
{"node_config.0.min_cpu_platform", nodepool.Config.MinCpuPlatform},
241242
}
242243

243244
for _, attrs := range nodepoolTests {
@@ -517,6 +518,7 @@ resource "google_container_node_pool" "np_with_node_config" {
517518
"https://www.googleapis.com/auth/monitoring"
518519
]
519520
preemptible = true
521+
min_cpu_platform = "Intel Broadwell"
520522
}
521523
}`, acctest.RandString(10), acctest.RandString(10))
522524

website/docs/r/container_cluster.html.markdown

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ which the cluster's instances are launched
159159
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
160160
for more information. Defaults to false.
161161

162+
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
163+
The instance may be scheduled on the specified or newer CPU platform. Applicable
164+
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
165+
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
166+
for more information.
167+
162168
**Addons Config** supports the following addons:
163169

164170
* `http_load_balancing` - (Optional) The status of the HTTP Load Balancing

website/docs/r/container_node_pool.html.markdown

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ resource "google_container_cluster" "primary" {
114114
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
115115
for more information. Defaults to false.
116116

117+
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
118+
The instance may be scheduled on the specified or newer CPU platform. Applicable
119+
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
120+
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
121+
for more information.
122+
117123
The `autoscaling` block supports:
118124

119125
* `min_node_count` - (Required) Minimum number of nodes in the NodePool. Must be >=1 and

0 commit comments

Comments
 (0)