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

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