nomad

HCL and Docker files for Nomad deployments
git clone https://git.in0rdr.ch/nomad.git
Log | Files | Refs | Pull requests |Archive

commit 5b19e08a022ff76750d7e281dca324e120bdbcfc
parent 35ee9833d60a9df603157cdb6172d312d0bd678a
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun, 21 Jul 2024 18:16:54 +0200

feat(snapshot): remove consul

Diffstat:
Mhcl/infra/snapshots/README | 25+++----------------------
Mhcl/infra/snapshots/nomad-snapshots.nomad | 9---------
Mhcl/infra/snapshots/templates/snapshot.sh.tmpl | 17++++++++---------
3 files changed, 11 insertions(+), 40 deletions(-)

diff --git a/hcl/infra/snapshots/README b/hcl/infra/snapshots/README @@ -1,7 +1,7 @@ NOMAD SNAPSHOTS --------------- -Run periodic Raft state snapshots for Consul and Nomad and store snapshots on NFS. +Run periodic Raft state snapshots for Nomad and store snapshots on NFS. This creates a parameterized job: - https://www.nomadproject.io/docs/job-specification/parameterized @@ -9,10 +9,9 @@ This creates a parameterized job: nomad run nomad-snapshots.nomad -The jobs can be dispatched to either take snapshots of Nomad or Consul state: +The jobs can be dispatched to take snapshots of Nomad state: - nomad job dispatch -meta service=nomad snapshot -- nomad job dispatch -meta service=consul snapshot -- nomad job dispatch -meta service=consul-kv snapshot +- nomad job dispatch -meta service=nomad-var snapshot The service meta parameter is required. @@ -22,24 +21,6 @@ EXEC DRIVER Exec driver is used (instead of raw_exec), because raw_exec does not support CSI volumes. Host volumes suck, because they require client reconfiguration. -CONSUL CONNECT --------------- - -This job leverages Consul connect integration to automagically access the -Consul API from the job. The consul API and the required CONSUL_ environment -variables are automatically exposed to the job in the "bridge" or "host" -network modes: - ->CONSUL_HTTP_ADDR: Will be automatically set to a unix domain socket in bridge ->networking mode, or a tcp address in host networking mode. -https://www.nomadproject.io/docs/runtime/environment - -The connection from the job to the Consul API is established as follows: -- "bridge" network mode: As socket mounted to the alloc dir, - CONSUL_HTTP_ADDR=unix:///alloc/tmp/consul_http.sock. -- "host" network mode: Directly through the tcp socket of the host network, - CONSUL_HTTP_ADDR=127.0.0.1:8501 - This job uses the "host" network mode. No CNI plugins are required. >To use bridge mode, you must have the reference CNI plugins installed diff --git a/hcl/infra/snapshots/nomad-snapshots.nomad b/hcl/infra/snapshots/nomad-snapshots.nomad @@ -30,15 +30,6 @@ job "snapshot" { mode = "host" } - service { - task = "snapshot-save" - connect { - # start this job as Consul connect native service - # to expose the CONSUL_ environment variables - native = true - } - } - task "snapshot-save" { driver = "exec" diff --git a/hcl/infra/snapshots/templates/snapshot.sh.tmpl b/hcl/infra/snapshots/templates/snapshot.sh.tmpl @@ -1,9 +1,9 @@ #!/usr/bin/env sh # -# Script to create snapshots from Nomad or Consul storage. -# Invoke with name of the service [nomad consul] as first arg. +# Script to create snapshots from Nomad. +# Invoke with name of the service as first arg. # -# Example: ./snapshot.sh consul-kv +# Example: ./snapshot.sh nomad set -o errexit set -o nounset @@ -16,14 +16,13 @@ case "$1" in nomad) nomad operator snapshot save ;; - consul) - consul snapshot save consul-state-{{ timestamp "20060102" }}-{{ timestamp "unix" }}.snap - ;; - consul-kv) - consul kv export > consul-kv-{{ timestamp "20060102" }}-{{ timestamp "unix" }}.json + nomad-var) + for v in $(nomad var list -out terse); do + nomad var get -out json $v >> nomad-var-{{ timestamp "20060102" }}-{{ timestamp "unix" }}.dump + done ;; *) - echo "Usage: $0 {nomad|consul|consul-kv}" + echo "Usage: $0 nomad" ;; esac