Class NodePool


  • public class NodePool
    extends com.pulumi.resources.CustomResource
    Manages a node pool in a Google Kubernetes Engine (GKE) cluster separately from the cluster control plane. For more information see [the official documentation](https://cloud.google.com/container-engine/docs/node-pools) and [the API reference](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters.nodePools). ## Example Usage ### Using A Separately Managed Node Pool (Recommended) ```java 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() .location("us-central1") .removeDefaultNodePool(true) .initialNodeCount(1) .build()); var primaryPreemptibleNodes = new NodePool("primaryPreemptibleNodes", NodePoolArgs.builder() .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()); } } ``` ### 2 Node Pools, 1 Separately Managed + The Default Node Pool ```java 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() .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() .cluster(primary.id()) .nodeConfig(NodePoolNodeConfigArgs.builder() .machineType("e2-medium") .serviceAccount(default_.email()) .oauthScopes("https://www.googleapis.com/auth/cloud-platform") .build()) .timeouts(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference)) .build()); } } ``` ## 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}}` In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import node pools using one of the formats above. For exampletf import { id = "{{project_id}}/{{location}}/{{cluster_id}}/{{pool_id}}" to = google_container_node_pool.default } ```sh $ pulumi import gcp:container/nodePool:NodePool When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), node pools can be imported using one of the formats above. For example ``` ```sh $ pulumi import gcp:container/nodePool:NodePool default {{project_id}}/{{location}}/{{cluster_id}}/{{pool_id}} ``` ```sh $ pulumi import gcp:container/nodePool:NodePool default {{location}}/{{cluster_id}}/{{pool_id}} ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      NodePool​(java.lang.String name)  
      NodePool​(java.lang.String name, NodePoolArgs args)  
      NodePool​(java.lang.String name, NodePoolArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Constructor Detail

      • NodePool

        public NodePool​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • NodePool

        public NodePool​(java.lang.String name,
                        NodePoolArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • NodePool

        public NodePool​(java.lang.String name,
                        NodePoolArgs args,
                        @Nullable
                        com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • autoscaling

        public com.pulumi.core.Output<java.util.Optional<NodePoolAutoscaling>> autoscaling()
        Returns:
        Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage. Structure is documented below.
      • cluster

        public com.pulumi.core.Output<java.lang.String> cluster()
        Returns:
        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. ***
      • initialNodeCount

        public com.pulumi.core.Output<java.lang.Integer> initialNodeCount()
        Returns:
        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.
      • instanceGroupUrls

        public com.pulumi.core.Output<java.util.List<java.lang.String>> instanceGroupUrls()
        Returns:
        The resource URLs of the managed instance groups associated with this node pool.
      • location

        public com.pulumi.core.Output<java.lang.String> location()
        Returns:
        The location (region or zone) of the cluster. ***
      • managedInstanceGroupUrls

        public com.pulumi.core.Output<java.util.List<java.lang.String>> managedInstanceGroupUrls()
        Returns:
        List of instance group URLs which have been assigned to this node pool.
      • management

        public com.pulumi.core.Output<NodePoolManagement> management()
        Returns:
        Node management configuration, wherein auto-repair and auto-upgrade is configured. Structure is documented below.
      • maxPodsPerNode

        public com.pulumi.core.Output<java.lang.Integer> maxPodsPerNode()
        Returns:
        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](https://cloud.google.com/kubernetes-engine/docs/how-to/flexible-pod-cidr) for more information.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        The name of the node pool. If left blank, the provider will auto-generate a unique name.
      • namePrefix

        public com.pulumi.core.Output<java.lang.String> namePrefix()
        Returns:
        Creates a unique name for the node pool beginning with the specified prefix. Conflicts with `name`.
      • networkConfig

        public com.pulumi.core.Output<NodePoolNetworkConfig> networkConfig()
        Returns:
        The network configuration of the pool. Such as configuration for [Adding Pod IP address ranges](https://cloud.google.com/kubernetes-engine/docs/how-to/multi-pod-cidr)) to the node pool. Or enabling private nodes. Structure is documented below
      • nodeConfig

        public com.pulumi.core.Output<NodePoolNodeConfig> nodeConfig()
        Returns:
        Parameters used in creating the node pool. See gcp.container.Cluster for schema.
      • nodeCount

        public com.pulumi.core.Output<java.lang.Integer> nodeCount()
        Returns:
        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`.
      • nodeLocations

        public com.pulumi.core.Output<java.util.List<java.lang.String>> nodeLocations()
        Returns:
        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. > Note: `node_locations` will not revert to the cluster's default set of zones upon being unset. You must manually reconcile the list of zones with your cluster.
      • operation

        public com.pulumi.core.Output<java.lang.String> operation()
      • placementPolicy

        public com.pulumi.core.Output<java.util.Optional<NodePoolPlacementPolicy>> placementPolicy()
        Returns:
        Specifies a custom placement policy for the nodes. <a name="nested_autoscaling"></a>The `autoscaling` block supports (either total or per zone limits are required):
      • project

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The ID of the project in which to create the node pool. If blank, the provider-configured project will be used.
      • upgradeSettings

        public com.pulumi.core.Output<NodePoolUpgradeSettings> upgradeSettings()
        Returns:
        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.
      • version

        public com.pulumi.core.Output<java.lang.String> version()
        Returns:
        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.
      • get

        public static NodePool get​(java.lang.String name,
                                   com.pulumi.core.Output<java.lang.String> id,
                                   @Nullable
                                   NodePoolState state,
                                   @Nullable
                                   com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.