Advertisement
Guest User

fedorm

a guest
Jan 22nd, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.33 KB | None | 0 0
  1. job "coupons-processing" {
  2.  
  3.   datacenters = [
  4.     "dc1"]
  5.  
  6.   type = "system"
  7.  
  8.   update {
  9.     max_parallel = 1
  10.     min_healthy_time = "30s"
  11.     healthy_deadline = "5m"
  12.     auto_revert = true
  13.   }
  14.  
  15.   group "processing" {
  16.     task "processing" {
  17.       driver = "docker"
  18.  
  19.       config {
  20.         image = "artifactory.setmachine.ru:5000/coupon-processing/psql:localtest"
  21.  
  22.         auth {
  23.           username = "admin"
  24.           password = "tc324012"
  25.         }
  26.  
  27.         port_map = {
  28.           http = 8008,
  29.           tcp = 5432
  30.         }
  31.  
  32.         dns_servers = [
  33.           "${NOMAD_IP_http}"]
  34.       }
  35.  
  36.       env {
  37.         "PATRONI_CONSUL_HOST" = "${NOMAD_IP_http}:8500"
  38.         "PATRONI_NAME" = "dbnode_${NOMAD_IP_http}"
  39.         "PATRONI_RESTAPI_CONNECT_ADDRESS" = "${NOMAD_IP_http}:8008"
  40.         "PATRONI_POSTGRESQL_CONNECT_ADDRESS" = "${NOMAD_IP_http}:5432"
  41.       }
  42.  
  43.       service {
  44.         name = "dbnode"
  45.         tags = [
  46.           "dbnode"]
  47.         port = "http"
  48.         check {
  49.           name = "alive"
  50.           type = "tcp"
  51.           interval = "10s"
  52.           timeout = "2s"
  53.         }
  54.       }
  55.  
  56.       resources {
  57.         cpu = 1000
  58.         memory = 1500
  59.         network {
  60.           port "http" {
  61.             static = "8008"
  62.           },
  63.           port "tcp" {
  64.             static = "5432"
  65.           }
  66.         }
  67.       }
  68.     }
  69.  
  70.     task "haproxy" {
  71.       driver = "docker"
  72.  
  73.       config {
  74.         image = "haproxy:alpine"
  75.  
  76.         port_map = {
  77.           http_5000 = 5000,
  78.           http_5001 = 5001,
  79.           http = 80
  80.         }
  81.  
  82.         volumes = [
  83.           "haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg"
  84.         ]
  85.  
  86.         dns_servers = [
  87.           "${NOMAD_IP_http}"]
  88.       }
  89.  
  90.       template {
  91.         data = <<EOH
  92.         global
  93.         maxconn 500
  94.  
  95.         defaults
  96.             log global
  97.             mode tcp
  98.             retries 2
  99.             timeout client 30m
  100.             timeout connect 4s
  101.             timeout server 30m
  102.             timeout check 5s
  103.  
  104.         frontend f_master_postgresql
  105.             bind *:5000
  106.             default_backend b_master_postgresql
  107.  
  108.         frontend f_slave_postgresql
  109.             bind *:5001
  110.             default_backend b_replica_postgresql
  111.  
  112.         backend b_master_postgresql
  113.             option httpchk OPTIONS /master
  114.             http-check expect status 200
  115.             default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
  116.             {{range $i, $services := service "dbnode"}}
  117.                 server dbnode{{ $i | add 1 }} {{.Address}}:5432 maxconn 200 check port 8008{{ end }}
  118.  
  119.  
  120.         backend b_replica_postgresql
  121.             option httpchk OPTIONS /replica
  122.             http-check expect status 200
  123.             default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
  124.             {{range $i, $services := service "dbnode"}}
  125.                 server dbnode{{ $i | add 1 }} {{.Address}}:5432 maxconn 200 check port 8008{{ end }}
  126.         EOH
  127.  
  128.         destination = "haproxy.cfg"
  129.       }
  130.  
  131.       service {
  132.         name = "haproxy"
  133.         tags = [
  134.           "global",
  135.           "lb",
  136.           "urlprefix-/haproxy"]
  137.         port = "http"
  138.         check {
  139.           name = "alive"
  140.           type = "tcp"
  141.           interval = "10s"
  142.           timeout = "2s"
  143.         }
  144.       }
  145.  
  146.       resources {
  147.         cpu = 1000
  148.         memory = 1500
  149.         network {
  150.           port "http_5000" {
  151.             static = "5000"
  152.           },
  153.           port "http_5001" {
  154.             static = "5001"
  155.           },
  156.           port "http" {
  157.             static = 80
  158.           }
  159.         }
  160.       }
  161.     }
  162.   }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement