https://rancher.com/ logo
Title
c

clever-processor-78736

09/08/2022, 8:49 PM
Hi! Is there a way of fetching the node IP addresses (using a data source) from a cluster created using the
rancher2_cluster_v2
resource? We're trying to create a external loadbalancer and adding the control plane nodes into a LB backend-pool.
a

adventurous-battery-36116

09/09/2022, 2:38 AM
Here’s a local that I use for associating hostnames with IPs:
locals {
  node_ip = values(zipmap(rancher2_cluster_sync.get_node_info.nodes[*].hostname, rancher2_cluster_sync.get_node_info.nodes[*].ip_address))
}
You’ll also need the
rancher2_cluster_sync
resource for this, but it doesn’t need any arguments:
resource "rancher2_cluster_sync" "get_node_info" {
  cluster_id = rancher2_cluster_v2.rke2.cluster_v1_id
}
c

clever-processor-78736

09/09/2022, 11:41 AM
Thanks!! Will try this!