Advertisement
Guest User

fedorm

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