Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.digitalocean.kotlin.KubernetesNodePool.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.digitalocean.kotlin
import com.pulumi.core.Output
import com.pulumi.digitalocean.kotlin.outputs.KubernetesNodePoolNode
import com.pulumi.digitalocean.kotlin.outputs.KubernetesNodePoolTaint
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.digitalocean.kotlin.outputs.KubernetesNodePoolNode.Companion.toKotlin as kubernetesNodePoolNodeToKotlin
import com.pulumi.digitalocean.kotlin.outputs.KubernetesNodePoolTaint.Companion.toKotlin as kubernetesNodePoolTaintToKotlin
/**
* Builder for [KubernetesNodePool].
*/
@PulumiTagMarker
public class KubernetesNodePoolResourceBuilder internal constructor() {
public var name: String? = null
public var args: KubernetesNodePoolArgs = KubernetesNodePoolArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend KubernetesNodePoolArgsBuilder.() -> Unit) {
val builder = KubernetesNodePoolArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): KubernetesNodePool {
val builtJavaResource = com.pulumi.digitalocean.KubernetesNodePool(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return KubernetesNodePool(builtJavaResource)
}
}
/**
* Provides a DigitalOcean Kubernetes node pool resource. While the default node pool must be defined in the `digitalocean.KubernetesCluster` resource, this resource can be used to add additional ones to a cluster.
* ## Example Usage
* ### Basic Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* const foo = new digitalocean.KubernetesCluster("foo", {
* name: "foo",
* region: digitalocean.Region.NYC1,
* version: "1.22.8-do.1",
* nodePool: {
* name: "front-end-pool",
* size: "s-2vcpu-2gb",
* nodeCount: 3,
* },
* });
* const bar = new digitalocean.KubernetesNodePool("bar", {
* clusterId: foo.id,
* name: "backend-pool",
* size: digitalocean.DropletSlug.DropletC2,
* nodeCount: 2,
* tags: ["backend"],
* labels: {
* service: "backend",
* priority: "high",
* },
* taints: [{
* key: "workloadKind",
* value: "database",
* effect: "NoSchedule",
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* foo = digitalocean.KubernetesCluster("foo",
* name="foo",
* region=digitalocean.Region.NYC1,
* version="1.22.8-do.1",
* node_pool={
* "name": "front-end-pool",
* "size": "s-2vcpu-2gb",
* "node_count": 3,
* })
* bar = digitalocean.KubernetesNodePool("bar",
* cluster_id=foo.id,
* name="backend-pool",
* size=digitalocean.DropletSlug.DROPLET_C2,
* node_count=2,
* tags=["backend"],
* labels={
* "service": "backend",
* "priority": "high",
* },
* taints=[{
* "key": "workloadKind",
* "value": "database",
* "effect": "NoSchedule",
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* return await Deployment.RunAsync(() =>
* {
* var foo = new DigitalOcean.KubernetesCluster("foo", new()
* {
* Name = "foo",
* Region = DigitalOcean.Region.NYC1,
* Version = "1.22.8-do.1",
* NodePool = new DigitalOcean.Inputs.KubernetesClusterNodePoolArgs
* {
* Name = "front-end-pool",
* Size = "s-2vcpu-2gb",
* NodeCount = 3,
* },
* });
* var bar = new DigitalOcean.KubernetesNodePool("bar", new()
* {
* ClusterId = foo.Id,
* Name = "backend-pool",
* Size = DigitalOcean.DropletSlug.DropletC2,
* NodeCount = 2,
* Tags = new[]
* {
* "backend",
* },
* Labels =
* {
* { "service", "backend" },
* { "priority", "high" },
* },
* Taints = new[]
* {
* new DigitalOcean.Inputs.KubernetesNodePoolTaintArgs
* {
* Key = "workloadKind",
* Value = "database",
* Effect = "NoSchedule",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* foo, err := digitalocean.NewKubernetesCluster(ctx, "foo", &digitalocean.KubernetesClusterArgs{
* Name: pulumi.String("foo"),
* Region: pulumi.String(digitalocean.RegionNYC1),
* Version: pulumi.String("1.22.8-do.1"),
* NodePool: &digitalocean.KubernetesClusterNodePoolArgs{
* Name: pulumi.String("front-end-pool"),
* Size: pulumi.String("s-2vcpu-2gb"),
* NodeCount: pulumi.Int(3),
* },
* })
* if err != nil {
* return err
* }
* _, err = digitalocean.NewKubernetesNodePool(ctx, "bar", &digitalocean.KubernetesNodePoolArgs{
* ClusterId: foo.ID(),
* Name: pulumi.String("backend-pool"),
* Size: pulumi.String(digitalocean.DropletSlugDropletC2),
* NodeCount: pulumi.Int(2),
* Tags: pulumi.StringArray{
* pulumi.String("backend"),
* },
* Labels: pulumi.StringMap{
* "service": pulumi.String("backend"),
* "priority": pulumi.String("high"),
* },
* Taints: digitalocean.KubernetesNodePoolTaintArray{
* &digitalocean.KubernetesNodePoolTaintArgs{
* Key: pulumi.String("workloadKind"),
* Value: pulumi.String("database"),
* Effect: pulumi.String("NoSchedule"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.digitalocean.KubernetesCluster;
* import com.pulumi.digitalocean.KubernetesClusterArgs;
* import com.pulumi.digitalocean.inputs.KubernetesClusterNodePoolArgs;
* import com.pulumi.digitalocean.KubernetesNodePool;
* import com.pulumi.digitalocean.KubernetesNodePoolArgs;
* import com.pulumi.digitalocean.inputs.KubernetesNodePoolTaintArgs;
* 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 foo = new KubernetesCluster("foo", KubernetesClusterArgs.builder()
* .name("foo")
* .region("nyc1")
* .version("1.22.8-do.1")
* .nodePool(KubernetesClusterNodePoolArgs.builder()
* .name("front-end-pool")
* .size("s-2vcpu-2gb")
* .nodeCount(3)
* .build())
* .build());
* var bar = new KubernetesNodePool("bar", KubernetesNodePoolArgs.builder()
* .clusterId(foo.id())
* .name("backend-pool")
* .size("c-2")
* .nodeCount(2)
* .tags("backend")
* .labels(Map.ofEntries(
* Map.entry("service", "backend"),
* Map.entry("priority", "high")
* ))
* .taints(KubernetesNodePoolTaintArgs.builder()
* .key("workloadKind")
* .value("database")
* .effect("NoSchedule")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* foo:
* type: digitalocean:KubernetesCluster
* properties:
* name: foo
* region: nyc1
* version: 1.22.8-do.1
* nodePool:
* name: front-end-pool
* size: s-2vcpu-2gb
* nodeCount: 3
* bar:
* type: digitalocean:KubernetesNodePool
* properties:
* clusterId: ${foo.id}
* name: backend-pool
* size: c-2
* nodeCount: 2
* tags:
* - backend
* labels:
* service: backend
* priority: high
* taints:
* - key: workloadKind
* value: database
* effect: NoSchedule
* ```
*
* ### Autoscaling Example
* Node pools may also be configured to [autoscale](https://www.digitalocean.com/docs/kubernetes/how-to/autoscale/).
* For example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* const autoscale_pool_01 = new digitalocean.KubernetesNodePool("autoscale-pool-01", {
* clusterId: foo.id,
* name: "autoscale-pool-01",
* size: digitalocean.DropletSlug.DropletS1VCPU2GB,
* autoScale: true,
* minNodes: 1,
* maxNodes: 5,
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* autoscale_pool_01 = digitalocean.KubernetesNodePool("autoscale-pool-01",
* cluster_id=foo["id"],
* name="autoscale-pool-01",
* size=digitalocean.DropletSlug.DROPLET_S1_VCPU2_GB,
* auto_scale=True,
* min_nodes=1,
* max_nodes=5)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* return await Deployment.RunAsync(() =>
* {
* var autoscale_pool_01 = new DigitalOcean.KubernetesNodePool("autoscale-pool-01", new()
* {
* ClusterId = foo.Id,
* Name = "autoscale-pool-01",
* Size = DigitalOcean.DropletSlug.DropletS1VCPU2GB,
* AutoScale = true,
* MinNodes = 1,
* MaxNodes = 5,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := digitalocean.NewKubernetesNodePool(ctx, "autoscale-pool-01", &digitalocean.KubernetesNodePoolArgs{
* ClusterId: pulumi.Any(foo.Id),
* Name: pulumi.String("autoscale-pool-01"),
* Size: pulumi.String(digitalocean.DropletSlugDropletS1VCPU2GB),
* AutoScale: pulumi.Bool(true),
* MinNodes: pulumi.Int(1),
* MaxNodes: pulumi.Int(5),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.digitalocean.KubernetesNodePool;
* import com.pulumi.digitalocean.KubernetesNodePoolArgs;
* 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 autoscale_pool_01 = new KubernetesNodePool("autoscale-pool-01", KubernetesNodePoolArgs.builder()
* .clusterId(foo.id())
* .name("autoscale-pool-01")
* .size("s-1vcpu-2gb")
* .autoScale(true)
* .minNodes(1)
* .maxNodes(5)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* autoscale-pool-01:
* type: digitalocean:KubernetesNodePool
* properties:
* clusterId: ${foo.id}
* name: autoscale-pool-01
* size: s-1vcpu-2gb
* autoScale: true
* minNodes: 1
* maxNodes: 5
* ```
*
* ## Import
* If you are importing an existing Kubernetes cluster with a single node pool, just
* import the cluster. Additional node pools can be imported by using their `id`, e.g.
* ```sh
* $ pulumi import digitalocean:index/kubernetesNodePool:KubernetesNodePool mynodepool 9d76f410-9284-4436-9633-4066852442c8
* ```
* Note: If the node pool has the `terraform:default-node-pool` tag, then it is a default node pool for an
* existing cluster. The provider will refuse to import the node pool in that case because the node pool
* is managed by the `digitalocean_kubernetes_cluster` resource and not by this
* `digitalocean_kubernetes_node_pool` resource.
*/
public class KubernetesNodePool internal constructor(
override val javaResource: com.pulumi.digitalocean.KubernetesNodePool,
) : KotlinCustomResource(javaResource, KubernetesNodePoolMapper) {
/**
* A computed field representing the actual number of nodes in the node pool, which is especially useful when auto-scaling is enabled.
*/
public val actualNodeCount: Output
get() = javaResource.actualNodeCount().applyValue({ args0 -> args0 })
/**
* Enable auto-scaling of the number of nodes in the node pool within the given min/max range.
*/
public val autoScale: Output?
get() = javaResource.autoScale().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The ID of the Kubernetes cluster to which the node pool is associated.
*/
public val clusterId: Output
get() = javaResource.clusterId().applyValue({ args0 -> args0 })
/**
* A map of key/value pairs to apply to nodes in the pool. The labels are exposed in the Kubernetes API as labels in the metadata of the corresponding [Node resources](https://kubernetes.io/docs/concepts/architecture/nodes/).
*/
public val labels: Output>?
get() = javaResource.labels().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}).orElse(null)
})
/**
* If auto-scaling is enabled, this represents the maximum number of nodes that the node pool can be scaled up to.
*/
public val maxNodes: Output?
get() = javaResource.maxNodes().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* If auto-scaling is enabled, this represents the minimum number of nodes that the node pool can be scaled down to.
*/
public val minNodes: Output?
get() = javaResource.minNodes().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* A name for the node pool.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The number of Droplet instances in the node pool. If auto-scaling is enabled, this should only be set if the desired result is to explicitly reset the number of nodes to this value. If auto-scaling is enabled, and the node count is outside of the given min/max range, it will use the min nodes value.
*/
public val nodeCount: Output?
get() = javaResource.nodeCount().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* A list of nodes in the pool. Each node exports the following attributes:
*/
public val nodes: Output>
get() = javaResource.nodes().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
kubernetesNodePoolNodeToKotlin(args0)
})
})
})
/**
* The slug identifier for the type of Droplet to be used as workers in the node pool.
*/
public val size: Output
get() = javaResource.size().applyValue({ args0 -> args0 })
/**
* A list of tag names to be applied to the Kubernetes cluster.
*/
public val tags: Output>?
get() = javaResource.tags().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0
})
}).orElse(null)
})
/**
* A list of taints applied to all nodes in the pool.
* This resource supports customized create timeouts. The default timeout is 30 minutes.
*/
public val taints: Output>?
get() = javaResource.taints().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> kubernetesNodePoolTaintToKotlin(args0) })
})
}).orElse(null)
})
}
public object KubernetesNodePoolMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.digitalocean.KubernetesNodePool::class == javaResource::class
override fun map(javaResource: Resource): KubernetesNodePool = KubernetesNodePool(
javaResource as
com.pulumi.digitalocean.KubernetesNodePool,
)
}
/**
* @see [KubernetesNodePool].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [KubernetesNodePool].
*/
public suspend fun kubernetesNodePool(
name: String,
block: suspend KubernetesNodePoolResourceBuilder.() -> Unit,
): KubernetesNodePool {
val builder = KubernetesNodePoolResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [KubernetesNodePool].
* @param name The _unique_ name of the resulting resource.
*/
public fun kubernetesNodePool(name: String): KubernetesNodePool {
val builder = KubernetesNodePoolResourceBuilder()
builder.name(name)
return builder.build()
}