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