1. Packages
  2. Ionoscloud Provider
  3. API Docs
  4. getK8sClusters
ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud

ionoscloud.getK8sClusters

Explore with Pulumi AI

ionoscloud logo
ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud

    The k8s_clusters data source can be used to search for and return existing kubernetes clusters based on filters used.

    Example Usage

    By Name

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.getK8sClusters({
        filters: [{
            name: "name",
            value: "k8sClusterExample",
        }],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_k8s_clusters(filters=[{
        "name": "name",
        "value": "k8sClusterExample",
    }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ionoscloud.GetK8sClusters(ctx, &ionoscloud.GetK8sClustersArgs{
    			Filters: []ionoscloud.GetK8sClustersFilter{
    				{
    					Name:  "name",
    					Value: "k8sClusterExample",
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ionoscloud.GetK8sClusters.Invoke(new()
        {
            Filters = new[]
            {
                new Ionoscloud.Inputs.GetK8sClustersFilterInputArgs
                {
                    Name = "name",
                    Value = "k8sClusterExample",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.IonoscloudFunctions;
    import com.pulumi.ionoscloud.inputs.GetK8sClustersArgs;
    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 = IonoscloudFunctions.getK8sClusters(GetK8sClustersArgs.builder()
                .filters(GetK8sClustersFilterArgs.builder()
                    .name("name")
                    .value("k8sClusterExample")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getK8sClusters
          arguments:
            filters:
              - name: name
                value: k8sClusterExample
    

    By Name and k8s version Family

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example2 = ionoscloud.getK8sClusters({
        filters: [
            {
                name: "name",
                value: "k8sClusterExample",
            },
            {
                name: "k8s_version",
                value: "1.27",
            },
        ],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example2 = ionoscloud.get_k8s_clusters(filters=[
        {
            "name": "name",
            "value": "k8sClusterExample",
        },
        {
            "name": "k8s_version",
            "value": "1.27",
        },
    ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ionoscloud.GetK8sClusters(ctx, &ionoscloud.GetK8sClustersArgs{
    			Filters: []ionoscloud.GetK8sClustersFilter{
    				{
    					Name:  "name",
    					Value: "k8sClusterExample",
    				},
    				{
    					Name:  "k8s_version",
    					Value: "1.27",
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example2 = Ionoscloud.GetK8sClusters.Invoke(new()
        {
            Filters = new[]
            {
                new Ionoscloud.Inputs.GetK8sClustersFilterInputArgs
                {
                    Name = "name",
                    Value = "k8sClusterExample",
                },
                new Ionoscloud.Inputs.GetK8sClustersFilterInputArgs
                {
                    Name = "k8s_version",
                    Value = "1.27",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.IonoscloudFunctions;
    import com.pulumi.ionoscloud.inputs.GetK8sClustersArgs;
    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 example2 = IonoscloudFunctions.getK8sClusters(GetK8sClustersArgs.builder()
                .filters(            
                    GetK8sClustersFilterArgs.builder()
                        .name("name")
                        .value("k8sClusterExample")
                        .build(),
                    GetK8sClustersFilterArgs.builder()
                        .name("k8s_version")
                        .value("1.27")
                        .build())
                .build());
    
        }
    }
    
    variables:
      example2:
        fn::invoke:
          function: ionoscloud:getK8sClusters
          arguments:
            filters:
              - name: name
                value: k8sClusterExample
              - name: k8s_version
                value: '1.27'
    

    Retrieve private clusters only, by Name and Cluster State

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@pulumi/ionoscloud";
    
    const example = ionoscloud.getServers({
        filters: [
            {
                name: "name",
                value: "k8sClusterExample",
            },
            {
                name: "state",
                value: "ACTIVE",
            },
            {
                name: "public",
                value: "false",
            },
        ],
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.get_servers(filters=[
        {
            "name": "name",
            "value": "k8sClusterExample",
        },
        {
            "name": "state",
            "value": "ACTIVE",
        },
        {
            "name": "public",
            "value": "false",
        },
    ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ionoscloud.GetServers(ctx, &ionoscloud.GetServersArgs{
    			Filters: []ionoscloud.GetServersFilter{
    				{
    					Name:  "name",
    					Value: "k8sClusterExample",
    				},
    				{
    					Name:  "state",
    					Value: "ACTIVE",
    				},
    				{
    					Name:  "public",
    					Value: "false",
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ionoscloud.GetServers.Invoke(new()
        {
            Filters = new[]
            {
                new Ionoscloud.Inputs.GetServersFilterInputArgs
                {
                    Name = "name",
                    Value = "k8sClusterExample",
                },
                new Ionoscloud.Inputs.GetServersFilterInputArgs
                {
                    Name = "state",
                    Value = "ACTIVE",
                },
                new Ionoscloud.Inputs.GetServersFilterInputArgs
                {
                    Name = "public",
                    Value = "false",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.IonoscloudFunctions;
    import com.pulumi.ionoscloud.inputs.GetServersArgs;
    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 = IonoscloudFunctions.getServers(GetServersArgs.builder()
                .filters(            
                    GetServersFilterArgs.builder()
                        .name("name")
                        .value("k8sClusterExample")
                        .build(),
                    GetServersFilterArgs.builder()
                        .name("state")
                        .value("ACTIVE")
                        .build(),
                    GetServersFilterArgs.builder()
                        .name("public")
                        .value("false")
                        .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ionoscloud:getServers
          arguments:
            filters:
              - name: name
                value: k8sClusterExample
              - name: state
                value: ACTIVE
              - name: public
                value: 'false'
    

    Using getK8sClusters

    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 getK8sClusters(args: GetK8sClustersArgs, opts?: InvokeOptions): Promise<GetK8sClustersResult>
    function getK8sClustersOutput(args: GetK8sClustersOutputArgs, opts?: InvokeOptions): Output<GetK8sClustersResult>
    def get_k8s_clusters(filters: Optional[Sequence[GetK8sClustersFilter]] = None,
                         id: Optional[str] = None,
                         timeouts: Optional[GetK8sClustersTimeouts] = None,
                         opts: Optional[InvokeOptions] = None) -> GetK8sClustersResult
    def get_k8s_clusters_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetK8sClustersFilterArgs]]]] = None,
                         id: Optional[pulumi.Input[str]] = None,
                         timeouts: Optional[pulumi.Input[GetK8sClustersTimeoutsArgs]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetK8sClustersResult]
    func GetK8sClusters(ctx *Context, args *GetK8sClustersArgs, opts ...InvokeOption) (*GetK8sClustersResult, error)
    func GetK8sClustersOutput(ctx *Context, args *GetK8sClustersOutputArgs, opts ...InvokeOption) GetK8sClustersResultOutput

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

    public static class GetK8sClusters 
    {
        public static Task<GetK8sClustersResult> InvokeAsync(GetK8sClustersArgs args, InvokeOptions? opts = null)
        public static Output<GetK8sClustersResult> Invoke(GetK8sClustersInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetK8sClustersResult> getK8sClusters(GetK8sClustersArgs args, InvokeOptions options)
    public static Output<GetK8sClustersResult> getK8sClusters(GetK8sClustersArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ionoscloud:index/getK8sClusters:getK8sClusters
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<GetK8sClustersFilter>

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    Id string
    Timeouts GetK8sClustersTimeouts
    Filters []GetK8sClustersFilter

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    Id string
    Timeouts GetK8sClustersTimeouts
    filters List<GetK8sClustersFilter>

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    id String
    timeouts GetK8sClustersTimeouts
    filters GetK8sClustersFilter[]

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    id string
    timeouts GetK8sClustersTimeouts
    filters Sequence[GetK8sClustersFilter]

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    id str
    timeouts GetK8sClustersTimeouts
    filters List<Property Map>

    One or more property name - value pairs to be used in filtering the cluster list by the specified attributes. You can use most of the top level fields from the k8s_cluster resource except those containing other nested structures such as maintenance_window or config.

    NOTE: Filtering uses partial matching for all types of values. Searching for a cluster using name:testCluster will find all clusters who have the testCluster substring in their name. This also applies to values for properties that would normally be boolean or numerical.

    id String
    timeouts Property Map

    getK8sClusters Result

    The following output properties are available:

    Clusters List<GetK8sClustersCluster>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    Entries double
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    Id string
    Filters List<GetK8sClustersFilter>
    Timeouts GetK8sClustersTimeouts
    Clusters []GetK8sClustersCluster
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    Entries float64
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    Id string
    Filters []GetK8sClustersFilter
    Timeouts GetK8sClustersTimeouts
    clusters List<GetK8sClustersCluster>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    entries Double
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    id String
    filters List<GetK8sClustersFilter>
    timeouts GetK8sClustersTimeouts
    clusters GetK8sClustersCluster[]
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    entries number
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    id string
    filters GetK8sClustersFilter[]
    timeouts GetK8sClustersTimeouts
    clusters Sequence[GetK8sClustersCluster]
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    entries float
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    id str
    filters Sequence[GetK8sClustersFilter]
    timeouts GetK8sClustersTimeouts
    clusters List<Property Map>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    entries Number
    indicates the number of clusters found and added to the list after the query has been performed with the specified filters. For a full reference of all the attributes returned, check out documentation
    id String
    filters List<Property Map>
    timeouts Property Map

    Supporting Types

    GetK8sClustersCluster

    GetK8sClustersClusterConfig

    ApiVersion string
    Clusters List<GetK8sClustersClusterConfigCluster>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    Contexts List<GetK8sClustersClusterConfigContext>
    CurrentContext string
    Kind string
    Users List<GetK8sClustersClusterConfigUser>
    ApiVersion string
    Clusters []GetK8sClustersClusterConfigCluster
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    Contexts []GetK8sClustersClusterConfigContext
    CurrentContext string
    Kind string
    Users []GetK8sClustersClusterConfigUser
    apiVersion String
    clusters List<GetK8sClustersClusterConfigCluster>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    contexts List<GetK8sClustersClusterConfigContext>
    currentContext String
    kind String
    users List<GetK8sClustersClusterConfigUser>
    apiVersion string
    clusters GetK8sClustersClusterConfigCluster[]
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    contexts GetK8sClustersClusterConfigContext[]
    currentContext string
    kind string
    users GetK8sClustersClusterConfigUser[]
    api_version str
    clusters Sequence[GetK8sClustersClusterConfigCluster]
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    contexts Sequence[GetK8sClustersClusterConfigContext]
    current_context str
    kind str
    users Sequence[GetK8sClustersClusterConfigUser]
    apiVersion String
    clusters List<Property Map>
    list of Kubernetes clusters that match the provided filters. The elements of this list are structurally identical to the k8s_cluster datasource, which is limited to retrieving only 1 cluster in a single query.
    contexts List<Property Map>
    currentContext String
    kind String
    users List<Property Map>

    GetK8sClustersClusterConfigCluster

    Cluster Dictionary<string, string>
    Name string
    Cluster map[string]string
    Name string
    cluster Map<String,String>
    name String
    cluster {[key: string]: string}
    name string
    cluster Mapping[str, str]
    name str
    cluster Map<String>
    name String

    GetK8sClustersClusterConfigContext

    Context Dictionary<string, string>
    Name string
    Context map[string]string
    Name string
    context Map<String,String>
    name String
    context {[key: string]: string}
    name string
    context Mapping[str, str]
    name str
    context Map<String>
    name String

    GetK8sClustersClusterConfigUser

    Name string
    User Dictionary<string, string>
    Name string
    User map[string]string
    name String
    user Map<String,String>
    name string
    user {[key: string]: string}
    name str
    user Mapping[str, str]
    name String
    user Map<String>

    GetK8sClustersClusterMaintenanceWindow

    DayOfTheWeek string
    Time string
    DayOfTheWeek string
    Time string
    dayOfTheWeek String
    time String
    dayOfTheWeek string
    time string
    dayOfTheWeek String
    time String

    GetK8sClustersClusterS3Bucket

    Name string
    Name string
    name String
    name string
    name str
    name String

    GetK8sClustersFilter

    Name string
    Value string
    Name string
    Value string
    name String
    value String
    name string
    value string
    name str
    value str
    name String
    value String

    GetK8sClustersTimeouts

    Create string
    Default string
    Delete string
    Update string
    Create string
    Default string
    Delete string
    Update string
    create String
    default_ String
    delete String
    update String
    create string
    default string
    delete string
    update string
    create String
    default String
    delete String
    update String

    Package Details

    Repository
    ionoscloud ionos-cloud/terraform-provider-ionoscloud
    License
    Notes
    This Pulumi package is based on the ionoscloud Terraform Provider.
    ionoscloud logo
    ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud