Ingress 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.
Properties
- Name
port
- Type
- (int: )
- Required
- required
- Readonly
- Description
If the application to be exposed exists on the target then this is the port that will be opened on the local machine that will direct traffic to the remote service.
If the application exists on the local machine then this is the port where the application is running.
- Name
expose_local
- Type
- (bool: false)
- Required
- Readonly
- Description
If set to true a service running on the local machine will be exposed to the target cluster. If false then a service running on the target cluster will be exposed to the local machine.
- Name
target
- Type
- (traffic_target: {})
- Required
- required
- Readonly
- Description
The target for the ingress.
- Name
ingress_id
- Type
- (string: "")
- Required
- Readonly
- readonly
- Description
The unique identifier for the created ingress.
- Name
local_address
- Type
- (string: "")
- Required
- Readonly
- readonly
- Description
The full address where the exposed application can be reached from the local network.
Generally this is the local ip address of the machine running Jumppad and the port where the application is exposed.
- Name
remote_address
- Type
- (string: "")
- Required
- Readonly
- readonly
- Description
The address of the exposed service as it would be rechable from the target cluster. This is generally a kubernetes service reference and port or for Nomad a rechable IP address and port.
traffic_target
- Name
resource
- Type
- (remote cluster: )
- Required
- required
- Readonly
- Description
A reference to the
nomad_cluster
orkubernetes_cluster
resource.resource "k8s_cluster" "dev" { } resource "ingress" "consul_http" { port = 18500 target { resource = resource.k8s_cluster.dev port = 8500 config = { service = "consul-consul-server" namespace = "default" } } }
- Name
port
- Type
- (int: )
- Required
- required
- Readonly
- Description
The numerical reference for the target service port.
Either
port
ornamed_port
must be specified.
- Name
named_port
- Type
- (string: "")
- Required
- required
- Readonly
- Description
The string reference for the target service port.
Either
port
ornamed_port
must be specified.
- Name
config
- Type
- (map[string]string: map[]{})
- Required
- required
- Readonly
- Description
The configuration parameters for the ingress, configuration parameters differ depending on the target type.
Kubernetes target config
service = "Kubernetes service name" namespace = "Kubernetes namespace where the service is deployed"
Nomad target config
job = "Name of the Nomad job" group = "Group in the job" task = "Name of the task in the group"
Meta Properties
In addition to the main properties, all resources have meta
properties, such
as the id
of the resource. To see the list of these properties please see the
Meta Properties
section in the documentation /docs/resources/meta.
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 jumppad
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"
}
}
}