Skip to content

Commit

Permalink
Merge pull request #1665 from vishen/container_cluster_disk_type
Browse files Browse the repository at this point in the history
container_cluster: added disk_type node configuration
  • Loading branch information
paddycarver authored Jul 6, 2018
2 parents c9f0473 + d0890dc commit 0eb723e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
18 changes: 16 additions & 2 deletions google/node_config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package google

import (
"strconv"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
containerBeta "google.golang.org/api/container/v1beta1"
"strconv"
"strings"
)

// Matches gke-default scope from https://cloud.google.com/sdk/gcloud/reference/container/clusters/create
Expand Down Expand Up @@ -34,6 +35,14 @@ var schemaNodeConfig = &schema.Schema{
ValidateFunc: validation.IntAtLeast(10),
},

"disk_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"pd-standard", "pd-ssd"}, false),
},

"guest_accelerator": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -216,6 +225,10 @@ func expandNodeConfig(v interface{}) *containerBeta.NodeConfig {
nc.DiskSizeGb = int64(v.(int))
}

if v, ok := nodeConfig["disk_type"]; ok {
nc.DiskType = v.(string)
}

if v, ok := nodeConfig["local_ssd_count"]; ok {
nc.LocalSsdCount = int64(v.(int))
}
Expand Down Expand Up @@ -304,6 +317,7 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
config = append(config, map[string]interface{}{
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"disk_type": c.DiskType,
"guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators),
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
Expand Down
3 changes: 2 additions & 1 deletion google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ resource "google_container_cluster" "with_network_policy_enabled" {
network_policy {
enabled = true
provider = "CALICO"
}
}
addons_config {
network_policy_config {
disabled = false
Expand Down Expand Up @@ -1654,6 +1654,7 @@ resource "google_container_cluster" "with_node_config" {
node_config {
machine_type = "n1-standard-1"
disk_size_gb = 15
disk_type = "pd-ssd"
local_ssd_count = 1
oauth_scopes = [
"https://www.googleapis.com/auth/monitoring",
Expand Down
11 changes: 7 additions & 4 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ output "cluster_ca_certificate" {
official release (which is not necessarily the latest version).

* `monitoring_service` - (Optional) The monitoring service that the cluster
should write metrics to.
should write metrics to.
Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API.
VM metrics will be collected by Google Compute Engine regardless of this setting
Available options include
Expand Down Expand Up @@ -181,10 +181,10 @@ The `addons_config` block supports:

* `horizontal_pod_autoscaling` - (Optional) The status of the Horizontal Pod Autoscaling
addon, which increases or decreases the number of replica pods a replication controller
has based on the resource usage of the existing pods.
has based on the resource usage of the existing pods.
It ensures that a Heapster pod is running in the cluster, which is also used by the Cloud Monitoring service.
It is enabled by default;
set `disabled = true` to disable.
set `disabled = true` to disable.
* `http_load_balancing` - (Optional) The status of the HTTP (L7) load balancing
controller addon, which makes it easy to set up HTTP load balancers for services in a
cluster. It is enabled by default; set `disabled = true` to disable.
Expand Down Expand Up @@ -279,7 +279,10 @@ The `node_config` block supports:
* `disk_size_gb` - (Optional) Size of the disk attached to each node, specified
in GB. The smallest allowed disk size is 10GB. Defaults to 100GB.

* `guest_accelerator` - (Optional) List of the type and count of accelerator cards attached to the instance.
* `disk_type` - (Optional) Type of the disk attached to each node
(e.g. 'pd-standard' or 'pd-ssd'). If unspecified, the default disk type is 'pd-standard'

* `guest_accelerator` - (Optional) List of the type and count of accelerator cards attached to the instance.
Structure documented below.

* `image_type` - (Optional) The image type to use for this node.
Expand Down

0 comments on commit 0eb723e

Please sign in to comment.