Skip to content

Commit

Permalink
chore: gen docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ecshreve committed Sep 27, 2023
1 parent e84a231 commit c605588
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 143 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

---

deploy nomad jobs with go
This repo is how I deploy Nomad jobs to my home lab. It's a work in progress. ymmv


## registry
Expand All @@ -18,9 +18,3 @@ contains service definitions
## slomad

contains the slomad package which provides a minimal interface to the nomad api

## devcontainer

pre-built with devcontainer-cli, image based on ubuntu 22.04, includes hashi tools, docker, and
my dotfile setup all baked in

19 changes: 12 additions & 7 deletions cmd/slomad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import "github.com/ecshreve/slomad/cmd/slomad"

## Index

- [func RunDeploy(j *slomad.Job, confirm, force, verbose bool) error](<#func-rundeploy>)
- [func main()](<#func-main>)
- [func newNomadClient() (*nomadApi.Client, error)](<#func-newnomadclient>)
- [func planApiJob(nomadClient *nomadApi.Client, job *nomadApi.Job, diff bool) (bool, error)](<#func-planapijob>)
- [func submitApiJob(nomadClient *nomadApi.Client, job *nomadApi.Job) error](<#func-submitapijob>)
- [func RunDeploy\(j \*slomad.Job, confirm, force, verbose bool\) error](<#RunDeploy>)
- [func main\(\)](<#main>)
- [func newNomadClient\(\) \(\*nomadApi.Client, error\)](<#newNomadClient>)
- [func planApiJob\(nomadClient \*nomadApi.Client, job \*nomadApi.Job, diff bool\) \(bool, error\)](<#planApiJob>)
- [func submitApiJob\(nomadClient \*nomadApi.Client, job \*nomadApi.Job\) error](<#submitApiJob>)


<a name="RunDeploy"></a>
## func [RunDeploy](<https://github.com/ecshreve/slomad/blob/main/cmd/slomad/deploy.go#L15>)

```go
Expand All @@ -23,12 +24,16 @@ func RunDeploy(j *slomad.Job, confirm, force, verbose bool) error

RunDeploy runs a deploy for the given job.

<a name="main"></a>
## func [main](<https://github.com/ecshreve/slomad/blob/main/cmd/slomad/main.go#L12>)

```go
func main()
```



<a name="newNomadClient"></a>
## func [newNomadClient](<https://github.com/ecshreve/slomad/blob/main/cmd/slomad/deploy.go#L46>)

```go
Expand All @@ -37,6 +42,7 @@ func newNomadClient() (*nomadApi.Client, error)

newNomadClient returns a default nomad api client.

<a name="planApiJob"></a>
## func [planApiJob](<https://github.com/ecshreve/slomad/blob/main/cmd/slomad/deploy.go#L59>)

```go
Expand All @@ -45,6 +51,7 @@ func planApiJob(nomadClient *nomadApi.Client, job *nomadApi.Job, diff bool) (boo

planApiJob runs a plan for the given job, and returns whether or not the job can be ignored, and any errors encountered.

<a name="submitApiJob"></a>
## func [submitApiJob](<https://github.com/ecshreve/slomad/blob/main/cmd/slomad/deploy.go#L81>)

```go
Expand All @@ -53,6 +60,4 @@ func submitApiJob(nomadClient *nomadApi.Client, job *nomadApi.Job) error

submitApiJob submits the given job to the nomad cluster.



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
116 changes: 77 additions & 39 deletions internal/registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,58 @@ import "github.com/ecshreve/slomad/internal/registry"
## Index

- [Variables](<#variables>)
- [func getStorageArgs(storage string) []string](<#func-getstorageargs>)
- [func promConfigHelper(tmpl string) string](<#func-promconfighelper>)
- [func getStorageArgs\(storage string\) \[\]string](<#getStorageArgs>)
- [func promConfigHelper\(tmpl string\) string](<#promConfigHelper>)


## Variables

<a name="ControllerJob"></a>

```go
var ControllerJob = smd.Job{
Name: "storage-controller",
Type: smd.STORAGE_CONTROLLER,
Target: smd.WORKER,
Target: smd.NODE0,
Ports: smd.BasicPortConfig(0),
Shape: smd.TINY_TASK,
Args: getStorageArgs("controller"),
}
```

<a name="GrafanaJob"></a>TODO: mount nomad volume and persist data

```go
var GrafanaJob = smd.Job{
Name: "grafana",
Type: smd.SERVICE,
Target: smd.WORKER,
Ports: smd.BasicPortConfig(3000),
Shape: smd.LARGE_TASK,
User: "root",
Env: map[string]string{"GF_SERVER_HTTP_PORT": "${NOMAD_PORT_http}"},
Volumes: []smd.Volume{{Src: "grafana-vol", Dst: "/var/lib/grafana", Mount: true}},
Name: "grafana",
Type: smd.SERVICE,
Target: smd.NODE,
Ports: smd.BasicPortConfig(3000),
Shape: smd.LARGE_TASK,
User: "root",
Env: map[string]string{
"GF_SERVER_ROOT_URL": "http://clust.slab.lan:9999/grafana",
"GF_SERVER_SERVE_FROM_SUB_PATH": "true",
},
}
```

TODO: mount nomad volume and persist data

```go
var InfluxDBJob = smd.Job{
Name: "influxdb",
Type: smd.SERVICE,
Target: smd.WORKER,
Ports: smd.BasicPortConfig(8086),
Shape: smd.LARGE_TASK,
Volumes: []smd.Volume{{Src: "influx_data", Dst: "/var/lib/influxdb"}},
}
```
<a name="LokiJob"></a>

```go
var LokiJob = smd.Job{
Name: "loki",
Type: smd.SERVICE,
Target: smd.WORKER,
Ports: smd.BasicPortConfig(3100),
Shape: smd.TINY_TASK,
Target: smd.NODE,
Ports: []*smd.Port{
{Label: "http", To: 3100, From: 3100, Static: true},
},
Shape: smd.TINY_TASK,
}
```

<a name="NodeExporterJob"></a>

```go
var NodeExporterJob = smd.Job{
Name: "node-exporter",
Expand All @@ -83,6 +82,8 @@ var NodeExporterJob = smd.Job{
}
```

<a name="NodeJob"></a>

```go
var NodeJob = smd.Job{
Name: "storage-node",
Expand All @@ -94,6 +95,10 @@ var NodeJob = smd.Job{
}
```

<a name="PlexJob"></a>PlexJob is the job definition for the plex service.

@DEPRECATED: This job is no longer used.

```go
var PlexJob = smd.Job{
Name: "plex",
Expand All @@ -119,20 +124,26 @@ var PlexJob = smd.Job{
}
```

PrometheusJob is a Job for the Prometheus service.
<a name="PrometheusJob"></a>PrometheusJob is a Job for the Prometheus service.

```go
var PrometheusJob = smd.Job{
Name: "prometheus",
Type: smd.SERVICE,
Target: smd.WORKER,
Target: smd.NODE,
Ports: smd.BasicPortConfig(9090),
Shape: smd.LARGE_TASK,
Templates: map[string]string{"prometheus.yml": promConfigHelper(prometheusConfig)},
Volumes: []smd.Volume{{Src: "local/config", Dst: "/etc/prometheus"}},
Args: []string{
"--web.external-url=http://slab.lan/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
},
}
```

<a name="PromtailJob"></a>

```go
var PromtailJob = smd.Job{
Name: "promtail",
Expand All @@ -152,34 +163,35 @@ var PromtailJob = smd.Job{
}
```

<a name="SpeedtestJob"></a>

```go
var SpeedtestJob = smd.Job{
Name: "speedtest",
Type: smd.SERVICE,
Target: smd.WORKER,
Target: smd.NODE,
Ports: smd.BasicPortConfig(80),
Shape: smd.XTINY_TASK,
}
```

<a name="TraefikJob"></a>TraefikJob is the job definition for the traefik service.

@DEPRECATED: This job is no longer used.

```go
var TraefikJob = slomad.Job{
Name: "traefik",
Type: slomad.SERVICE,
Target: slomad.WORKER_0,
Target: slomad.ALL,
Shape: slomad.DEFAULT_TASK,
Ports: []*slomad.Port{
{Label: "web", To: 0, From: 80, Static: true},
{Label: "websecure", To: 0, From: 443, Static: true},
{Label: "admin", To: 0, From: 8081, Static: true},
{Label: "web", To: 80, From: 81, Static: true},
{Label: "admin", To: 8080, From: 8081, Static: true},
},
Args: []string{
"--entryPoints.web.address=:80",
"--entryPoints.websecure.address=:443",
"--entryPoints.admin.address=:8081",
"--entrypoints.websecure.http.redirections.entryPoint.to=web",
"--entrypoints.websecure.http.redirections.entryPoint.scheme=http",
"--accesslog=true",
"--api=true",
"--api.dashboard=true",
"--api.insecure=true",
Expand All @@ -205,25 +217,50 @@ var TraefikJob = slomad.Job{
}
```

<a name="UptimeJob"></a>

```go
var UptimeJob = smd.Job{
Name: "uptime",
Type: smd.SERVICE,
Target: smd.NODE,
Ports: []*smd.Port{
{Label: "http", To: 3001, From: 3001, Static: true},
},
Shape: smd.DEFAULT_TASK,
}
```

<a name="WhoamiJob"></a>

```go
var WhoamiJob = smd.Job{
Name: "whoami",
Type: smd.SERVICE,
Target: smd.WORKER,
Target: smd.NODE,
Shape: smd.XXTINY_TASK,
Args: []string{"--port", "${NOMAD_PORT_http}"},
Ports: smd.BasicPortConfig(80),
TaskServiceTags: map[string][]string{
"whoami": {
"urlprefix-/whoami",
},
},
}
```

<a name="prometheusConfig"></a>

```go
var prometheusConfig string
```

<a name="promtailConfig"></a>

```go
var promtailConfig string
```

<a name="getStorageArgs"></a>
## func [getStorageArgs](<https://github.com/ecshreve/slomad/blob/main/internal/registry/storage.go#L31>)

```go
Expand All @@ -234,6 +271,7 @@ getStorageArgs returns the common args for the storage controller and node.

TODO: input validation

<a name="promConfigHelper"></a>
## func [promConfigHelper](<https://github.com/ecshreve/slomad/blob/main/internal/registry/services.go#L11>)

```go
Expand Down
Loading

0 comments on commit c605588

Please sign in to comment.