Google Kubernetes (Container) Engine Node Pool

This page shows how to write Terraform for Kubernetes (Container) Engine Node Pool and write them securely.

google_container_node_pool (Terraform)

The Node Pool in Kubernetes (Container) Engine can be configured in Terraform with the resource name google_container_node_pool. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconinfracost/infracost
resource "google_container_node_pool" "default_regional" {
  name    = "default"
  cluster = google_container_cluster.default_regional.id
}

resource "google_container_node_pool" "with_node_config_regional" {
github-iconUCDenver-ccp/Translator-TM-Provider-Infrastructure-Modules
resource "google_container_node_pool" "node_pool" {
  provider = google-beta

  name     = "private-pool"
  project  = var.project
  location = var.location
github-iconCheckmarx/kics
resource "google_container_node_pool" "positive1" {
  name       = "my-node-pool"
  location   = "us-central1-a"
  cluster    = google_container_cluster.primary.name
  node_count = 3

github-icongilyas/infracost
resource "google_container_node_pool" "default_regional" {
  name    = "default"
  cluster = google_container_cluster.default_regional.id
}

resource "google_container_node_pool" "with_node_config_regional" {

Parameters

  • cluster required - string
    • The cluster to create the node pool for. Cluster must be present in location provided for zonal clusters.

  • id optionalcomputed - string
  • initial_node_count optionalcomputed - number
    • The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource.

  • instance_group_urls requiredcomputed - list / string
    • The resource URLs of the managed instance groups associated with this node pool.

  • location optionalcomputed - string
    • The location (region or zone) of the cluster.

  • max_pods_per_node optionalcomputed - number
    • The maximum number of pods per node in this node pool. Note that this does not work on node pools which are "route-based" - that is, node pools belonging to clusters that do not have IP Aliasing enabled.

  • name optionalcomputed - string
    • The name of the node pool. If left blank, Terraform will auto-generate a unique name.

  • name_prefix optionalcomputed - string
    • Creates a unique name for the node pool beginning with the specified prefix. Conflicts with name.

  • node_count optionalcomputed - number
    • The number of nodes per instance group. This field can be used to update the number of nodes per instance group but should not be used alongside autoscaling.

  • node_locations optionalcomputed - set / string
    • The list of zones in which the node pool's nodes should be located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. If unspecified, the cluster-level node_locations will be used.

  • operation requiredcomputed - string
  • project optionalcomputed - string
    • The ID of the project in which to create the node pool. If blank, the provider-configured project will be used.

  • version optionalcomputed - string
    • The Kubernetes version for the nodes in this pool. Note that if this field and auto_upgrade are both specified, they will fight each other for what the node version should be, so setting both is highly discouraged. While a fuzzy version can be specified, it's recommended that you specify explicit versions as Terraform will see spurious diffs when fuzzy versions are used. See the google_container_engine_versions data source's version_prefix field to approximate fuzzy versions in a Terraform-compatible way.

Explanation in Terraform Registry

-> See the Using GKE with Terraform guide for more information about using GKE with Terraform. Manages a node pool in a Google Kubernetes Engine (GKE) cluster separately from the cluster control plane. For more information see the official documentation and the API reference.

Frequently asked questions

What is Google Kubernetes (Container) Engine Node Pool?

Google Kubernetes (Container) Engine Node Pool is a resource for Kubernetes (Container) Engine of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Kubernetes (Container) Engine Node Pool?

For Terraform, the infracost/infracost, UCDenver-ccp/Translator-TM-Provider-Infrastructure-Modules and Checkmarx/kics source code examples are useful. See the Terraform Example section for further details.

security-icon

Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.