Retrieve K8s Ingress Load Balancer IP (not hostname) using Terraform?

I need to retrieve K8s Ingress Load Balancer IP (not hostname) using Terraform.

I've tried this:


But it was blank/null. 'hostname' field has a valid hostname available, but then it is a 'name', non-resolved, which is not acceptable to the resource, which requires an IP.

The ingress I've used:

resource "kubernetes_ingress" "mytestapp-backend-ingress" {
   wait_for_load_balancer = true
   metadata {
     name = "mytestapp-backend-ingress"
     annotations = {
       "" = "nginx"
   spec {
     rule {
       host = ""
       http {
         path {
           backend {
             service_name = "mytestapp-backend-service"
             service_port = 8080
           path = "/"

The domain to be configured with IP from LB/ingress:

resource "linode_domain_record" "mydomain_record_all" {
     domain_id =
     record_type = "A"
     target = kubernetes_ingress.mytestapp-backend-ingress.status.0.load_balancer.0.ingress.0.ip

If using "hostname" (instead of "ip") will error because 'hostname' is invalid IP address, as Terraform output shows:

linode_domain_record.mydomain_domain_record_all: Creating…
Error: Error creating a Linode DomainRecord: [400] [target] Invalid IPv4 or IPv6 address

How should I be handling this?


Update: On Digital Ocean, I was told the IP field is populated properly, if yes, it would make this a Linode specific problem. [I'll try to replicate this there.]

I was able to workaround problem by using the 'dns provider', as:

data "dns_a_record_set" "ingress-lb-ip" {
  host = kubernetes_ingress.mytestapp-backend-ingress.status.0.load_balancer.0.ingress.0.hostname

resource "linode_domain_record" "mydomain_domain_record_www" {
    domain_id =
    name = "www"
    record_type = "A"
    target = data.dns_a_record_set.ingress-lb-ip.addrs.0

Ideally Linode should be adding IP to ip field. I don't understand why the 'ip' field is not populated by Linode.

@linode Care to explain why ip field is not populated?

1 Reply

Hey there -

In the most recent Cloud Control Manager release, we changed from exposing the public IP address to using the NodeBalance hostname, which is why you're running into this.

That said, we're working on rolling that back and making it an opt-in feature. That should be available soon!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct