DigitalOcean

v4.15.2 published on Friday, Sep 2, 2022 by Pulumi

getKubernetesVersions

Provides access to the available DigitalOcean Kubernetes Service versions.

Example Usage

Output a list of all available versions

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var example = DigitalOcean.GetKubernetesVersions.Invoke();

    return new Dictionary<string, object?>
    {
        ["k8s-versions"] = example.Apply(getKubernetesVersionsResult => getKubernetesVersionsResult.ValidVersions),
    };
});
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 {
		example, err := digitalocean.GetKubernetesVersions(ctx, nil, nil)
		if err != nil {
			return err
		}
		ctx.Export("k8s-versions", example.ValidVersions)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetKubernetesVersionsArgs;
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) {
        final var example = DigitaloceanFunctions.getKubernetesVersions();

        ctx.export("k8s-versions", example.applyValue(getKubernetesVersionsResult -> getKubernetesVersionsResult.validVersions()));
    }
}
import pulumi
import pulumi_digitalocean as digitalocean

example = digitalocean.get_kubernetes_versions()
pulumi.export("k8s-versions", example.valid_versions)
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

export = async () => {
    const example = await digitalocean.getKubernetesVersions({});
    const k8s_versions = example.validVersions;
    return {
        "k8s-versions": k8s_versions,
    };
}
variables:
  example:
    Fn::Invoke:
      Function: digitalocean:getKubernetesVersions
      Arguments: {}
outputs:
  k8s-versions: ${example.validVersions}

Create a Kubernetes cluster using the most recent version available

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var example = DigitalOcean.GetKubernetesVersions.Invoke();

    var example_cluster = new DigitalOcean.KubernetesCluster("example-cluster", new()
    {
        Region = "lon1",
        Version = example.Apply(getKubernetesVersionsResult => getKubernetesVersionsResult.LatestVersion),
        NodePool = new DigitalOcean.Inputs.KubernetesClusterNodePoolArgs
        {
            Name = "default",
            Size = "s-1vcpu-2gb",
            NodeCount = 3,
        },
    });

});
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 {
		example, err := digitalocean.GetKubernetesVersions(ctx, nil, nil)
		if err != nil {
			return err
		}
		_, err = digitalocean.NewKubernetesCluster(ctx, "example-cluster", &digitalocean.KubernetesClusterArgs{
			Region:  pulumi.String("lon1"),
			Version: pulumi.String(example.LatestVersion),
			NodePool: &KubernetesClusterNodePoolArgs{
				Name:      pulumi.String("default"),
				Size:      pulumi.String("s-1vcpu-2gb"),
				NodeCount: pulumi.Int(3),
			},
		})
		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.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetKubernetesVersionsArgs;
import com.pulumi.digitalocean.KubernetesCluster;
import com.pulumi.digitalocean.KubernetesClusterArgs;
import com.pulumi.digitalocean.inputs.KubernetesClusterNodePoolArgs;
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) {
        final var example = DigitaloceanFunctions.getKubernetesVersions();

        var example_cluster = new KubernetesCluster("example-cluster", KubernetesClusterArgs.builder()        
            .region("lon1")
            .version(example.applyValue(getKubernetesVersionsResult -> getKubernetesVersionsResult.latestVersion()))
            .nodePool(KubernetesClusterNodePoolArgs.builder()
                .name("default")
                .size("s-1vcpu-2gb")
                .nodeCount(3)
                .build())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

example = digitalocean.get_kubernetes_versions()
example_cluster = digitalocean.KubernetesCluster("example-cluster",
    region="lon1",
    version=example.latest_version,
    node_pool=digitalocean.KubernetesClusterNodePoolArgs(
        name="default",
        size="s-1vcpu-2gb",
        node_count=3,
    ))
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const example = digitalocean.getKubernetesVersions({});
const example_cluster = new digitalocean.KubernetesCluster("example-cluster", {
    region: "lon1",
    version: example.then(example => example.latestVersion),
    nodePool: {
        name: "default",
        size: "s-1vcpu-2gb",
        nodeCount: 3,
    },
});
resources:
  example-cluster:
    type: digitalocean:KubernetesCluster
    properties:
      region: lon1
      version: ${example.latestVersion}
      nodePool:
        name: default
        size: s-1vcpu-2gb
        nodeCount: 3
variables:
  example:
    Fn::Invoke:
      Function: digitalocean:getKubernetesVersions
      Arguments: {}

Pin a Kubernetes cluster to a specific minor version

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var example = DigitalOcean.GetKubernetesVersions.Invoke(new()
    {
        VersionPrefix = "1.22.",
    });

    var example_cluster = new DigitalOcean.KubernetesCluster("example-cluster", new()
    {
        Region = "lon1",
        Version = example.Apply(getKubernetesVersionsResult => getKubernetesVersionsResult.LatestVersion),
        NodePool = new DigitalOcean.Inputs.KubernetesClusterNodePoolArgs
        {
            Name = "default",
            Size = "s-1vcpu-2gb",
            NodeCount = 3,
        },
    });

});
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 {
		example, err := digitalocean.GetKubernetesVersions(ctx, &GetKubernetesVersionsArgs{
			VersionPrefix: pulumi.StringRef("1.22."),
		}, nil)
		if err != nil {
			return err
		}
		_, err = digitalocean.NewKubernetesCluster(ctx, "example-cluster", &digitalocean.KubernetesClusterArgs{
			Region:  pulumi.String("lon1"),
			Version: pulumi.String(example.LatestVersion),
			NodePool: &KubernetesClusterNodePoolArgs{
				Name:      pulumi.String("default"),
				Size:      pulumi.String("s-1vcpu-2gb"),
				NodeCount: pulumi.Int(3),
			},
		})
		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.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetKubernetesVersionsArgs;
import com.pulumi.digitalocean.KubernetesCluster;
import com.pulumi.digitalocean.KubernetesClusterArgs;
import com.pulumi.digitalocean.inputs.KubernetesClusterNodePoolArgs;
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) {
        final var example = DigitaloceanFunctions.getKubernetesVersions(GetKubernetesVersionsArgs.builder()
            .versionPrefix("1.22.")
            .build());

        var example_cluster = new KubernetesCluster("example-cluster", KubernetesClusterArgs.builder()        
            .region("lon1")
            .version(example.applyValue(getKubernetesVersionsResult -> getKubernetesVersionsResult.latestVersion()))
            .nodePool(KubernetesClusterNodePoolArgs.builder()
                .name("default")
                .size("s-1vcpu-2gb")
                .nodeCount(3)
                .build())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

example = digitalocean.get_kubernetes_versions(version_prefix="1.22.")
example_cluster = digitalocean.KubernetesCluster("example-cluster",
    region="lon1",
    version=example.latest_version,
    node_pool=digitalocean.KubernetesClusterNodePoolArgs(
        name="default",
        size="s-1vcpu-2gb",
        node_count=3,
    ))
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const example = digitalocean.getKubernetesVersions({
    versionPrefix: "1.22.",
});
const example_cluster = new digitalocean.KubernetesCluster("example-cluster", {
    region: "lon1",
    version: example.then(example => example.latestVersion),
    nodePool: {
        name: "default",
        size: "s-1vcpu-2gb",
        nodeCount: 3,
    },
});
resources:
  example-cluster:
    type: digitalocean:KubernetesCluster
    properties:
      region: lon1
      version: ${example.latestVersion}
      nodePool:
        name: default
        size: s-1vcpu-2gb
        nodeCount: 3
variables:
  example:
    Fn::Invoke:
      Function: digitalocean:getKubernetesVersions
      Arguments:
        versionPrefix: 1.22.

Using getKubernetesVersions

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getKubernetesVersions(args: GetKubernetesVersionsArgs, opts?: InvokeOptions): Promise<GetKubernetesVersionsResult>
function getKubernetesVersionsOutput(args: GetKubernetesVersionsOutputArgs, opts?: InvokeOptions): Output<GetKubernetesVersionsResult>
def get_kubernetes_versions(version_prefix: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetKubernetesVersionsResult
def get_kubernetes_versions_output(version_prefix: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetKubernetesVersionsResult]
func GetKubernetesVersions(ctx *Context, args *GetKubernetesVersionsArgs, opts ...InvokeOption) (*GetKubernetesVersionsResult, error)
func GetKubernetesVersionsOutput(ctx *Context, args *GetKubernetesVersionsOutputArgs, opts ...InvokeOption) GetKubernetesVersionsResultOutput

> Note: This function is named GetKubernetesVersions in the Go SDK.

public static class GetKubernetesVersions 
{
    public static Task<GetKubernetesVersionsResult> InvokeAsync(GetKubernetesVersionsArgs args, InvokeOptions? opts = null)
    public static Output<GetKubernetesVersionsResult> Invoke(GetKubernetesVersionsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetKubernetesVersionsResult> getKubernetesVersions(GetKubernetesVersionsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: digitalocean:index/getKubernetesVersions:getKubernetesVersions
  Arguments:
    # Arguments dictionary

The following arguments are supported:

VersionPrefix string

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

VersionPrefix string

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

versionPrefix String

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

versionPrefix string

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

version_prefix str

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

versionPrefix String

If provided, the provider will only return versions that match the string prefix. For example, 1.15. will match all 1.15.x series releases.

getKubernetesVersions Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

LatestVersion string

The most recent version available.

ValidVersions List<string>

A list of available versions.

VersionPrefix string
Id string

The provider-assigned unique ID for this managed resource.

LatestVersion string

The most recent version available.

ValidVersions []string

A list of available versions.

VersionPrefix string
id String

The provider-assigned unique ID for this managed resource.

latestVersion String

The most recent version available.

validVersions List<String>

A list of available versions.

versionPrefix String
id string

The provider-assigned unique ID for this managed resource.

latestVersion string

The most recent version available.

validVersions string[]

A list of available versions.

versionPrefix string
id str

The provider-assigned unique ID for this managed resource.

latest_version str

The most recent version available.

valid_versions Sequence[str]

A list of available versions.

version_prefix str
id String

The provider-assigned unique ID for this managed resource.

latestVersion String

The most recent version available.

validVersions List<String>

A list of available versions.

versionPrefix String

Package Details

Repository
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.