Skip to content

Instantly share code, notes, and snippets.

View schmichael's full-sized avatar

Michael Schurter schmichael

View GitHub Profile
job "sysinfo" {
datacenters = ["dc1"]
type = "batch"
group "sysinfo" {
task "sysinfo" {
driver = "docker"
config {
// Windows 2019
job "example" {
datacenters = ["dc1"]
group "cache" {
network {
port "db" {
to = 6379
}
}
client {
host_network "public" {
cidr = "192.168.86.227/32"
}
}
job "hello" {
datacenters = ["dc1"]
type = "batch"
periodic {
cron = "* * * * * *"
}
task "hello" {

nomad job restart RFC

While Nomad has the ability to restart individual allocations and tasks, it lack the ability to restart entire jobs.

A new `nomad job restart command will fill this gap by adding the ability to restart all allocations for a job.

Behavior

Functionally job restart will be as if the user scripted a rolling nomad alloc restart for all allocs of a given job. Importantly job restart will not reschedule any allocations. It can be thought of an inplace update with nothing being updated.

job "workdir" {
type = "batch"
datacenters = ["dc1"]
task "workdir" {
driver = "exec"
config {
work_dir = "/etc"
command = "/usr/bin/pwd"
@schmichael
schmichael / simple.hcl
Last active August 11, 2021 22:25
Simple Nomad Hello World Job
job "example" {
datacenters = ["dc1"]
group "hello" {
task "hello" {
driver = "docker"
config {
image = "redis:3.2"
command = "/bin/bash"
time="2021-08-10T18:35:26Z" level=info msg="Input arguments: /px-oci-mon -c px-cluster-nomadv1 -a -b --endpoint 0.0.0.0:9015"
time="2021-08-10T18:35:26Z" level=info msg="Updated arguments: /px-oci-mon -c px-cluster-nomadv1 -a -b" install-opts=--upgrade
time="2021-08-10T18:35:26Z" level=info msg="OCI-Monitor computed version v2.8.0-gd252e59e-dirty"
time="2021-08-10T18:35:26Z" level=info msg="REAPER: Starting ..."
time="2021-08-10T18:35:26Z" level=info msg="Service handler initialized via as DBus{type:dbus,svc:portworx.service,id:0xc000543440}"
time="2021-08-10T18:35:26Z" level=info msg="Setting up container handler"
time="2021-08-10T18:35:26Z" level=info msg="> run-host: /bin/sh -c cat /etc/crictl.yaml || cat /var/vcap/store/crictl.yaml"
time="2021-08-10T18:35:26Z" level=info msg="Locating my container handler"
time="2021-08-10T18:35:26Z" level=info msg="Negotiated Docker API version: 1.32"
time="2021-08-10T18:35:26Z" level=info msg="> Using Docker as container handler"
job "min" {
datacenters = ["dc1"]
update {
stagger = "30s"
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "10m"
progress_deadline = "15m"
auto_revert = false
package main
import (
"log"
"os"
"time"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/jobspec"
)