github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consul/input/namespaces/connect_sidecars.nomad (about)

     1  job "connect_sidecars" {
     2    datacenters = ["dc1"]
     3    type        = "service"
     4  
     5    constraint {
     6      attribute = "${attr.kernel.name}"
     7      value     = "linux"
     8    }
     9  
    10    group "api" {
    11  
    12      consul {
    13        namespace = "apple"
    14      }
    15  
    16      network {
    17        mode = "bridge"
    18      }
    19  
    20      service {
    21        name = "count-api"
    22        port = "9001"
    23  
    24        connect {
    25          sidecar_service {}
    26        }
    27  
    28        check {
    29          expose   = true
    30          name     = "api-health"
    31          type     = "http"
    32          path     = "/health"
    33          interval = "5s"
    34          timeout  = "3s"
    35        }
    36      }
    37  
    38      task "web" {
    39        driver = "docker"
    40  
    41        config {
    42          image = "hashicorpdev/counter-api:v3"
    43        }
    44      }
    45    }
    46  
    47    group "api-z" {
    48  
    49      # consul namespace not set
    50  
    51      network {
    52        mode = "bridge"
    53      }
    54  
    55      service {
    56        name = "count-api-z"
    57        port = "9001"
    58  
    59        connect {
    60          sidecar_service {}
    61        }
    62  
    63        check {
    64          expose   = true
    65          name     = "api-health"
    66          type     = "http"
    67          path     = "/health"
    68          interval = "5s"
    69          timeout  = "3s"
    70        }
    71      }
    72  
    73      task "web-z" {
    74        driver = "docker"
    75  
    76        config {
    77          image = "hashicorpdev/counter-api:v3"
    78        }
    79      }
    80    }
    81  
    82    group "dashboard" {
    83  
    84      consul {
    85        namespace = "apple"
    86      }
    87  
    88      network {
    89        mode = "bridge"
    90  
    91        port "http" {
    92          static = 9002
    93          to     = 9002
    94        }
    95      }
    96  
    97      service {
    98        name = "count-dashboard"
    99        port = "9002"
   100  
   101        connect {
   102          sidecar_service {
   103            proxy {
   104              upstreams {
   105                destination_name = "count-api"
   106                local_bind_port  = 8080
   107              }
   108            }
   109          }
   110        }
   111      }
   112  
   113      task "dashboard" {
   114        driver = "docker"
   115  
   116        env {
   117          COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
   118        }
   119  
   120        config {
   121          image = "hashicorpdev/counter-dashboard:v3"
   122        }
   123      }
   124    }
   125  
   126    group "dashboard-z" {
   127  
   128      # consul namespace not set
   129  
   130      network {
   131        mode = "bridge"
   132  
   133        port "http" {
   134          static = 9003
   135          to     = 9002
   136        }
   137      }
   138  
   139      service {
   140        name = "count-dashboard-z"
   141        port = "9003"
   142  
   143        connect {
   144          sidecar_service {
   145            proxy {
   146              upstreams {
   147                destination_name = "count-api-z"
   148                local_bind_port  = 8080
   149              }
   150            }
   151          }
   152        }
   153      }
   154  
   155      task "dashboard" {
   156        driver = "docker"
   157  
   158        env {
   159          COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api-z}"
   160        }
   161  
   162        config {
   163          image = "hashicorpdev/counter-dashboard:v3"
   164        }
   165      }
   166    }
   167  }