Skip to content

Instantly share code, notes, and snippets.

@asrivascrealytee
Last active March 11, 2019 12:15
Show Gist options
  • Save asrivascrealytee/c9d9ca06006cff0fcd79dd21fc43e683 to your computer and use it in GitHub Desktop.
Save asrivascrealytee/c9d9ca06006cff0fcd79dd21fc43e683 to your computer and use it in GitHub Desktop.
nomad-resources

stateful apps


  • Convert hcl to json for deployed jobs
nomad init
nomad run example.nomad
nomad inspect example > job.json
(can stop the job so you can see it gets re-registered)
curl -XPUT -d @job.json http://127.0.0.1:4646/v1/job/example

nomad run -output template.hcl > template.json

@asrivascrealytee
Copy link
Author

job "staging/docs" {
  datacenters = ["dc1"]

  group "staging/example" {
    meta {
      ENVIRONMENT = "staging"
    }

    task "server" {
      driver = "docker"

      config {
        image = "hashicorp/http-echo"

        args = [
          "-listen",
          ":5678",
          "-text",
          "${NOMAD_META_ENVIRONMENT}",
        ]

        # port_map {
        #   web = 5678
        # }
      }

      resources {
        network {
          mbits = 10

          port "http" {
            static = 5678
          }
        }
      }
    }
  }
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment