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

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  job "connect_terminating" {
     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 = "host"
    21        port "port" {
    22          static = "9001"
    23        }
    24      }
    25  
    26      service {
    27        name = "count-api"
    28        port = "port"
    29      }
    30  
    31      task "api" {
    32        driver = "docker"
    33  
    34        config {
    35          image        = "hashicorpdev/counter-api:v3"
    36          network_mode = "host"
    37        }
    38  
    39        env {
    40          PORT = "${NOMAD_PORT_port}"
    41        }
    42      }
    43    }
    44  
    45    group "api-z" {
    46  
    47      # consul namespace not set
    48  
    49      network {
    50        mode = "host"
    51        port "port" {
    52          static = "9011"
    53        }
    54      }
    55  
    56      service {
    57        name = "count-api-z"
    58        port = "port"
    59      }
    60  
    61      task "api" {
    62        driver = "docker"
    63  
    64        config {
    65          image        = "hashicorpdev/counter-api:v3"
    66          network_mode = "host"
    67        }
    68  
    69        env {
    70          PORT = "${NOMAD_PORT_port}"
    71        }
    72      }
    73    }
    74  
    75    group "gateway" {
    76  
    77      consul {
    78        namespace = "apple"
    79      }
    80  
    81      network {
    82        mode = "bridge"
    83      }
    84  
    85      service {
    86        name = "api-gateway"
    87  
    88        connect {
    89          gateway {
    90            terminating {
    91              service {
    92                name = "count-api"
    93              }
    94            }
    95          }
    96        }
    97      }
    98    }
    99  
   100    group "gateway-z" {
   101  
   102      # consul namespace not set
   103  
   104      network {
   105        mode = "bridge"
   106      }
   107  
   108      service {
   109        name = "api-gateway-z"
   110  
   111        connect {
   112          gateway {
   113            terminating {
   114              service {
   115                name = "count-api-z"
   116              }
   117            }
   118          }
   119        }
   120      }
   121    }
   122  
   123    group "dashboard" {
   124  
   125      consul {
   126        namespace = "apple"
   127      }
   128  
   129      network {
   130        mode = "bridge"
   131  
   132        port "http" {
   133          static = 9002
   134          to     = 9002
   135        }
   136      }
   137  
   138      service {
   139        name = "count-dashboard"
   140        port = "9002"
   141  
   142        connect {
   143          sidecar_service {
   144            proxy {
   145              upstreams {
   146                destination_name = "count-api"
   147                local_bind_port  = 8080
   148              }
   149            }
   150          }
   151        }
   152      }
   153  
   154      task "dashboard" {
   155        driver = "docker"
   156  
   157        env {
   158          COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
   159        }
   160  
   161        config {
   162          image = "hashicorpdev/counter-dashboard:v3"
   163        }
   164      }
   165    }
   166  
   167    group "dashboard-z" {
   168  
   169      # consul namespace not set
   170  
   171      network {
   172        mode = "bridge"
   173  
   174        port "http" {
   175          static = 9012
   176          to     = 9002
   177        }
   178      }
   179  
   180      service {
   181        name = "count-dashboard-z"
   182        port = "9012"
   183  
   184        connect {
   185          sidecar_service {
   186            proxy {
   187              upstreams {
   188                destination_name = "count-api-z"
   189                local_bind_port  = 8080
   190              }
   191            }
   192          }
   193        }
   194      }
   195  
   196      task "dashboard" {
   197        driver = "docker"
   198  
   199        env {
   200          COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api-z}"
   201        }
   202  
   203        config {
   204          image = "hashicorpdev/counter-dashboard:v3"
   205        }
   206      }
   207    }
   208  }