@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
283 lines • 13 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KubernetesCluster = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Provides a DigitalOcean Kubernetes cluster resource. This can be used to create, delete, and modify clusters. For more information see the [official documentation](https://www.digitalocean.com/docs/kubernetes/).
*
* ## 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: "latest",
* nodePool: {
* name: "worker-pool",
* size: "s-2vcpu-2gb",
* nodeCount: 3,
* 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 foo = new digitalocean.KubernetesCluster("foo", {
* name: "foo",
* region: digitalocean.Region.NYC1,
* version: "1.22.8-do.1",
* nodePool: {
* name: "autoscale-worker-pool",
* size: "s-2vcpu-2gb",
* autoScale: true,
* minNodes: 1,
* maxNodes: 5,
* },
* });
* ```
*
* Note that, currently, each node pool must always have at least one node and when using autoscaling the minNodes must be greater than or equal to 1.
* > Autoscaling to zero (`min_nodes=0`) is in [private preview](https://docs.digitalocean.com/release-notes/kubernetes/#2025-01-07) and not available for public use.
*
* ### Auto Upgrade Example
*
* DigitalOcean Kubernetes clusters may also be configured to [auto upgrade](https://www.digitalocean.com/docs/kubernetes/how-to/upgrade-cluster/#automatically) patch versions. You may explicitly specify the maintenance window policy.
* For example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const example = digitalocean.getKubernetesVersions({
* versionPrefix: "1.22.",
* });
* const foo = new digitalocean.KubernetesCluster("foo", {
* name: "foo",
* region: digitalocean.Region.NYC1,
* autoUpgrade: true,
* version: example.then(example => example.latestVersion),
* maintenancePolicy: {
* startTime: "04:00",
* day: "sunday",
* },
* nodePool: {
* name: "default",
* size: "s-1vcpu-2gb",
* nodeCount: 3,
* },
* });
* ```
*
* Note that a data source is used to supply the version. This is needed to prevent configuration diff whenever a cluster is upgraded.
*
* ### Kubernetes Terraform Provider Example
*
* The cluster's kubeconfig is exported as an attribute allowing you to use it with
* the Kubernetes Terraform provider.
*
* > When using interpolation to pass credentials from a `digitalocean.KubernetesCluster`
* resource to the Kubernetes provider, the cluster resource generally should not
* be created in the same Terraform module where Kubernetes provider resources are
* also used. This can lead to unpredictable errors which are hard to debug and
* diagnose. The root issue lies with the order in which Terraform itself evaluates
* the provider blocks vs. actual resources.
*
* When using the Kubernetes provider with a cluster created in a separate Terraform
* module or configuration, use the `digitalocean.KubernetesCluster` data-source
* to access the cluster's credentials. See here for a full example.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const example = digitalocean.getKubernetesCluster({
* name: "prod-cluster-01",
* });
* ```
*
* ### Exec credential plugin
*
* Another method to ensure that the Kubernetes provider is receiving valid credentials
* is to use an exec plugin. In order to use use this approach, the DigitalOcean
* CLI (`doctl`) must be present. `doctl` will renew the token if needed before
* initializing the provider.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* ```
*
* ## Import
*
* Before importing a Kubernetes cluster, the cluster's default node pool must be tagged with
* the `terraform:default-node-pool` tag. The provider will automatically add this tag if
* the cluster only has a single node pool. Clusters with more than one node pool, however, will require
* that you manually add the `terraform:default-node-pool` tag to the node pool that you intend to be
* the default node pool.
*
* Then the Kubernetes cluster and its default node pool can be imported using the cluster's `id`, e.g.
*
* ```sh
* $ pulumi import digitalocean:index/kubernetesCluster:KubernetesCluster mycluster 1b8b2100-0e9f-4e8f-ad78-9eb578c2a0af
* ```
*
* Additional node pools must be imported separately as `digitalocean.KubernetesCluster`
* resources, e.g.
*
* ```sh
* $ pulumi import digitalocean:index/kubernetesCluster:KubernetesCluster mynodepool 9d76f410-9284-4436-9633-4066852442c8
* ```
*/
class KubernetesCluster extends pulumi.CustomResource {
/**
* Get an existing KubernetesCluster resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new KubernetesCluster(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'digitalocean:index/kubernetesCluster:KubernetesCluster';
/**
* Returns true if the given object is an instance of KubernetesCluster. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === KubernetesCluster.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["amdGpuDeviceMetricsExporterPlugin"] = state?.amdGpuDeviceMetricsExporterPlugin;
resourceInputs["amdGpuDevicePlugin"] = state?.amdGpuDevicePlugin;
resourceInputs["autoUpgrade"] = state?.autoUpgrade;
resourceInputs["clusterAutoscalerConfigurations"] = state?.clusterAutoscalerConfigurations;
resourceInputs["clusterSubnet"] = state?.clusterSubnet;
resourceInputs["clusterUrn"] = state?.clusterUrn;
resourceInputs["controlPlaneFirewall"] = state?.controlPlaneFirewall;
resourceInputs["createdAt"] = state?.createdAt;
resourceInputs["destroyAllAssociatedResources"] = state?.destroyAllAssociatedResources;
resourceInputs["endpoint"] = state?.endpoint;
resourceInputs["ha"] = state?.ha;
resourceInputs["ipv4Address"] = state?.ipv4Address;
resourceInputs["kubeConfigs"] = state?.kubeConfigs;
resourceInputs["kubeconfigExpireSeconds"] = state?.kubeconfigExpireSeconds;
resourceInputs["maintenancePolicy"] = state?.maintenancePolicy;
resourceInputs["name"] = state?.name;
resourceInputs["nodePool"] = state?.nodePool;
resourceInputs["nvidiaGpuDevicePlugin"] = state?.nvidiaGpuDevicePlugin;
resourceInputs["rdmaSharedDevicePlugin"] = state?.rdmaSharedDevicePlugin;
resourceInputs["region"] = state?.region;
resourceInputs["registryIntegration"] = state?.registryIntegration;
resourceInputs["routingAgent"] = state?.routingAgent;
resourceInputs["serviceSubnet"] = state?.serviceSubnet;
resourceInputs["ssos"] = state?.ssos;
resourceInputs["status"] = state?.status;
resourceInputs["surgeUpgrade"] = state?.surgeUpgrade;
resourceInputs["tags"] = state?.tags;
resourceInputs["updatedAt"] = state?.updatedAt;
resourceInputs["version"] = state?.version;
resourceInputs["vpcUuid"] = state?.vpcUuid;
}
else {
const args = argsOrState;
if (args?.nodePool === undefined && !opts.urn) {
throw new Error("Missing required property 'nodePool'");
}
if (args?.region === undefined && !opts.urn) {
throw new Error("Missing required property 'region'");
}
if (args?.version === undefined && !opts.urn) {
throw new Error("Missing required property 'version'");
}
resourceInputs["amdGpuDeviceMetricsExporterPlugin"] = args?.amdGpuDeviceMetricsExporterPlugin;
resourceInputs["amdGpuDevicePlugin"] = args?.amdGpuDevicePlugin;
resourceInputs["autoUpgrade"] = args?.autoUpgrade;
resourceInputs["clusterAutoscalerConfigurations"] = args?.clusterAutoscalerConfigurations;
resourceInputs["clusterSubnet"] = args?.clusterSubnet;
resourceInputs["controlPlaneFirewall"] = args?.controlPlaneFirewall;
resourceInputs["destroyAllAssociatedResources"] = args?.destroyAllAssociatedResources;
resourceInputs["ha"] = args?.ha;
resourceInputs["kubeconfigExpireSeconds"] = args?.kubeconfigExpireSeconds;
resourceInputs["maintenancePolicy"] = args?.maintenancePolicy;
resourceInputs["name"] = args?.name;
resourceInputs["nodePool"] = args?.nodePool;
resourceInputs["nvidiaGpuDevicePlugin"] = args?.nvidiaGpuDevicePlugin;
resourceInputs["rdmaSharedDevicePlugin"] = args?.rdmaSharedDevicePlugin;
resourceInputs["region"] = args?.region;
resourceInputs["registryIntegration"] = args?.registryIntegration;
resourceInputs["routingAgent"] = args?.routingAgent;
resourceInputs["serviceSubnet"] = args?.serviceSubnet;
resourceInputs["ssos"] = args?.ssos;
resourceInputs["surgeUpgrade"] = args?.surgeUpgrade;
resourceInputs["tags"] = args?.tags;
resourceInputs["version"] = args?.version;
resourceInputs["vpcUuid"] = args?.vpcUuid;
resourceInputs["clusterUrn"] = undefined /*out*/;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["endpoint"] = undefined /*out*/;
resourceInputs["ipv4Address"] = undefined /*out*/;
resourceInputs["kubeConfigs"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["updatedAt"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["kubeConfigs"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(KubernetesCluster.__pulumiType, name, resourceInputs, opts);
}
}
exports.KubernetesCluster = KubernetesCluster;
//# sourceMappingURL=kubernetesCluster.js.map