kubernetes_nodes

This data source provides a mechanism for listing the names of nodes in a kubernetes cluster.

By default, all nodes in the cluster are returned, but queries by node label are also supported.

It can be used to check for the existence of a specific node or to lookup a node to apply a taint with the kubernetes_node_taint resource.

Example usage

All nodes

data "kubernetes_nodes" "example" {}

output "node-ids" {
  value = [for node in data.kubernetes_nodes.example.nodes : node.spec.0.provider_id]
}

By label

data "kubernetes_nodes" "example" {
  metadata {
    labels = {
      "kubernetes.io/os" = "linux"
    }
  }
}

output "linux-node-names" {
  value = [for node in data.kubernetes_nodes.example.nodes : node.metadata.0.name]
}

Argument Reference

The following arguments are supported:

Attributes

Nested Blocks

metadata

Arguments

Attributes

spec

Attributes

status

Attributes

addresses

Attributes

node_info

Attributes

taints

Attributes