Skip to content

Commit 8bba7b1

Browse files
committed
add support for CPU Platform in google_container_node_pool
1 parent d0a76e5 commit 8bba7b1

5 files changed

+36
-9
lines changed

google/node_config.go

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

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

@@ -169,15 +179,16 @@ func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
169179
}
170180

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

183194
if len(c.OauthScopes) > 0 {

google/resource_container_cluster_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ func testAccCheckContainerCluster(n string) resource.TestCheckFunc {
591591
{"node_config.0.labels", cluster.NodeConfig.Labels},
592592
{"node_config.0.tags", cluster.NodeConfig.Tags},
593593
{"node_config.0.preemptible", cluster.NodeConfig.Preemptible},
594+
{"node_config.0.min_cpu_platform", cluster.NodeConfig.MinCpuPlatform},
594595
{"node_version", cluster.CurrentNodeVersion},
595596
}
596597

@@ -1006,6 +1007,7 @@ resource "google_container_cluster" "with_node_config" {
10061007
}
10071008
tags = ["foo", "bar"]
10081009
preemptible = true
1010+
min_cpu_platform = "Intel Broadwell"
10091011
}
10101012
}`, acctest.RandString(10))
10111013

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-m in-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-m in-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)