Skip to content

Commit

Permalink
Add ingress and nomad_job docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjackson committed May 7, 2023
1 parent adbd0bd commit bd9d415
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/config/navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const navigation = [
{ title: 'Overview', href: '/docs/resources/overview' },
{ title: 'Container', href: '/docs/resources/container' },
{ title: 'Nomad Cluster', href: '/docs/resources/nomad_cluster' },
{ title: 'Nomad Job', href: '/docs/resources/nomad_job' },
{ title: 'Ingress', href: '/docs/resources/ingress' },
]
}
]
2 changes: 1 addition & 1 deletion src/pages/docs/resources/container.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Volume from "./shared/volume.mdx"
import Port from "./shared/port.mdx"
import PortRange from "./shared/port_range.mdx"

# Container
# Container `container`

The `container` resource allows you to create Docker containers.

Expand Down
118 changes: 118 additions & 0 deletions src/pages/docs/resources/ingress.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import MetaProperties from "./shared/meta.mdx"

# Ingress `ingress`

<Intro>
The `ingress` resource allows you to expose services in Kubernetes and Nomad
tasks to the local machine.
</Intro >

## Properties

<Properties>
<Property name="port" type="int" required="true" value="">
The local port to expose the service on.
</Property>

<Property name="target" type="#traffic_target" required="true" value="">
The target for the ingress.
</Property>

<Property name="ingress_id" type="string" required="false" value="" readonly>
The unique identifier for the created ingress.
</Property>

<Property name="address" type="string" required="false" value="" readonly>
The full address where the ingress can be reached from the local network.

Generally this is the local ip address of the machine running Jumppad and the
port where the service is exposed.
</Property>
</Properties>

---

## traffic_target

<Properties>
<Property name="id" type="string" required="true" value="">
The id of the `nomad_cluster` or `kubernetes_cluster` resource.
</Property>

<Property name="port" type="int" required="true" value="">
The numerical reference for the target service port.

Either `port` or `named_port` must be specified.
</Property>

<Property name="named_port" type="string" required="true" value="">
The streing reference for the target service port.

Either `port` or `named_port` must be specified.
</Property>

<Property name="config" type="map[string]string" required="true" value="">
The configuration parameters for the ingress, configuration parameters
differ depending on the target type.

**Kubernetes target config**
```hcl
service = "Kubernetes service name"
namespace = "Kubernetes namespace where the service is deployed"
```

**Nomad target config**
```hcl
job = "Name of the Nomad job"
group = "Group in the job"
task = "Name of the task in the group"
```
</Property>
</Properties>

<MetaProperties/>

## Examples

### Nomad Ingress

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

```hcl
resource "ingress" "fake_service_1" {
port = 19090
target {
id = resource.nomad_cluster.dev.id
named_port = "http"
config = {
job = "example_1"
group = "fake_service"
task = "fake_service"
}
}
}
```

### Kubernets Ingress

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

```hcl
resource "ingress" "fake_service_1" {
port = 19090
target {
id = resource.k8s_cluster.k3s.id
port = 9090
config = {
service = "fake-service"
namespace = "default"
}
}
}
```
2 changes: 1 addition & 1 deletion src/pages/docs/resources/nomad_cluster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Volume from "./shared/volume.mdx"
import Port from "./shared/port.mdx"
import PortRange from "./shared/port_range.mdx"

# Nomad Cluster
# Nomad Cluster `nomad_cluster`

<Intro>
The `nomad_cluster` resource allows you to create Nomad clusters as Docker containers. Clusters
Expand Down
83 changes: 83 additions & 0 deletions src/pages/docs/resources/nomad_job.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import MetaProperties from "./shared/meta.mdx"

# Nomad Job `nomad_job`

<Intro>
The `nomad_job` resource allows you to apply one or more Nomad job files to
a cluster.
</Intro>

## Properties

<Properties>
<Property name="cluster" type="string" required="true" value="">
The id of the cluster to apply the jobs to. Commonly this is set using
the interpolated value `id` from the cluster. Setting the cluster id this
way ensures that the cluster is created and healthy before any jobs are
applied.

```hcl
resource "nomad_job" "example" {
cluster = resource.nomad_cluster.dev.id
...
}
```
</Property>
<Property name="pahts" type="[]string" required="true" value="">
Paths to the Nomad job files to apply to the cluster.
</Property>
<Property name="paths" type="#health_check" required="false" value="">
Optional health check to perform after the jobs have been applied, this resource
will not complete until the health checks are passing.
</Property>
</Properties>

---

## health_check

A health_check stanza allows the definition of a health check which must pass before the resource is marked as successfully created.

```hcl
health_check {
duration = "60s"
nomad_jobs = ["example"]
}
```

<Properties>
<Property name="timeout" type="duration" required="true" value="">
The maximum duration to wait before marking the health check as failed.
Expressed as a Go duration, e.g. `1s` = 1 second, `100ms` = 100 milliseconds.
</Property>

<Property name="nomad_jobs" type="[]string" required="true" value="">
An array of nomad jobs that must be marked as "Running" by the Nomad
server.
</Property>
</Properties>


<MetaProperties/>

## Examples

```hcl
resource "nomad_cluster" "dev" {
network {
id = resource.network.cloud.id
}
}
resource "nomad_job" "example" {
cluster = resource.nomad_cluster.dev.id
paths = ["./app_config/example1.nomad"]
health_check {
timeout = "60s"
nomad_jobs = ["example"]
}
}
```

0 comments on commit bd9d415

Please sign in to comment.