Update GKE docs to match actual schema; reorder fields in schema (#637)

* reorder schemas and update docs

* initial_node_count is optional

* clarify when initial_node_count must be set
This commit is contained in:
Dana Hoffman 2017-10-27 15:18:34 -07:00 committed by GitHub
parent 48192d62dc
commit adbb5dd4fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 281 additions and 316 deletions

View File

@ -14,13 +14,6 @@ var schemaNodeConfig = &schema.Schema{
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"machine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"disk_size_gb": {
Type: schema.TypeInt,
Optional: true,
@ -29,42 +22,6 @@ var schemaNodeConfig = &schema.Schema{
ValidateFunc: validation.IntAtLeast(10),
},
"local_ssd_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
},
"oauth_scopes": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
StateFunc: func(v interface{}) string {
return canonicalizeServiceScope(v.(string))
},
},
Set: stringScopeHashcode,
},
"service_account": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"metadata": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: schema.TypeString,
},
"image_type": {
Type: schema.TypeString,
Optional: true,
@ -79,11 +36,46 @@ var schemaNodeConfig = &schema.Schema{
Elem: schema.TypeString,
},
"tags": {
Type: schema.TypeList,
"local_ssd_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
},
"machine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"metadata": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Elem: schema.TypeString,
},
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"oauth_scopes": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
StateFunc: func(v interface{}) string {
return canonicalizeServiceScope(v.(string))
},
},
Set: stringScopeHashcode,
},
"preemptible": {
@ -93,11 +85,19 @@ var schemaNodeConfig = &schema.Schema{
Default: false,
},
"min_cpu_platform": {
"service_account": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"tags": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
}

View File

@ -40,42 +40,6 @@ func resourceContainerCluster() *schema.Resource {
},
Schema: map[string]*schema.Schema{
"master_auth": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"client_certificate": {
Type: schema.TypeString,
Computed: true,
},
"client_key": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"cluster_ca_certificate": {
Type: schema.TypeString,
Computed: true,
},
"password": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Sensitive: true,
},
"username": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
},
},
"name": {
Type: schema.TypeString,
Required: true,
@ -109,12 +73,6 @@ func resourceContainerCluster() *schema.Resource {
ForceNew: true,
},
"initial_node_count": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"additional_zones": {
Type: schema.TypeSet,
Optional: true,
@ -122,71 +80,6 @@ func resourceContainerCluster() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},
"cluster_ipv4_cidr": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
_, ipnet, err := net.ParseCIDR(value)
if err != nil || ipnet == nil || value != ipnet.String() {
errors = append(errors, fmt.Errorf(
"%q must contain a valid CIDR", k))
}
return
},
},
"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"enable_legacy_abac": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"endpoint": {
Type: schema.TypeString,
Computed: true,
},
"instance_group_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"logging_service": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"logging.googleapis.com", "none"}, false),
},
"monitoring_service": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"network": {
Type: schema.TypeString,
Optional: true,
Default: "default",
ForceNew: true,
StateFunc: StoreResourceName,
},
"subnetwork": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"addons_config": {
Type: schema.TypeList,
Optional: true,
@ -240,9 +133,86 @@ func resourceContainerCluster() *schema.Resource {
},
},
"master_version": {
"cluster_ipv4_cidr": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
_, ipnet, err := net.ParseCIDR(value)
if err != nil || ipnet == nil || value != ipnet.String() {
errors = append(errors, fmt.Errorf(
"%q must contain a valid CIDR", k))
}
return
},
},
"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"enable_legacy_abac": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"initial_node_count": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"logging_service": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"logging.googleapis.com", "none"}, false),
},
"master_auth": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"password": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Sensitive: true,
},
"username": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"client_certificate": {
Type: schema.TypeString,
Computed: true,
},
"client_key": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"cluster_ca_certificate": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"min_master_version": {
@ -250,14 +220,22 @@ func resourceContainerCluster() *schema.Resource {
Optional: true,
},
"node_config": schemaNodeConfig,
"node_version": {
"monitoring_service": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"network": {
Type: schema.TypeString,
Optional: true,
Default: "default",
ForceNew: true,
StateFunc: StoreResourceName,
},
"node_config": schemaNodeConfig,
"node_pool": {
Type: schema.TypeList,
Optional: true,
@ -268,11 +246,39 @@ func resourceContainerCluster() *schema.Resource {
},
},
"node_version": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"project": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"subnetwork": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"endpoint": {
Type: schema.TypeString,
Computed: true,
},
"instance_group_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"master_version": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

View File

@ -56,36 +56,6 @@ func resourceContainerNodePool() *schema.Resource {
}
var schemaNodePool = map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"name_prefix": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"initial_node_count": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
Deprecated: "Use node_count instead",
},
"node_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(1),
},
"node_config": schemaNodeConfig,
"autoscaling": &schema.Schema{
Type: schema.TypeList,
Optional: true,
@ -106,6 +76,36 @@ var schemaNodePool = map[string]*schema.Schema{
},
},
},
"initial_node_count": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
Deprecated: "Use node_count instead",
},
"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"name_prefix": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"node_config": schemaNodeConfig,
"node_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(1),
},
}
func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) error {

View File

@ -53,9 +53,6 @@ resource "google_container_cluster" "primary" {
## Argument Reference
* `initial_node_count` - (Required) The number of nodes to create in this
cluster (not including the Kubernetes master).
* `name` - (Required) The name of the cluster, unique within the project and
zone.
@ -63,24 +60,34 @@ resource "google_container_cluster" "primary" {
in `initial_node_count` should be created in.
- - -
* `master_auth` - (Optional) The authentication information for accessing the
Kubernetes master.
* `additional_zones` - (Optional) If additional zones are configured, the number
of nodes specified in `initial_node_count` is created in all specified zones.
* `additional_zones` - (Optional) The list of additional Google Compute Engine
locations in which the cluster's nodes should be located. If additional zones are
configured, the number of nodes specified in `initial_node_count` is created in
all specified zones.
* `addons_config` - (Optional) The configuration for addons supported by Google
Container Engine
Container Engine. Structure is documented below.
* `cluster_ipv4_cidr` - (Optional) The IP address range of the container pods in
this cluster. Default is an automatically assigned CIDR.
* `description` - (Optional) Description of the cluster.
* `enable_legacy_abac` - (Optional) Whether the ABAC authorizer is enabled for this cluster.
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.
* `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.
* `logging_service` - (Optional) The logging service that the cluster should
write logs to. Available options include `logging.googleapis.com` and
`none`. Defaults to `logging.googleapis.com`
* `master_auth` - (Optional) The authentication information for accessing the
Kubernetes master. Structure is documented below.
* `min_master_version` - (Optional) The minimum version of the master. GKE
will auto-update the master to new versions, so this does not guarantee the
current master version--use the read-only `master_version` field to obtain that.
@ -93,25 +100,53 @@ resource "google_container_cluster" "primary" {
`monitoring.googleapis.com`
* `network` - (Optional) The name or self_link of the Google Compute Engine
network to which the cluster is connected
network to which the cluster is connected.
* `node_config` - (Optional) The machine type and image to use for all nodes in
this cluster
* `node_config` - (Optional) Parameters used in creating the cluster's nodes.
Structure is documented below.
* `node_pool` - (Optional) List of node pools associated with this cluster.
See [google_container_node_pool](container_node_pool.html) for schema.
* `node_version` - (Optional) The Kubernetes version on the nodes. Also affects
the initial master version on cluster creation. Updates affect nodes only.
Defaults to the default version set by GKE which is not necessarily the latest
version.
* `node_version` - (Optional) The Kubernetes version on the nodes. Must either be unset
or set to the same value as `min_master_version` on create. Defaults to the default
version set by GKE which is not necessarily the latest version.
* `project` - (Optional) The project in which the resource belongs. If it
is not provided, the provider project is used.
* `subnetwork` - (Optional) The name of the Google Compute Engine subnetwork in
which the cluster's instances are launched
which the cluster's instances are launched.
**Master Auth** supports the following arguments:
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. It is enabled by default;
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.
* `kubernetes_dashboard` - (Optional) The status of the Kubernetes Dashboard
add-on, which controls whether the Kubernetes Dashboard is enabled for this cluster.
It is enabled by default; set `disabled = true` to disable.
This example `addons_config` disables two addons:
```
addons_config {
http_load_balancing {
disabled = true
}
horizontal_pod_autoscaling {
disabled = true
}
}
```
The `master_auth` block supports:
* `password` - (Required) The password to use for HTTP basic authentication when accessing
the Kubernetes master endpoint
@ -119,17 +154,30 @@ which the cluster's instances are launched
* `username` - (Required) The username to use for HTTP basic authentication when accessing
the Kubernetes master endpoint
**Node Config** supports the following arguments:
* `machine_type` - (Optional) The name of a Google Compute Engine machine type.
Defaults to `n1-standard-1`.
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.
* `image_type` - (Optional) The image type to use for this node.
* `labels` - (Optional) The Kubernetes labels (key/value pairs) to be applied to each node.
* `local_ssd_count` - (Optional) The amount of local SSD disks that will be
attached to each cluster node. Defaults to 0.
* `machine_type` - (Optional) The name of a Google Compute Engine machine type.
Defaults to `n1-standard-1`.
* `metadata` - (Optional) The metadata key/value pairs assigned to instances in
the cluster.
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
The instance may be scheduled on the specified or newer CPU platform. Applicable
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
for more information.
* `oauth_scopes` - (Optional) The set of Google API scopes to be made available
on all of the node VMs under the "default" service account. These can be
either FQDNs, or scope aliases. The following scopes are necessary to ensure
@ -142,80 +190,34 @@ which the cluster's instances are launched
* `monitoring` (`https://www.googleapis.com/auth/monitoring`),
if `monitoring_service` points to Google
* `service_account` - (Optional) The service account to be used by the Node VMs.
If not specified, the "default" service account is used.
* `metadata` - (Optional) The metadata key/value pairs assigned to instances in
the cluster.
* `image_type` - (Optional) The image type to use for this node.
* `labels` - (Optional) The Kubernetes labels (key/value pairs) to be applied to each node.
* `tags` - (Optional) The list of instance tags applied to all nodes. Tags are used to identify
valid sources or targets for network firewalls.
* `preemptible` - (Optional) A boolean that represents whether or not the underlying node VMs
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
for more information. Defaults to false.
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
The instance may be scheduled on the specified or newer CPU platform. Applicable
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
for more information.
* `service_account` - (Optional) The service account to be used by the Node VMs.
If not specified, the "default" service account is used.
**Addons Config** supports the following addons:
* `http_load_balancing` - (Optional) The status of the HTTP Load Balancing
add-on. It is enabled by default; set `disabled = true` to disable.
* `horizontal_pod_autoscaling` - (Optional) The status of the Horizontal Pod
Autoscaling addon. It is enabled by default; set `disabled = true` to
disable.
* `kubernetes_dashboard` - (Optional) The status of the Kubernetes Dashboard
add-on. It is enabled by default; set `disabled = true` to disable.
This example `addons_config` disables both addons:
```
addons_config {
http_load_balancing {
disabled = true
}
horizontal_pod_autoscaling {
disabled = true
}
}
```
**Node Pool** supports the following arguments:
* `initial_node_count` - (Required) The initial node count for the pool.
* `name` - (Optional) The name of the node pool. If left blank, Terraform will
auto-generate a unique name.
* `name_prefix` - (Optional) Creates a unique name for the node pool beginning
with the specified prefix. Conflicts with `name`.
* `tags` - (Optional) The list of instance tags applied to all nodes. Tags are used to identify
valid sources or targets for network firewalls.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are
exported:
* `endpoint` - The IP address of this cluster's Kubernetes master
* `endpoint` - The IP address of this cluster's Kubernetes master.
* `instance_group_urls` - List of instance group URLs which have been assigned
to the cluster
to the cluster.
* `master_auth.client_certificate` - Base64 encoded public certificate
used by clients to authenticate to the cluster endpoint.
* `master_auth.client_key` - Base64 encoded private key used by clients
to authenticate to the cluster endpoint
to authenticate to the cluster endpoint.
* `master_auth.cluster_ca_certificate` - Base64 encoded public certificate
that is the root of trust for the cluster
that is the root of trust for the cluster.
* `master_version` - The current version of the master in the cluster. This may
be different than the `min_master_version` set in the config if the master

View File

@ -55,12 +55,13 @@ resource "google_container_cluster" "primary" {
* `cluster` - (Required) The cluster to create the node pool for.
* `initial_node_count` - (Required) The initial node count for the pool.
- - -
* `project` - (Optional) The project in which to create the node pool. If blank,
the provider-configured project will be used.
* `autoscaling` - (Optional) Configuration required by cluster autoscaler to adjust
the size of the node pool to the current cluster usage. Structure is documented below.
* `initial_node_count` - (Deprecated, Optional) The initial node count for the pool.
Use `node_count` instead.
* `name` - (Optional) The name of the node pool. If left blank, Terraform will
auto-generate a unique name.
@ -68,57 +69,13 @@ resource "google_container_cluster" "primary" {
* `name_prefix` - (Optional) Creates a unique name for the node pool beginning
with the specified prefix. Conflicts with `name`.
* `node_config` - (Optional) The machine type and image to use for all nodes in
this pool
* `node_config` - (Optional) The node configuration of the pool. See
[google_container_cluster](container_cluster.html for schema.
* `autoscaling` - (Optional) Configuration required by cluster autoscaler to adjust
the size of the node pool to the current cluster usage. Structure is documented below.
* `node_count` - (Optional) The number of nodes per instance group.
**Node Config** supports the following arguments:
* `machine_type` - (Optional) The name of a Google Compute Engine machine type.
Defaults to `n1-standard-1`.
* `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.
* `local_ssd_count` - (Optional) The amount of local SSD disks that will be
attached to each node pool. Defaults to 0.
* `oauth_scopes` - (Optional) The set of Google API scopes to be made available
on all of the node VMs under the "default" service account. These can be
either FQDNs, or scope aliases. The following scopes are necessary to ensure
the correct functioning of the node pool:
* `compute-rw` (`https://www.googleapis.com/auth/compute`)
* `storage-ro` (`https://www.googleapis.com/auth/devstorage.read_only`)
* `logging-write` (`https://www.googleapis.com/auth/logging.write`),
if `logging_service` points to Google
* `monitoring` (`https://www.googleapis.com/auth/monitoring`),
if `monitoring_service` points to Google
* `service_account` - (Optional) The service account to be used by the Node VMs.
If not specified, the "default" service account is used.
* `metadata` - (Optional) The metadata key/value pairs assigned to instances in
the node pool.
* `image_type` - (Optional) The image type to use for this node.
* `labels` - (Optional) The Kubernetes labels (key/value pairs) to be applied to each node.
* `tags` - (Optional) The list of instance tags applied to all nodes. Tags are used to identify
valid sources or targets for network firewalls.
* `preemptible` - (Optional) A boolean that represents whether or not the underlying node VMs
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
for more information. Defaults to false.
* `min_cpu_platform` - (Optional) Minimum CPU platform to be used by this instance.
The instance may be scheduled on the specified or newer CPU platform. Applicable
values are the friendly names of CPU platforms, such as `Intel Haswell`. See the
[official documentation](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
for more information.
* `project` - (Optional) The project in which to create the node pool. If blank,
the provider-configured project will be used.
The `autoscaling` block supports: