github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consul/input/namespaces/script_checks_group.nomad (about) 1 job "script_checks_group" { 2 datacenters = ["dc1"] 3 type = "service" 4 5 constraint { 6 attribute = "${attr.kernel.name}" 7 value = "linux" 8 } 9 10 group "group-a" { 11 12 consul { 13 namespace = "apple" 14 } 15 16 network { 17 mode = "bridge" 18 } 19 20 service { 21 name = "service-1a" 22 port = "9001" 23 24 check { 25 name = "alive-1" 26 type = "script" 27 task = "test" 28 interval = "2s" 29 timeout = "2s" 30 command = "echo" 31 args = ["alive-1"] 32 } 33 } 34 35 service { 36 name = "service-2a" 37 port = "9002" 38 39 check { 40 name = "alive-2a" 41 type = "script" 42 task = "test" 43 interval = "2s" 44 timeout = "2s" 45 command = "echo" 46 args = ["alive-2a"] 47 } 48 49 # the file expected by this check will not exist when started, 50 # so the check will error-out and be in a warning state until 51 # it's been created 52 check { 53 name = "alive-2ab" 54 type = "script" 55 task = "test" 56 interval = "2s" 57 timeout = "2s" 58 command = "cat" 59 args = ["/tmp/${NOMAD_ALLOC_ID}-alive-2ab"] 60 } 61 } 62 63 service { 64 name = "service-3a" 65 port = "9003" 66 67 # this check should always time out and so the service 68 # should not be marked healthy 69 check { 70 name = "always-dead" 71 type = "script" 72 task = "test" 73 interval = "2s" 74 timeout = "1s" 75 command = "sleep" 76 args = ["10"] 77 } 78 } 79 80 task "test" { 81 driver = "raw_exec" 82 83 config { 84 command = "bash" 85 args = ["-c", "sleep 15000"] 86 } 87 } 88 } 89 90 group "group-z" { 91 92 # no consul namespace set 93 94 network { 95 mode = "bridge" 96 } 97 98 service { 99 name = "service-1z" 100 port = "9001" 101 102 check { 103 name = "alive-1z" 104 type = "script" 105 task = "test" 106 interval = "2s" 107 timeout = "2s" 108 command = "echo" 109 args = ["alive-1"] 110 } 111 } 112 113 service { 114 name = "service-2z" 115 port = "9002" 116 117 check { 118 name = "alive-2z" 119 type = "script" 120 task = "test" 121 interval = "2s" 122 timeout = "2s" 123 command = "echo" 124 args = ["alive-2z"] 125 } 126 127 # the file expected by this check will not exist when started, 128 # so the check will error-out and be in a warning state until 129 # it's been created 130 check { 131 name = "alive-2zb" 132 type = "script" 133 task = "test" 134 interval = "2s" 135 timeout = "2s" 136 command = "cat" 137 args = ["/tmp/${NOMAD_ALLOC_ID}-alive-2zb"] 138 } 139 } 140 141 service { 142 name = "service-3z" 143 port = "9003" 144 145 # this check should always time out and so the service 146 # should not be marked healthy 147 check { 148 name = "always-dead" 149 type = "script" 150 task = "test" 151 interval = "2s" 152 timeout = "1s" 153 command = "sleep" 154 args = ["10"] 155 } 156 } 157 158 task "test" { 159 driver = "raw_exec" 160 161 config { 162 command = "bash" 163 args = ["-c", "sleep 15000"] 164 } 165 } 166 } 167 }