Report this

What is the reason for this report?

terraform failed to expose kubernetes service

Posted on September 28, 2020

I have a kub deployment to expose as LoadBalancer. Created with Terraform, looks good. But when I create a service to expose, it returns empty response all the time.

resource "kubernetes_service" "front" {
  metadata {
    name = "front"
  }
  spec {
    selector = {
      App = "front"
    }
    port {
      port = 8000
    }
    type = "LoadBalancer"
  }
}

Checked cluster status and found the service endpoint was not created by some reason.

If I delete the service with kubectl and re-create it as:

–kubeconfig ~/.kube/my-doks-config.yaml expose deployment front --type LoadBalancer

Everything is fine, endpoint created, the service exposed and working as expected.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.