github.com/hernad/nomad@v1.6.112/e2e/consul/input/namespaces/services_task.nomad (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  job "services_task" {
     5    datacenters = ["dc1"]
     6    type        = "service"
     7  
     8    constraint {
     9      attribute = "${attr.kernel.name}"
    10      value     = "linux"
    11    }
    12  
    13    group "group-b" {
    14  
    15      consul {
    16        namespace = "banana"
    17      }
    18  
    19      network {
    20        mode = "bridge"
    21        port "port-b" {
    22          to = 1234
    23        }
    24      }
    25  
    26      task "task-b" {
    27        driver = "docker"
    28  
    29        config {
    30          image   = "busybox:1"
    31          command = "nc"
    32          args    = ["-ll", "-p", "1234", "-e", "/bin/cat"]
    33        }
    34  
    35        service {
    36          name = "b1"
    37          port = "port-b"
    38  
    39          check {
    40            name     = "ping-b1"
    41            type     = "tcp"
    42            interval = "10s"
    43            timeout  = "2s"
    44          }
    45        }
    46  
    47        service {
    48          name = "b2"
    49          port = "port-b"
    50  
    51          check {
    52            name     = "ping-b2"
    53            type     = "tcp"
    54            interval = "10s"
    55            timeout  = "2s"
    56          }
    57        }
    58      }
    59    }
    60  
    61    group "group-c" {
    62  
    63      consul {
    64        namespace = "cherry"
    65      }
    66  
    67      network {
    68        mode = "bridge"
    69        port "port-c" {
    70          to = 1234
    71        }
    72      }
    73  
    74      task "task-c" {
    75        driver = "docker"
    76  
    77        config {
    78          image   = "busybox:1"
    79          command = "nc"
    80          args    = ["-ll", "-p", "1234", "-e", "/bin/cat"]
    81        }
    82  
    83        service {
    84          name = "c1"
    85          port = "port-c"
    86  
    87          check {
    88            name     = "ping-c1"
    89            type     = "tcp"
    90            interval = "10s"
    91            timeout  = "2s"
    92          }
    93        }
    94  
    95        service {
    96          name = "c2"
    97          port = "port-c"
    98  
    99          check {
   100            name     = "ping-c2"
   101            type     = "tcp"
   102            interval = "10s"
   103            timeout  = "2s"
   104          }
   105        }
   106      }
   107    }
   108  
   109    group "group-z" {
   110  
   111      # consul namespace not set
   112  
   113      network {
   114        mode = "bridge"
   115        port "port-z" {
   116          to = 1234
   117        }
   118      }
   119  
   120      task "task-z" {
   121        driver = "docker"
   122  
   123        config {
   124          image   = "busybox:1"
   125          command = "nc"
   126          args    = ["-ll", "-p", "1234", "-e", "/bin/cat"]
   127        }
   128  
   129        service {
   130          name = "z1"
   131          port = "port-z"
   132  
   133          check {
   134            name     = "ping-z1"
   135            type     = "tcp"
   136            interval = "10s"
   137            timeout  = "2s"
   138          }
   139        }
   140  
   141        service {
   142          name = "z2"
   143          port = "port-z"
   144  
   145          check {
   146            name     = "ping-z2"
   147            type     = "tcp"
   148            interval = "10s"
   149            timeout  = "2s"
   150          }
   151        }
   152      }
   153    }
   154  }