1. Packages
  2. UpCloud
  3. API Docs
  4. getKubernetesCluster
UpCloud v0.2.0 published on Wednesday, Apr 16, 2025 by UpCloudLtd

upcloud.getKubernetesCluster

Explore with Pulumi AI

upcloud logo
UpCloud v0.2.0 published on Wednesday, Apr 16, 2025 by UpCloudLtd

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as kubernetes from "@pulumi/kubernetes";
    import * as local from "@pulumi/local";
    import * as upcloud from "@pulumi/upcloud";
    import * as upcloud from "@upcloud/pulumi-upcloud";
    
    // Use Kubernetes provider to access your Kubernetes cluster
    // Create a network for the Kubernetes cluster
    const exampleNetwork = new upcloud.Network("example", {
        name: "example-network",
        zone: "de-fra1",
        ipNetwork: {
            address: "172.16.1.0/24",
            dhcp: true,
            family: "IPv4",
        },
    });
    // Create a Kubernetes cluster
    const exampleKubernetesCluster = new upcloud.KubernetesCluster("example", {
        controlPlaneIpFilters: ["0.0.0.0/0"],
        name: "exampleapp",
        network: exampleNetwork.id,
        zone: "de-fra1",
    });
    // Read the details of the newly created cluster
    const example = upcloud.getKubernetesClusterOutput({
        id: exampleKubernetesCluster.id,
    });
    // Use the Kubernetes provider resources to interact with the cluster
    const exampleNamespace = new kubernetes.index.Namespace("example", {metadata: [{
        name: "example-namespace",
    }]});
    // In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
    const exampleFile = new local.index.File("example", {
        content: example.kubeconfig,
        filename: "example.conf",
    });
    
    import pulumi
    import pulumi_kubernetes as kubernetes
    import pulumi_local as local
    import pulumi_upcloud as upcloud
    
    # Use Kubernetes provider to access your Kubernetes cluster
    # Create a network for the Kubernetes cluster
    example_network = upcloud.Network("example",
        name="example-network",
        zone="de-fra1",
        ip_network={
            "address": "172.16.1.0/24",
            "dhcp": True,
            "family": "IPv4",
        })
    # Create a Kubernetes cluster
    example_kubernetes_cluster = upcloud.KubernetesCluster("example",
        control_plane_ip_filters=["0.0.0.0/0"],
        name="exampleapp",
        network=example_network.id,
        zone="de-fra1")
    # Read the details of the newly created cluster
    example = upcloud.get_kubernetes_cluster_output(id=example_kubernetes_cluster.id)
    # Use the Kubernetes provider resources to interact with the cluster
    example_namespace = kubernetes.index.Namespace("example", metadata=[{
        name: example-namespace,
    }])
    # In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
    example_file = local.index.File("example",
        content=example.kubeconfig,
        filename=example.conf)
    
    package main
    
    import (
    	"github.com/UpCloudLtd/pulumi-upcloud/sdk/go/upcloud"
    	"github.com/pulumi/pulumi-kubernetes/sdk/go/kubernetes"
    	"github.com/pulumi/pulumi-local/sdk/go/local"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Use Kubernetes provider to access your Kubernetes cluster
    		// Create a network for the Kubernetes cluster
    		exampleNetwork, err := upcloud.NewNetwork(ctx, "example", &upcloud.NetworkArgs{
    			Name: pulumi.String("example-network"),
    			Zone: pulumi.String("de-fra1"),
    			IpNetwork: &upcloud.NetworkIpNetworkArgs{
    				Address: pulumi.String("172.16.1.0/24"),
    				Dhcp:    pulumi.Bool(true),
    				Family:  pulumi.String("IPv4"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Create a Kubernetes cluster
    		exampleKubernetesCluster, err := upcloud.NewKubernetesCluster(ctx, "example", &upcloud.KubernetesClusterArgs{
    			ControlPlaneIpFilters: pulumi.StringArray{
    				pulumi.String("0.0.0.0/0"),
    			},
    			Name:    pulumi.String("exampleapp"),
    			Network: exampleNetwork.ID(),
    			Zone:    pulumi.String("de-fra1"),
    		})
    		if err != nil {
    			return err
    		}
    		// Read the details of the newly created cluster
    		example := upcloud.LookupKubernetesClusterOutput(ctx, upcloud.GetKubernetesClusterOutputArgs{
    			Id: exampleKubernetesCluster.ID(),
    		}, nil)
    		// Use the Kubernetes provider resources to interact with the cluster
    		_, err = kubernetes.NewNamespace(ctx, "example", &kubernetes.NamespaceArgs{
    			Metadata: []map[string]interface{}{
    				map[string]interface{}{
    					"name": "example-namespace",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
    		_, err = local.NewFile(ctx, "example", &local.FileArgs{
    			Content:  example.Kubeconfig,
    			Filename: "example.conf",
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kubernetes = Pulumi.Kubernetes;
    using Local = Pulumi.Local;
    using UpCloud = Pulumi.UpCloud;
    using UpCloud = UpCloud.Pulumi.UpCloud;
    
    return await Deployment.RunAsync(() => 
    {
        // Use Kubernetes provider to access your Kubernetes cluster
        // Create a network for the Kubernetes cluster
        var exampleNetwork = new UpCloud.Network("example", new()
        {
            Name = "example-network",
            Zone = "de-fra1",
            IpNetwork = new UpCloud.Inputs.NetworkIpNetworkArgs
            {
                Address = "172.16.1.0/24",
                Dhcp = true,
                Family = "IPv4",
            },
        });
    
        // Create a Kubernetes cluster
        var exampleKubernetesCluster = new UpCloud.KubernetesCluster("example", new()
        {
            ControlPlaneIpFilters = new[]
            {
                "0.0.0.0/0",
            },
            Name = "exampleapp",
            Network = exampleNetwork.Id,
            Zone = "de-fra1",
        });
    
        // Read the details of the newly created cluster
        var example = UpCloud.GetKubernetesCluster.Invoke(new()
        {
            Id = exampleKubernetesCluster.Id,
        });
    
        // Use the Kubernetes provider resources to interact with the cluster
        var exampleNamespace = new Kubernetes.Index.Namespace("example", new()
        {
            Metadata = new[]
            {
                
                {
                    { "name", "example-namespace" },
                },
            },
        });
    
        // In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
        var exampleFile = new Local.Index.File("example", new()
        {
            Content = example.Apply(getKubernetesClusterResult => getKubernetesClusterResult.Kubeconfig),
            Filename = "example.conf",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.upcloud.Network;
    import com.pulumi.upcloud.NetworkArgs;
    import com.pulumi.upcloud.inputs.NetworkIpNetworkArgs;
    import com.pulumi.upcloud.KubernetesCluster;
    import com.pulumi.upcloud.KubernetesClusterArgs;
    import com.pulumi.upcloud.UpcloudFunctions;
    import com.pulumi.upcloud.inputs.GetKubernetesClusterArgs;
    import com.pulumi.kubernetes.Namespace;
    import com.pulumi.kubernetes.NamespaceArgs;
    import com.pulumi.local.File;
    import com.pulumi.local.FileArgs;
    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) {
            // Use Kubernetes provider to access your Kubernetes cluster
            // Create a network for the Kubernetes cluster
            var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
                .name("example-network")
                .zone("de-fra1")
                .ipNetwork(NetworkIpNetworkArgs.builder()
                    .address("172.16.1.0/24")
                    .dhcp(true)
                    .family("IPv4")
                    .build())
                .build());
    
            // Create a Kubernetes cluster
            var exampleKubernetesCluster = new KubernetesCluster("exampleKubernetesCluster", KubernetesClusterArgs.builder()
                .controlPlaneIpFilters("0.0.0.0/0")
                .name("exampleapp")
                .network(exampleNetwork.id())
                .zone("de-fra1")
                .build());
    
            // Read the details of the newly created cluster
            final var example = UpcloudFunctions.getKubernetesCluster(GetKubernetesClusterArgs.builder()
                .id(exampleKubernetesCluster.id())
                .build());
    
            // Use the Kubernetes provider resources to interact with the cluster
            var exampleNamespace = new Namespace("exampleNamespace", NamespaceArgs.builder()
                .metadata(List.of(Map.of("name", "example-namespace")))
                .build());
    
            // In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
            var exampleFile = new File("exampleFile", FileArgs.builder()
                .content(example.kubeconfig())
                .filename("example.conf")
                .build());
    
        }
    }
    
    resources:
      # Use Kubernetes provider to access your Kubernetes cluster
    
      # Create a network for the Kubernetes cluster
      exampleNetwork:
        type: upcloud:Network
        name: example
        properties:
          name: example-network
          zone: de-fra1
          ipNetwork:
            address: 172.16.1.0/24
            dhcp: true
            family: IPv4
      # Create a Kubernetes cluster
      exampleKubernetesCluster:
        type: upcloud:KubernetesCluster
        name: example
        properties:
          controlPlaneIpFilters:
            - 0.0.0.0/0
          name: exampleapp
          network: ${exampleNetwork.id}
          zone: de-fra1
      # Use the Kubernetes provider resources to interact with the cluster
      exampleNamespace:
        type: kubernetes:Namespace
        name: example
        properties:
          metadata:
            - name: example-namespace
      # In addition, write the kubeconfig to a file to interact with the cluster with `kubectl` or other clients
      exampleFile:
        type: local:File
        name: example
        properties:
          content: ${example.kubeconfig}
          filename: example.conf
    variables:
      # Read the details of the newly created cluster
      example:
        fn::invoke:
          function: upcloud:getKubernetesCluster
          arguments:
            id: ${exampleKubernetesCluster.id}
    

    Using getKubernetesCluster

    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 getKubernetesCluster(args: GetKubernetesClusterArgs, opts?: InvokeOptions): Promise<GetKubernetesClusterResult>
    function getKubernetesClusterOutput(args: GetKubernetesClusterOutputArgs, opts?: InvokeOptions): Output<GetKubernetesClusterResult>
    def get_kubernetes_cluster(id: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetKubernetesClusterResult
    def get_kubernetes_cluster_output(id: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetKubernetesClusterResult]
    func LookupKubernetesCluster(ctx *Context, args *LookupKubernetesClusterArgs, opts ...InvokeOption) (*LookupKubernetesClusterResult, error)
    func LookupKubernetesClusterOutput(ctx *Context, args *LookupKubernetesClusterOutputArgs, opts ...InvokeOption) LookupKubernetesClusterResultOutput

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

    public static class GetKubernetesCluster 
    {
        public static Task<GetKubernetesClusterResult> InvokeAsync(GetKubernetesClusterArgs args, InvokeOptions? opts = null)
        public static Output<GetKubernetesClusterResult> Invoke(GetKubernetesClusterInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetKubernetesClusterResult> getKubernetesCluster(GetKubernetesClusterArgs args, InvokeOptions options)
    public static Output<GetKubernetesClusterResult> getKubernetesCluster(GetKubernetesClusterArgs args, InvokeOptions options)
    
    fn::invoke:
      function: upcloud:index/getKubernetesCluster:getKubernetesCluster
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    Id string
    id String
    id string
    id str
    id String

    getKubernetesCluster Result

    The following output properties are available:

    ClientCertificate string
    ClientKey string
    ClusterCaCertificate string
    Host string
    Id string
    Kubeconfig string
    Name string
    ClientCertificate string
    ClientKey string
    ClusterCaCertificate string
    Host string
    Id string
    Kubeconfig string
    Name string
    clientCertificate String
    clientKey String
    clusterCaCertificate String
    host String
    id String
    kubeconfig String
    name String
    clientCertificate string
    clientKey string
    clusterCaCertificate string
    host string
    id string
    kubeconfig string
    name string
    clientCertificate String
    clientKey String
    clusterCaCertificate String
    host String
    id String
    kubeconfig String
    name String

    Package Details

    Repository
    upcloud UpCloudLtd/pulumi-upcloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the upcloud Terraform Provider.
    upcloud logo
    UpCloud v0.2.0 published on Wednesday, Apr 16, 2025 by UpCloudLtd