Ingress

The ingress resource allows you to expose services in Kubernetes and Nomad tasks to the local machine.

It also allows you to expose applications that are running to the local machine to a Kubernetes or Nomad cluster.

Examples

Nomad Remote Service

Exposes the the http port for the task fake_service in the group fake_service in the job example_1 locally on port 19090.

resource "ingress" "fake_service_1" {
  port = 19090

  target {
    resource   = resource.nomad_cluster.dev
    named_port = "http"

    config = {
      job   = "example_1"
      group = "fake_service"
      task  = "fake_service"
    }
  }
}

Kubernets Remote Service

Exposes the Kubernets port 9090 for the Kubernetes service fake-service in the default namespace locally on port 19090.

resource "ingress" "fake_service_1" {
  port = 19090

  target {
    resource = resource.k8s_cluster.k3s.meta.id
    port = 9090

    config = {
      service   = "fake-service"
      namespace = "default"
    }
  }
}

Kubernets Local Service

Exposes the local port 9090 used by the app container, as a the Kubernetes service fake-service in the default namespace on port 80.

resource "container" "app" {
  image {
    name = variable.image
  }

  port {
    local  = 9090
    remote = 9090
    host = 9090 
  }
}

resource "ingress" "fake_service_1" {
  port = 9090

  target {
    resource = resource.k8s_cluster.k3s
    port = 80

    config = {
      service   = "fake-service"
    }
  }
}

Last updated