2015-06-20 22:57:45 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_container_cluster"
|
2015-10-23 14:10:41 +00:00
|
|
|
sidebar_current: "docs-google-container-cluster"
|
2015-06-20 22:57:45 +00:00
|
|
|
description: |-
|
|
|
|
Creates a GKE cluster.
|
|
|
|
---
|
|
|
|
|
|
|
|
# google\_container\_cluster
|
|
|
|
|
2017-07-28 18:05:48 +00:00
|
|
|
Creates a GKE cluster. For more information see
|
|
|
|
[the official documentation](https://cloud.google.com/container-engine/docs/clusters)
|
|
|
|
and
|
|
|
|
[API](https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters).
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
!> **Warning:** Due to limitations of the API, all arguments except
|
|
|
|
`node_version` are non-updateable. Changing any will cause recreation of the
|
|
|
|
whole cluster!
|
2015-06-20 22:57:45 +00:00
|
|
|
|
2017-03-29 09:37:36 +00:00
|
|
|
~> **Note:** All arguments including the username and password will be stored in the raw state as plain-text.
|
|
|
|
[Read more about sensitive data in state](/docs/state/sensitive-data.html).
|
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
## Example usage
|
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2015-06-20 22:57:45 +00:00
|
|
|
resource "google_container_cluster" "primary" {
|
2017-02-18 22:48:50 +00:00
|
|
|
name = "marcellus-wallace"
|
|
|
|
zone = "us-central1-a"
|
2016-04-10 21:34:15 +00:00
|
|
|
initial_node_count = 3
|
|
|
|
|
2017-01-04 06:14:39 +00:00
|
|
|
additional_zones = [
|
|
|
|
"us-central1-b",
|
2017-02-18 22:48:50 +00:00
|
|
|
"us-central1-c",
|
2017-01-04 06:14:39 +00:00
|
|
|
]
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
master_auth {
|
|
|
|
username = "mr.yoda"
|
|
|
|
password = "adoy.rm"
|
|
|
|
}
|
|
|
|
|
|
|
|
node_config {
|
|
|
|
oauth_scopes = [
|
|
|
|
"https://www.googleapis.com/auth/compute",
|
|
|
|
"https://www.googleapis.com/auth/devstorage.read_only",
|
|
|
|
"https://www.googleapis.com/auth/logging.write",
|
2017-02-18 22:48:50 +00:00
|
|
|
"https://www.googleapis.com/auth/monitoring",
|
2016-04-10 21:34:15 +00:00
|
|
|
]
|
2017-06-17 19:07:10 +00:00
|
|
|
|
|
|
|
labels {
|
|
|
|
foo = "bar"
|
|
|
|
}
|
|
|
|
|
|
|
|
tags = ["foo", "bar"]
|
2016-04-10 21:34:15 +00:00
|
|
|
}
|
2015-06-20 22:57:45 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `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.
|
|
|
|
|
2017-01-04 06:14:39 +00:00
|
|
|
* `zone` - (Required) The zone that the master and the number of nodes specified
|
|
|
|
in `initial_node_count` should be created in.
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
- - -
|
2017-05-31 19:43:31 +00:00
|
|
|
* `master_auth` - (Optional) The authentication information for accessing the
|
|
|
|
Kubernetes master.
|
|
|
|
|
2017-01-04 06:14:39 +00:00
|
|
|
* `additional_zones` - (Optional) If additional zones are configured, the number
|
|
|
|
of nodes specified in `initial_node_count` is created in all specified zones.
|
|
|
|
|
2016-11-14 23:49:43 +00:00
|
|
|
* `addons_config` - (Optional) The configuration for addons supported by Google
|
|
|
|
Container Engine
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
* `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.
|
|
|
|
|
|
|
|
* `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`
|
|
|
|
|
|
|
|
* `monitoring_service` - (Optional) The monitoring service that the cluster
|
|
|
|
should write metrics to. Available options include
|
|
|
|
`monitoring.googleapis.com` and `none`. Defaults to
|
|
|
|
`monitoring.googleapis.com`
|
|
|
|
|
2016-11-14 23:49:43 +00:00
|
|
|
* `network` - (Optional) The name or self_link of the Google Compute Engine
|
|
|
|
network to which the cluster is connected
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
* `node_config` - (Optional) The machine type and image to use for all nodes in
|
|
|
|
this cluster
|
|
|
|
|
2017-04-12 19:57:53 +00:00
|
|
|
* `node_pool` - (Optional) List of node pools associated with this cluster.
|
|
|
|
|
2016-12-20 14:06:19 +00:00
|
|
|
* `node_version` - (Optional) The Kubernetes version on the nodes. Also affects
|
2017-02-18 22:48:50 +00:00
|
|
|
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
|
2016-12-20 14:06:19 +00:00
|
|
|
version.
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
* `project` - (Optional) The project in which the resource belongs. If it
|
|
|
|
is not provided, the provider project is used.
|
2015-06-20 22:57:45 +00:00
|
|
|
|
2016-11-14 23:49:43 +00:00
|
|
|
* `subnetwork` - (Optional) The name of the Google Compute Engine subnetwork in
|
|
|
|
which the cluster's instances are launched
|
2016-04-14 23:30:39 +00:00
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
**Master Auth** supports the following arguments:
|
|
|
|
|
2017-05-30 20:44:39 +00:00
|
|
|
* `password` - (Required) The password to use for HTTP basic authentication when accessing
|
2016-04-10 21:34:15 +00:00
|
|
|
the Kubernetes master endpoint
|
|
|
|
|
2017-05-30 20:44:39 +00:00
|
|
|
* `username` - (Required) The username to use for HTTP basic authentication when accessing
|
2016-04-10 21:34:15 +00:00
|
|
|
the Kubernetes master endpoint
|
2015-06-20 22:57:45 +00:00
|
|
|
|
|
|
|
**Node Config** supports the following arguments:
|
|
|
|
|
|
|
|
* `machine_type` - (Optional) The name of a Google Compute Engine machine type.
|
2016-04-10 21:34:15 +00:00
|
|
|
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.
|
|
|
|
|
2017-02-27 15:25:27 +00:00
|
|
|
* `local_ssd_count` - (Optional) The amount of local SSD disks that will be
|
|
|
|
attached to each cluster node. Defaults to 0.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `oauth_scopes` - (Optional) The set of Google API scopes to be made available
|
2016-11-14 23:50:24 +00:00
|
|
|
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 cluster:
|
|
|
|
|
|
|
|
* `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
|
2015-06-20 22:57:45 +00:00
|
|
|
|
2017-03-20 23:40:18 +00:00
|
|
|
* `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.
|
|
|
|
|
2017-06-17 19:07:10 +00:00
|
|
|
* `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.
|
|
|
|
|
2017-09-01 20:02:26 +00:00
|
|
|
* `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.
|
|
|
|
|
2016-04-14 23:30:39 +00:00
|
|
|
**Addons Config** supports the following addons:
|
|
|
|
|
2016-11-14 23:49:43 +00:00
|
|
|
* `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.
|
2016-04-14 23:30:39 +00:00
|
|
|
|
|
|
|
This example `addons_config` disables both addons:
|
2016-10-11 08:14:27 +00:00
|
|
|
|
2016-04-14 23:30:39 +00:00
|
|
|
```
|
|
|
|
addons_config {
|
2016-11-14 23:49:43 +00:00
|
|
|
http_load_balancing {
|
2016-10-11 08:14:27 +00:00
|
|
|
disabled = true
|
2016-04-14 23:30:39 +00:00
|
|
|
}
|
|
|
|
horizontal_pod_autoscaling {
|
2016-10-11 08:14:27 +00:00
|
|
|
disabled = true
|
2016-04-14 23:30:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-04-12 19:57:53 +00:00
|
|
|
**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`.
|
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
## Attributes Reference
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are
|
|
|
|
exported:
|
|
|
|
|
|
|
|
* `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
|
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
* `master_auth.client_certificate` - Base64 encoded public certificate
|
2016-04-10 21:34:15 +00:00
|
|
|
used by clients to authenticate to the cluster endpoint.
|
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
* `master_auth.client_key` - Base64 encoded private key used by clients
|
2016-04-10 21:34:15 +00:00
|
|
|
to authenticate to the cluster endpoint
|
|
|
|
|
2015-06-20 22:57:45 +00:00
|
|
|
* `master_auth.cluster_ca_certificate` - Base64 encoded public certificate
|
2016-04-10 21:34:15 +00:00
|
|
|
that is the root of trust for the cluster
|
2017-06-28 08:22:31 +00:00
|
|
|
|
|
|
|
<a id="timeouts"></a>
|
|
|
|
## Timeouts
|
|
|
|
|
|
|
|
`google_container_cluster` provides the following
|
|
|
|
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
|
|
|
|
|
|
|
- `create` - (Default `30 minutes`) Used for clusters
|
|
|
|
- `update` - (Default `10 minutes`) Used for updates to clusters
|
|
|
|
- `delete` - (Default `10 minutes`) Used for destroying clusters.
|
2017-09-07 17:31:58 +00:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
|
|
|
Container clusters can be imported using the `zone`, and `name`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import google_container_cluster.mycluster us-east1-a/my-cluster
|
|
|
|
```
|