Skip to content

googleComputeNodeGroup

Represents a NodeGroup resource to manage a group of sole-tenant nodes.

To get more information about NodeGroup, see:

\~> Warning: Due to limitations of the API, Terraform cannot update the number of nodes in a node group and changes to node group size either through Terraform config or through external changes will cause Terraform to delete and recreate the node group.

Example Usage - Node Group Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNodeTemplateSoletenantTmpl =
  new google.computeNodeTemplate.ComputeNodeTemplate(this, "soletenant-tmpl", {
    name: "soletenant-tmpl",
    node_type: "n1-node-96-624",
    region: "us-central1",
  });
new google.computeNodeGroup.ComputeNodeGroup(this, "nodes", {
  description:
    "example google_compute_node_group for Terraform Google Provider",
  name: "soletenant-group",
  node_template: googleComputeNodeTemplateSoletenantTmpl.id,
  size: 1,
  zone: "us-central1-f",
});

Example Usage - Node Group Autoscaling Policy

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNodeTemplateSoletenantTmpl =
  new google.computeNodeTemplate.ComputeNodeTemplate(this, "soletenant-tmpl", {
    name: "soletenant-tmpl",
    node_type: "n1-node-96-624",
    region: "us-central1",
  });
new google.computeNodeGroup.ComputeNodeGroup(this, "nodes", {
  autoscaling_policy: [
    {
      max_nodes: 10,
      min_nodes: 1,
      mode: "ONLY_SCALE_OUT",
    },
  ],
  description:
    "example google_compute_node_group for Terraform Google Provider",
  initial_size: 1,
  maintenance_policy: "RESTART_IN_PLACE",
  maintenance_window: [
    {
      start_time: "08:00",
    },
  ],
  name: "soletenant-group",
  node_template: googleComputeNodeTemplateSoletenantTmpl.id,
  zone: "us-central1-f",
});

Example Usage - Node Group Share Settings

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNodeTemplateSoletenantTmpl =
  new google.computeNodeTemplate.ComputeNodeTemplate(this, "soletenant-tmpl", {
    name: "soletenant-tmpl",
    node_type: "n1-node-96-624",
    region: "us-central1",
  });
const googleProjectGuestProject = new google.project.Project(
  this,
  "guest_project",
  {
    name: "project-name",
    org_id: "123456789",
    project_id: "project-id",
  }
);
new google.computeNodeGroup.ComputeNodeGroup(this, "nodes", {
  description:
    "example google_compute_node_group for Terraform Google Provider",
  name: "soletenant-group",
  node_template: googleComputeNodeTemplateSoletenantTmpl.id,
  share_settings: [
    {
      project_map: [
        {
          id: googleProjectGuestProject.projectId,
          project_id: googleProjectGuestProject.projectId,
        },
      ],
      share_type: "SPECIFIC_PROJECTS",
    },
  ],
  size: 1,
  zone: "us-central1-f",
});

Argument Reference

The following arguments are supported:

  • nodeTemplate - (Required) The URL of the node template to which this node group belongs.

  • description - (Optional) An optional textual description of the resource.

  • name - (Optional) Name of the resource.

  • size - (Optional) The total number of nodes in the node group. One of initialSize or size must be specified.

  • initialSize - (Optional) The initial number of nodes in the node group. One of initialSize or size must be specified.

  • maintenancePolicy - (Optional) Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT.

  • maintenanceWindow - (Optional) contains properties for the timeframe of maintenance Structure is documented below.

  • autoscalingPolicy - (Optional) If you use sole-tenant nodes for your workloads, you can use the node group autoscaler to automatically manage the sizes of your node groups. Structure is documented below.

  • shareSettings - (Optional) Share settings for the node group. Structure is documented below.

  • zone - (Optional) Zone where this node group is located

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The maintenanceWindow block supports:

  • startTime - (Required) instances.start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid.

The autoscalingPolicy block supports:

  • mode - (Required) The autoscaling mode. Set to one of the following:

    • OFF: Disables the autoscaler.
    • ON: Enables scaling in and scaling out.
    • ONLY_SCALE_OUT: Enables only scaling out. You must use this mode if your node groups are configured to restart their hosted VMs on minimal servers. Possible values are off, on, and onlyScaleOut.
  • minNodes - (Optional) Minimum size of the node group. Must be less than or equal to max-nodes. The default value is 0.

  • maxNodes - (Required) Maximum size of the node group. Set to a value less than or equal to 100 and greater than or equal to min-nodes.

The shareSettings block supports:

  • shareType - (Required) Node group sharing type. Possible values are organization, specificProjects, and local.

  • projectMap - (Optional) A map of project id and project config. This is only valid when shareType's value is SPECIFIC_PROJECTS. Structure is documented below.

The projectMap block supports:

  • id - (Required) The identifier for this object. Format specified above.

  • projectId - (Required) The project id/number should be the same as the key of this project config in the project map.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}

  • creationTimestamp - Creation timestamp in RFC3339 text format.

  • selfLink - The URI of the created resource.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

NodeGroup can be imported using any of these accepted formats:

$ terraform import google_compute_node_group.default projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}
$ terraform import google_compute_node_group.default {{project}}/{{zone}}/{{name}}
$ terraform import google_compute_node_group.default {{zone}}/{{name}}
$ terraform import google_compute_node_group.default {{name}}

User Project Overrides

This resource supports User Project Overrides.