Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes example should be able to output LoadBalancer external IP #692

Open
kriswuollett opened this issue Sep 14, 2021 · 1 comment
Open

Comments

@kriswuollett
Copy link
Contributor

I followed the Kubernetes example and tried adding the following outputs as seen in the kubernetes_service data source:

output "load_balancer_hostname" {
  value = kubernetes_ingress.test_ingress.status.0.load_balancer.0.ingress.0.hostname
}

output "load_balancer_ip" {
  value = kubernetes_ingress.test_ingress.status.0.load_balancer.0.ingress.0.ip
}

The load_balancer_ip appears to be a droplet IP address and not the external IP of the Load Balancer that was created. I'm not too sure that is an actual bug, so perhaps it would be nice if the Kubernetes example showed how to output the external IP whether through the kubernetes or digitialocean providers.

@kriswuollett
Copy link
Contributor Author

kriswuollett commented Sep 14, 2021

It sort of makes sense that test_ingress gives the cluster member IP. And so I just tried the following that works:

  • examples/kubernetes/outputs.tf
output "test_url" {
  value = module.kubernetes-config.test_url
}
  • examples/kubernetes/kubernetes-config/main.tf
data "kubernetes_service" "nginx-ingress-controller" {
  metadata {
    name      = "nginx-ingress-controller"
    namespace = kubernetes_namespace.test.metadata.0.name
  }
}
  • examples/kubernetes/kubernetes-config/outputs.tf
output "test_url" {
  value = "http:https://${data.kubernetes_service.nginx-ingress-controller.status.0.load_balancer.0.ingress.0.ip}/test"
}

Having test_url in the example is nice since it can provide a clickable link in some terminals. But in practice also showing how to get the IP would be useful for setting up other resources like DNS entries.

Something like this seems a reasonable thing to add to the example?

kriswuollett added a commit to kriswuollett/terraform-provider-digitalocean that referenced this issue Sep 21, 2021
- If IP address is not available yet, "[PENDING]" is shown, resolves digitalocean#692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment