2017-03-21 22:20:38 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_container_node_pool"
|
|
|
|
sidebar_current: "docs-google-container-node-pool"
|
|
|
|
description: |-
|
|
|
|
Manages a GKE NodePool resource.
|
|
|
|
---
|
|
|
|
|
|
|
|
# google\_container\_node\_pool
|
|
|
|
|
|
|
|
Manages a Node Pool resource within GKE. For more information see
|
|
|
|
[the official documentation](https://cloud.google.com/container-engine/docs/node-pools)
|
|
|
|
and
|
|
|
|
[API](https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters.nodePools).
|
|
|
|
|
|
|
|
## Example usage
|
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2017-03-21 22:20:38 +00:00
|
|
|
resource "google_container_node_pool" "np" {
|
|
|
|
name = "my-node-pool"
|
|
|
|
zone = "us-central1-a"
|
|
|
|
cluster = "${google_container_cluster.primary.name}"
|
|
|
|
initial_node_count = 3
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_container_cluster" "primary" {
|
|
|
|
name = "marcellus-wallace"
|
|
|
|
zone = "us-central1-a"
|
|
|
|
initial_node_count = 3
|
|
|
|
|
|
|
|
additional_zones = [
|
|
|
|
"us-central1-b",
|
|
|
|
"us-central1-c",
|
|
|
|
]
|
|
|
|
|
|
|
|
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",
|
|
|
|
"https://www.googleapis.com/auth/monitoring",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
* `zone` - (Required) The zone in which the cluster resides.
|
|
|
|
|
2018-01-19 18:45:19 +00:00
|
|
|
* `cluster` - (Required) The cluster to create the node pool for. Cluster must be present in `zone` provided for this resource.
|
2017-03-21 22:20:38 +00:00
|
|
|
|
|
|
|
- - -
|
|
|
|
|
2017-10-27 22:18:34 +00:00
|
|
|
* `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.
|
2017-03-21 22:20:38 +00:00
|
|
|
|
2017-11-21 20:56:29 +00:00
|
|
|
* `management` - (Optional) Node management configuration, wherein auto-repair and
|
|
|
|
auto-upgrade is configured. Structure is documented below.
|
|
|
|
|
2017-03-21 22:20:38 +00:00
|
|
|
* `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`.
|
2017-07-26 20:21:51 +00:00
|
|
|
|
2017-10-27 22:18:34 +00:00
|
|
|
* `node_config` - (Optional) The node configuration of the pool. See
|
2017-11-21 20:56:29 +00:00
|
|
|
[google_container_cluster](container_cluster.html) for schema.
|
2017-07-31 16:28:39 +00:00
|
|
|
|
2017-10-27 22:18:34 +00:00
|
|
|
* `node_count` - (Optional) The number of nodes per instance group.
|
2017-07-31 16:28:39 +00:00
|
|
|
|
2017-10-27 22:18:34 +00:00
|
|
|
* `project` - (Optional) The project in which to create the node pool. If blank,
|
|
|
|
the provider-configured project will be used.
|
2017-10-25 21:08:48 +00:00
|
|
|
|
2017-07-26 20:21:51 +00:00
|
|
|
The `autoscaling` block supports:
|
|
|
|
|
2017-10-03 17:46:33 +00:00
|
|
|
* `min_node_count` - (Required) Minimum number of nodes in the NodePool. Must be >=1 and
|
2017-09-06 20:57:00 +00:00
|
|
|
<= `max_node_count`.
|
2017-07-26 20:21:51 +00:00
|
|
|
|
2017-09-06 20:57:00 +00:00
|
|
|
* `max_node_count` - (Required) Maximum number of nodes in the NodePool. Must be >= min_node_count.
|
2017-08-07 17:35:39 +00:00
|
|
|
|
2017-11-21 20:56:29 +00:00
|
|
|
The `management` block supports:
|
|
|
|
|
|
|
|
* `auto_repair` - (Optional) Whether the nodes will be automatically repaired.
|
|
|
|
|
|
|
|
* `auto_upgrade` - (Optional) Whether the nodes will be automatically upgraded.
|
|
|
|
|
2017-08-07 17:35:39 +00:00
|
|
|
## Import
|
|
|
|
|
|
|
|
Node pools can be imported using the `zone`, `cluster` and `name`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import google_container_node_pool.mainpool us-east1-a/my-cluster/main-pool
|
2017-10-03 17:46:33 +00:00
|
|
|
```
|