NodePoolArgs

data class NodePoolArgs(val autoscaling: Output<NodePoolAutoscalingArgs>? = null, val cluster: Output<String>? = null, val initialNodeCount: Output<Int>? = null, val location: Output<String>? = null, val management: Output<NodePoolManagementArgs>? = null, val maxPodsPerNode: Output<Int>? = null, val name: Output<String>? = null, val namePrefix: Output<String>? = null, val networkConfig: Output<NodePoolNetworkConfigArgs>? = null, val nodeConfig: Output<NodePoolNodeConfigArgs>? = null, val nodeCount: Output<Int>? = null, val nodeLocations: Output<List<String>>? = null, val placementPolicy: Output<NodePoolPlacementPolicyArgs>? = null, val project: Output<String>? = null, val queuedProvisioning: Output<NodePoolQueuedProvisioningArgs>? = null, val upgradeSettings: Output<NodePoolUpgradeSettingsArgs>? = null, val version: Output<String>? = null) : ConvertibleToJava<NodePoolArgs>

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.

Example Usage

Using A Separately Managed Node Pool (Recommended)

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.serviceaccount.Account("default", {
accountId: "service-account-id",
displayName: "Service Account",
});
const primary = new gcp.container.Cluster("primary", {
name: "my-gke-cluster",
location: "us-central1",
removeDefaultNodePool: true,
initialNodeCount: 1,
});
const primaryPreemptibleNodes = new gcp.container.NodePool("primary_preemptible_nodes", {
name: "my-node-pool",
cluster: primary.id,
nodeCount: 1,
nodeConfig: {
preemptible: true,
machineType: "e2-medium",
serviceAccount: _default.email,
oauthScopes: ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
},
});
import pulumi
import pulumi_gcp as gcp
default = gcp.serviceaccount.Account("default",
account_id="service-account-id",
display_name="Service Account")
primary = gcp.container.Cluster("primary",
name="my-gke-cluster",
location="us-central1",
remove_default_node_pool=True,
initial_node_count=1)
primary_preemptible_nodes = gcp.container.NodePool("primary_preemptible_nodes",
name="my-node-pool",
cluster=primary.id,
node_count=1,
node_config={
"preemptible": True,
"machine_type": "e2-medium",
"service_account": default.email,
"oauth_scopes": ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = new Gcp.ServiceAccount.Account("default", new()
{
AccountId = "service-account-id",
DisplayName = "Service Account",
});
var primary = new Gcp.Container.Cluster("primary", new()
{
Name = "my-gke-cluster",
Location = "us-central1",
RemoveDefaultNodePool = true,
InitialNodeCount = 1,
});
var primaryPreemptibleNodes = new Gcp.Container.NodePool("primary_preemptible_nodes", new()
{
Name = "my-node-pool",
Cluster = primary.Id,
NodeCount = 1,
NodeConfig = new Gcp.Container.Inputs.NodePoolNodeConfigArgs
{
Preemptible = true,
MachineType = "e2-medium",
ServiceAccount = @default.Email,
OauthScopes = new[]
{
"https://www.googleapis.com/auth/cloud-platform",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/container"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/serviceaccount"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := serviceaccount.NewAccount(ctx, "default", &serviceaccount.AccountArgs{
AccountId: pulumi.String("service-account-id"),
DisplayName: pulumi.String("Service Account"),
})
if err != nil {
return err
}
primary, err := container.NewCluster(ctx, "primary", &container.ClusterArgs{
Name: pulumi.String("my-gke-cluster"),
Location: pulumi.String("us-central1"),
RemoveDefaultNodePool: pulumi.Bool(true),
InitialNodeCount: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = container.NewNodePool(ctx, "primary_preemptible_nodes", &container.NodePoolArgs{
Name: pulumi.String("my-node-pool"),
Cluster: primary.ID(),
NodeCount: pulumi.Int(1),
NodeConfig: &container.NodePoolNodeConfigArgs{
Preemptible: pulumi.Bool(true),
MachineType: pulumi.String("e2-medium"),
ServiceAccount: _default.Email,
OauthScopes: pulumi.StringArray{
pulumi.String("https://www.googleapis.com/auth/cloud-platform"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceaccount.Account;
import com.pulumi.gcp.serviceaccount.AccountArgs;
import com.pulumi.gcp.container.Cluster;
import com.pulumi.gcp.container.ClusterArgs;
import com.pulumi.gcp.container.NodePool;
import com.pulumi.gcp.container.NodePoolArgs;
import com.pulumi.gcp.container.inputs.NodePoolNodeConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Account("default", AccountArgs.builder()
.accountId("service-account-id")
.displayName("Service Account")
.build());
var primary = new Cluster("primary", ClusterArgs.builder()
.name("my-gke-cluster")
.location("us-central1")
.removeDefaultNodePool(true)
.initialNodeCount(1)
.build());
var primaryPreemptibleNodes = new NodePool("primaryPreemptibleNodes", NodePoolArgs.builder()
.name("my-node-pool")
.cluster(primary.id())
.nodeCount(1)
.nodeConfig(NodePoolNodeConfigArgs.builder()
.preemptible(true)
.machineType("e2-medium")
.serviceAccount(default_.email())
.oauthScopes("https://www.googleapis.com/auth/cloud-platform")
.build())
.build());
}
}
resources:
default:
type: gcp:serviceaccount:Account
properties:
accountId: service-account-id
displayName: Service Account
primary:
type: gcp:container:Cluster
properties:
name: my-gke-cluster
location: us-central1
removeDefaultNodePool: true
initialNodeCount: 1
primaryPreemptibleNodes:
type: gcp:container:NodePool
name: primary_preemptible_nodes
properties:
name: my-node-pool
cluster: ${primary.id}
nodeCount: 1
nodeConfig:
preemptible: true
machineType: e2-medium
serviceAccount: ${default.email}
oauthScopes:
- https://www.googleapis.com/auth/cloud-platform

2 Node Pools, 1 Separately Managed + The Default Node Pool

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.serviceaccount.Account("default", {
accountId: "service-account-id",
displayName: "Service Account",
});
const primary = new gcp.container.Cluster("primary", {
name: "marcellus-wallace",
location: "us-central1-a",
initialNodeCount: 3,
nodeLocations: ["us-central1-c"],
nodeConfig: {
serviceAccount: _default.email,
oauthScopes: ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
guestAccelerators: [{
type: "nvidia-tesla-k80",
count: 1,
}],
},
});
const np = new gcp.container.NodePool("np", {
name: "my-node-pool",
cluster: primary.id,
nodeConfig: {
machineType: "e2-medium",
serviceAccount: _default.email,
oauthScopes: ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
},
});
import pulumi
import pulumi_gcp as gcp
default = gcp.serviceaccount.Account("default",
account_id="service-account-id",
display_name="Service Account")
primary = gcp.container.Cluster("primary",
name="marcellus-wallace",
location="us-central1-a",
initial_node_count=3,
node_locations=["us-central1-c"],
node_config={
"service_account": default.email,
"oauth_scopes": ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
"guest_accelerators": [{
"type": "nvidia-tesla-k80",
"count": 1,
}],
})
np = gcp.container.NodePool("np",
name="my-node-pool",
cluster=primary.id,
node_config={
"machine_type": "e2-medium",
"service_account": default.email,
"oauth_scopes": ["https://www&#46;googleapis&#46;com/auth/cloud-platform"],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = new Gcp.ServiceAccount.Account("default", new()
{
AccountId = "service-account-id",
DisplayName = "Service Account",
});
var primary = new Gcp.Container.Cluster("primary", new()
{
Name = "marcellus-wallace",
Location = "us-central1-a",
InitialNodeCount = 3,
NodeLocations = new[]
{
"us-central1-c",
},
NodeConfig = new Gcp.Container.Inputs.ClusterNodeConfigArgs
{
ServiceAccount = @default.Email,
OauthScopes = new[]
{
"https://www.googleapis.com/auth/cloud-platform",
},
GuestAccelerators = new[]
{
new Gcp.Container.Inputs.ClusterNodeConfigGuestAcceleratorArgs
{
Type = "nvidia-tesla-k80",
Count = 1,
},
},
},
});
var np = new Gcp.Container.NodePool("np", new()
{
Name = "my-node-pool",
Cluster = primary.Id,
NodeConfig = new Gcp.Container.Inputs.NodePoolNodeConfigArgs
{
MachineType = "e2-medium",
ServiceAccount = @default.Email,
OauthScopes = new[]
{
"https://www.googleapis.com/auth/cloud-platform",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/container"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/serviceaccount"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := serviceaccount.NewAccount(ctx, "default", &serviceaccount.AccountArgs{
AccountId: pulumi.String("service-account-id"),
DisplayName: pulumi.String("Service Account"),
})
if err != nil {
return err
}
primary, err := container.NewCluster(ctx, "primary", &container.ClusterArgs{
Name: pulumi.String("marcellus-wallace"),
Location: pulumi.String("us-central1-a"),
InitialNodeCount: pulumi.Int(3),
NodeLocations: pulumi.StringArray{
pulumi.String("us-central1-c"),
},
NodeConfig: &container.ClusterNodeConfigArgs{
ServiceAccount: _default.Email,
OauthScopes: pulumi.StringArray{
pulumi.String("https://www.googleapis.com/auth/cloud-platform"),
},
GuestAccelerators: container.ClusterNodeConfigGuestAcceleratorArray{
&container.ClusterNodeConfigGuestAcceleratorArgs{
Type: pulumi.String("nvidia-tesla-k80"),
Count: pulumi.Int(1),
},
},
},
})
if err != nil {
return err
}
_, err = container.NewNodePool(ctx, "np", &container.NodePoolArgs{
Name: pulumi.String("my-node-pool"),
Cluster: primary.ID(),
NodeConfig: &container.NodePoolNodeConfigArgs{
MachineType: pulumi.String("e2-medium"),
ServiceAccount: _default.Email,
OauthScopes: pulumi.StringArray{
pulumi.String("https://www.googleapis.com/auth/cloud-platform"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceaccount.Account;
import com.pulumi.gcp.serviceaccount.AccountArgs;
import com.pulumi.gcp.container.Cluster;
import com.pulumi.gcp.container.ClusterArgs;
import com.pulumi.gcp.container.inputs.ClusterNodeConfigArgs;
import com.pulumi.gcp.container.NodePool;
import com.pulumi.gcp.container.NodePoolArgs;
import com.pulumi.gcp.container.inputs.NodePoolNodeConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Account("default", AccountArgs.builder()
.accountId("service-account-id")
.displayName("Service Account")
.build());
var primary = new Cluster("primary", ClusterArgs.builder()
.name("marcellus-wallace")
.location("us-central1-a")
.initialNodeCount(3)
.nodeLocations("us-central1-c")
.nodeConfig(ClusterNodeConfigArgs.builder()
.serviceAccount(default_.email())
.oauthScopes("https://www.googleapis.com/auth/cloud-platform")
.guestAccelerators(ClusterNodeConfigGuestAcceleratorArgs.builder()
.type("nvidia-tesla-k80")
.count(1)
.build())
.build())
.build());
var np = new NodePool("np", NodePoolArgs.builder()
.name("my-node-pool")
.cluster(primary.id())
.nodeConfig(NodePoolNodeConfigArgs.builder()
.machineType("e2-medium")
.serviceAccount(default_.email())
.oauthScopes("https://www.googleapis.com/auth/cloud-platform")
.build())
.build());
}
}
resources:
default:
type: gcp:serviceaccount:Account
properties:
accountId: service-account-id
displayName: Service Account
np:
type: gcp:container:NodePool
properties:
name: my-node-pool
cluster: ${primary.id}
nodeConfig:
machineType: e2-medium
serviceAccount: ${default.email}
oauthScopes:
- https://www.googleapis.com/auth/cloud-platform
primary:
type: gcp:container:Cluster
properties:
name: marcellus-wallace
location: us-central1-a
initialNodeCount: 3
nodeLocations:
- us-central1-c
nodeConfig:
serviceAccount: ${default.email}
oauthScopes:
- https://www.googleapis.com/auth/cloud-platform
guestAccelerators:
- type: nvidia-tesla-k80
count: 1

Import

Node pools can be imported using the project, location, cluster and name. If the project is omitted, the project value in the provider configuration will be used. Examples:

  • {{project_id}}/{{location}}/{{cluster_id}}/{{pool_id}}

  • {{location}}/{{cluster_id}}/{{pool_id}} When using the pulumi import command, node pools can be imported using one of the formats above. For example:

$ pulumi import gcp:container/nodePool:NodePool default {{project_id}}/{{location}}/{{cluster_id}}/{{pool_id}}
$ pulumi import gcp:container/nodePool:NodePool default {{location}}/{{cluster_id}}/{{pool_id}}

Constructors

Link copied to clipboard
constructor(autoscaling: Output<NodePoolAutoscalingArgs>? = null, cluster: Output<String>? = null, initialNodeCount: Output<Int>? = null, location: Output<String>? = null, management: Output<NodePoolManagementArgs>? = null, maxPodsPerNode: Output<Int>? = null, name: Output<String>? = null, namePrefix: Output<String>? = null, networkConfig: Output<NodePoolNetworkConfigArgs>? = null, nodeConfig: Output<NodePoolNodeConfigArgs>? = null, nodeCount: Output<Int>? = null, nodeLocations: Output<List<String>>? = null, placementPolicy: Output<NodePoolPlacementPolicyArgs>? = null, project: Output<String>? = null, queuedProvisioning: Output<NodePoolQueuedProvisioningArgs>? = null, upgradeSettings: Output<NodePoolUpgradeSettingsArgs>? = null, version: Output<String>? = null)

Properties

Link copied to clipboard

Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage. Structure is documented below.

Link copied to clipboard
val cluster: Output<String>? = null

The cluster to create the node pool for. Cluster must be present in location provided for clusters. May be specified in the format projects/{{project}}/locations/{{location}}/clusters/{{cluster}} or as just the name of the cluster.

Link copied to clipboard
val initialNodeCount: Output<Int>? = null

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. WARNING: Resizing your node pool manually may change this value in your existing cluster, which will trigger destruction and recreation on the next provider run (to rectify the discrepancy). If you don't need this value, don't set it. If you do need it, you can use a lifecycle block to ignore subsqeuent changes to this field.

Link copied to clipboard
val location: Output<String>? = null

The location (region or zone) of the cluster.

Link copied to clipboard
val management: Output<NodePoolManagementArgs>? = null

Node management configuration, wherein auto-repair and auto-upgrade is configured. Structure is documented below.

Link copied to clipboard
val maxPodsPerNode: Output<Int>? = null

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. See the official documentation for more information.

Link copied to clipboard
val name: Output<String>? = null

The name of the node pool. If left blank, the provider will auto-generate a unique name.

Link copied to clipboard
val namePrefix: Output<String>? = null

Creates a unique name for the node pool beginning with the specified prefix. Conflicts with name.

Link copied to clipboard

The network configuration of the pool. Such as configuration for Adding Pod IP address ranges) to the node pool. Or enabling private nodes. Structure is documented below

Link copied to clipboard
val nodeConfig: Output<NodePoolNodeConfigArgs>? = null

Parameters used in creating the node pool. See gcp.container.Cluster for schema.

Link copied to clipboard
val nodeCount: Output<Int>? = null

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.

Link copied to clipboard
val nodeLocations: Output<List<String>>? = null

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.

Link copied to clipboard

Specifies a custom placement policy for the nodes.

Link copied to clipboard
val project: Output<String>? = null

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

Link copied to clipboard

Specifies node pool-level settings of queued provisioning. Structure is documented below.

Link copied to clipboard

Specify node upgrade settings to change how GKE upgrades nodes. The maximum number of nodes upgraded simultaneously is limited to 20. Structure is documented below.

Link copied to clipboard
val version: Output<String>? = null

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 the provider will see spurious diffs when fuzzy versions are used. See the gcp.container.getEngineVersions data source's version_prefix field to approximate fuzzy versions in a provider-compatible way.

Functions

Link copied to clipboard
open override fun toJava(): NodePoolArgs