Skip to content

Commit

Permalink
container_cluster: added disk_type node configuration
Browse files Browse the repository at this point in the history
Added node config 'disk_type' which can either be 'pd-standard' or
'pd-ssd', if left blank 'pd-standard' will be the default used by google
cloud.

Closes: #1656
  • Loading branch information
vishen committed Jun 15, 2018
1 parent 43cccf3 commit d0890dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 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 @@ -1382,7 +1382,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 @@ -1631,6 +1631,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
13 changes: 8 additions & 5 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ output "cluster_ca_certificate" {
When enabled, identities in the system, including service accounts, nodes, and controllers,
will have statically granted permissions beyond those provided by the RBAC configuration or IAM.
Defaults to `false`

* `initial_node_count` - (Optional) The number of nodes to create in this
cluster (not including the Kubernetes master). Must be set if `node_pool` is not set.

Expand Down 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 @@ -179,10 +179,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 @@ -267,7 +267,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 d0890dc

Please sign in to comment.