Nomad examples?

1,197 views
Skip to first unread message

Long Nguyen

unread,
Feb 28, 2017, 10:03:43 PM2/28/17
to Nomad
Hi all,
   Does anyone have good nomad job examples? I'm a hard time trying to get some basic things like postgres up and running. (https://gist.github.com/lnguyen/03e46a0cbfbaa5b341dbb113000365df). Looking for templates examples and connecting services examples as well.

Thanks,
Long

Alex Dadgar

unread,
Mar 1, 2017, 4:38:40 PM3/1/17
to Nomad, Long Nguyen
Hey,


You can also run `nomad init` which will output an example job for reference.

Thanks,
Alex Dadgar
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/nomad/issues
IRC: #nomad-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Nomad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nomad-tool+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nomad-tool/0936053e-4e7f-4ecb-9448-89a8cb3944e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

h...@cn.tradeshift.com

unread,
Mar 17, 2017, 5:05:13 AM3/17/17
to Nomad
Hi,Alex
   I see these examples through following link that you provided ,but I change to it as my own scripts,you can see it as follows

 job "nginx" {
    region = "office"
    datacenters = ["west"]
    type = "service"
    all_at_once = false
    group "nginx" {
        count = 1
        restart {
            attempts = 10
            delay = "15s"
            interval = "5m"
            mode = "delay"
        }

        # Create service using a docker image
task "nginx-ck" {
    driver = "exec"
           config {
               command = "tail"
               args = ["-f", "/dev/null"]
           }
           resources {
                   network {
                       mbits = 1
                       port "nginx" {}
                   }
               }
            service {
              name = "nginx"
              tags = ["frontend", "dev"]
              port = "nginx"
              check {
                type = "tcp"
                interval = "5s"
                timeout = "2s"
              }
            }
}
        task "nginx" {

            driver = "docker"

            logs {
                max_files = 3
                max_file_size = 100
            }
            config {
                image = "172.16.30.80:5000/nginx:bwts"
                port_map {
                    service_port = 80
                }
            }

            resources {
                cpu = 512
                memory = 2048
                network {
                  mbits = 82
         port "service_port" {}
                }
                disk = 2048
            }

            env {

            }
        }
    }

}

when I run nomad 

root@nomad01:~# nomad run test.hcl
==> Monitoring evaluation "eba31fd3"
    Evaluation triggered by job "nginx"
    Allocation "e861342e" created: node "7a326813", group "nginx"
    Evaluation status changed: "pending" -> "complete"
==> Evaluation "eba31fd3" finished with status "complete"
root@nomad01:~# nomad status nginx
ID          = nginx
Name        = nginx
Type        = service
Priority    = 50
Datacenters = west
Status      = running
Periodic    = false

Summary
Task Group  Queued  Starting  Running  Failed  Complete  Lost
nginx       0       0         1        0       0         0

Allocations
ID        Eval ID   Node ID   Task Group  Desired  Status    Created At
e861342e  eba31fd3  7a326813  nginx       run      running   03/17/17 16:56:17 CST
bdac2446  4cb2e612  e4a22183  nginx       stop     complete  03/17/17 15:50:38 CST
root@nomad01:~#
root@nomad01:~#
root@nomad01:~#
root@nomad01:~# nomad alloc-status e861342e
ID            = e861342e
Eval ID       = eba31fd3
Name          = nginx.nginx[0]
Node ID       = 7a326813
Job ID        = nginx
Client Status = running

Task "nginx" is "running"
Task Resources
CPU        Memory           Disk     IOPS  Addresses
0/512 MHz  102 MiB/2.0 GiB  2.0 GiB  0     service_port: 172.16.30.111:35632

Recent Events:
Time                   Type      Description
03/17/17 16:55:45 CST  Started   Task started by client
03/17/17 16:55:36 CST  Received  Task received by client

Task "nginx-ck" is "running"
Task Resources
CPU        Memory          Disk     IOPS  Addresses
9/100 MHz  848 KiB/10 MiB  300 MiB  0     nginx: 172.16.30.111:24091

Recent Events:
Time                   Type      Description
03/17/17 16:56:21 CST  Started   Task started by client
03/17/17 16:55:36 CST  Received  Task received by client

I find nginx-ck is not the job that can monitor or check nginx's healthy state,because this task check 172.16.30.111:24091,and the docker is 172.16.30.111:35632,so I can't understand the working principle between these two tasks ,so can you explain it ?
Reply all
Reply to author
Forward
0 new messages