container_cluster: added disk_type node configuration

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
This commit is contained in:
Jonathan Pentecost 2018-06-15 21:21:51 +01:00
parent 43cccf3e2c
commit d0890dc2b7
3 changed files with 26 additions and 8 deletions

View File

@ -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
@ -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,
@ -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))
}
@ -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,

View File

@ -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
@ -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",

View File

@ -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.
@ -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
@ -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.
@ -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.