Sign inSign up

multipathmaster/nomadsm

By multipathmaster

Updated about 9 years ago

Send Nomad job alerts to SLACK: 10MB

Image
0

287

multipathmaster/nomadsm repository overview

https://github.com/multipathmaster/nomadsm

#QUICK OVERVIEW: DEPLOYMENT RECENTLY RAN AGAINST CONSUL 1.0.0 and NOMAD 0.7.0 - WORKS - YES the deployment assumes you are running hashi-ui or some other clone/fork. docker-entrypoint.sh is the entrypoint. It calls upon dead_man_switch.sh. dead_man_switch.sh starts the nmd_evnt_mntr.sh instances, as well a providing other options. nmd_evnt_mntr.sh is a collection of event monitors that call upon slack_alert.sh once a condition is met. slack_alert.sh is the alerting mechanism.

STEPS FOR SOLO DEPLOYMENT:

  1. docker build . OR docker pull multipathmaster/nomadsm
  2. docker tag "ID FROM ABOVE" "NEW NAME" IGNORE IF DOCKER PULL
  3. docker run -it -e NOMAD_JOB_IPHN='http://NOMAD_SERVER_IP:4646/v1/jobs' -e NOMAD_SRV_JOB_PATH='http://NOMAD_SERVER_IP:3000/nomad/REGION/jobs' -e S_CHAN='CHAN_NAME_WO_#' -e S_USRNM='BOT_NAME' -e S_HOOK='https://hooks.slack.com/services/YOUR/TOKEN/HERE' -e S_PROXY='http://YOUR.PROXY.HERE:PORT/' "NEW IMAGE NAME" OR multipathmaster/nomadsm NOTE: THE PROXY IS OPTIONAL ONLY IF YOU NEED IT
  4. docker ps #FIND CONTAINER
  5. docker exec -it "CONTAINER" bash

STEPS FOR DEPLOYING ON THE HASHICORP STACK: (CONSUL/NOMAD):

  1. docker build . OR docker pull multipathmaster/nomadsm
  2. docker tag "ID FROM ABOVE" "NEW NAME"
  3. export the image however you wish and place it in a repo. i use a local repo w/ a simple registry container on port 5000. i.e. you can use artifactory or something similar instead. Or use multipathmaster/nomadsm.
  4. copy the below config into nomadsm.nomad (or whatever_name_you_wish.nomad/json/etc...)
job "nomadsm" {
  region = "YOUR_REGION"
  datacenters = ["YOUR_DC"]
  type = "service"
   constraint {
     attribute = "${attr.kernel.name}"
     value     = "linux"
   }
  update {
    stagger = "15s"
    max_parallel = 1
  }
  group "nomadsm" {
    count = 1
    constraint {
      operator = "distinct_hosts"
      value    = "true"
    }
    restart {
      attempts = 10
      interval = "5m"
      delay = "25s"
      mode = "delay"
    }
    ephemeral_disk {
      size = 128
    }
    task "nomadsm" {
      driver = "docker"
      config {
        image = "multipathmaster/nomadsm:latest"
        network_mode = "host"
        port_map = {
        }
        #volumes = [ "" ]
      }
      env {
        NOMAD_JOB_IPHN="http://NOMAD_SERVER_IP:4646/v1/jobs"
        NOMAD_SRV_JOB_PATH="http://NOMAD_SERVER_IP:3000/nomad/REGION/jobs"
        S_CHAN="SLACK_CHANNEL_WO_#"
        S_USRNM="BOT_NAME"
        S_HOOK="https://hooks.slack.com/services/YOUR/TOKEN/HERE"
        S_PROXY="http://YOUR.PROXY.HERE:PORT/" #OPTIONAL ONLY IF YOU NEED THIS
      }
      resources {
        cpu    = 32
        memory = 64
        network {
          mbits = 10
        }
      }
      service {
        name = "nomadsm"
        tags = ["nomadsm"]
        #port = "nomadsm"
        #check {
        #  name     = "alive"
        #  type     = "tcp"
        #  interval = "15s"
        #  timeout  = "3s"
        #}
      }
    }
  }
}
  1. nomad plan nomadsm.nomad
  2. make any adjustments to the plan as you see fit(i.e. task/group/resources/service changes).
  3. nomad run nomadsm.nomad

Tag summary

Content type

Image

Digest

Size

4.2 MB

Last updated

about 9 years ago

docker pull multipathmaster/nomadsm