Skip to content

Commit

Permalink
services/nomad/apps/popcorn-report.nomad: add nomad job
Browse files Browse the repository at this point in the history
this component of popcorn reads what statrepo has collected and dumps it
to json every night. these json dumps are used by pqueryd and served by nginx.
  • Loading branch information
classabbyamp committed Jul 4, 2024
1 parent 177cfbd commit 54df6ec
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions services/nomad/apps/popcorn-report.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
job "popcorn-report" {
datacenters = ["VOID"]
namespace = "apps"
type = "batch"

periodic {
crons = ["@daily"]
prohibit_overlap = true
}

group "report" {
count = 1

volume "popcorn_data" {
type = "host"
source = "popcorn_data"
read_only = false
}

task "report" {
driver = "docker"

config {
image = "ghcr.io/void-linux/infra-popcorn:TODO"
command = "/local/popcorn-report"
}

volume_mount {
volume = "popcorn_data"
destination = "/data"
}

env {
OUTDIR = "/data"
}

template {
data = <<EOF
{{ $allocID := env "NOMAD_ALLOC_ID" -}}
#!/bin/sh
{{- range nomadService 1 $allocID "popcorn-statrepo" -}}
exec popcornctl --server "{{ .Address }}" --port "{{ .Port }}" \
report --reset --key "${POPCORN_KEY}" --file "${OUTDIR}/popcorn_$(date +%F).json"
{{- end -}}
EOF
destination = "local/popcorn-report"
perms = "755"
}

template {
data = <<EOF
{{- with nomadVar "nomad/jobs/popcorn" -}}
POPCORN_KEY={{.reset_key}}
{{- end -}}
EOF
destination = "secrets/env"
env = true
}
}
}
}

0 comments on commit 54df6ec

Please sign in to comment.