Advertisement
fedorm

Untitled

Jan 25th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 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. force_pull = true
  32.  
  33. dns_servers = ["${NOMAD_IP_http}"]
  34.  
  35. }
  36.  
  37. env {
  38. "PATRONI_CONSUL_HOST"="${NOMAD_IP_http}:8500"
  39. "PATRONI_NAME"="dbnode_${NOMAD_IP_http}"
  40. "PATRONI_RESTAPI_CONNECT_ADDRESS"="${NOMAD_IP_http}:8008"
  41. "PATRONI_POSTGRESQL_CONNECT_ADDRESS"="${NOMAD_IP_http}:5432"
  42. }
  43.  
  44. service {
  45. name = "dbnode"
  46. tags = ["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 = ["${NOMAD_IP_http}"]
  87. }
  88.  
  89. template {
  90. data = <<EOH
  91. global
  92. maxconn 500
  93.  
  94. defaults
  95. log global
  96. mode tcp
  97. retries 2
  98. timeout client 30m
  99. timeout connect 4s
  100. timeout server 30m
  101. timeout check 5s
  102.  
  103. frontend f_master_postgresql
  104. bind *:5000
  105. default_backend b_master_postgresql
  106.  
  107. frontend f_slave_postgresql
  108. bind *:5001
  109. default_backend b_replica_postgresql
  110.  
  111. backend b_master_postgresql
  112. option httpchk OPTIONS /master
  113. http-check expect status 200
  114. default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
  115. {{range $i, $services := service "dbnode"}}
  116. server dbnode{{ $i | add 1 }} {{.Address}}:5432 maxconn 200 check port 8008{{ end }}
  117.  
  118. backend b_replica_postgresql
  119. option httpchk OPTIONS /replica
  120. http-check expect status 200
  121. default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
  122. {{range $i, $services := service "dbnode"}}
  123. server dbnode{{ $i | add 1 }} {{.Address}}:5432 maxconn 200 check port 8008{{ end }}
  124. EOH
  125.  
  126. destination = "haproxy.cfg"
  127. }
  128.  
  129. service {
  130. name = "haproxy"
  131. tags = [ "global", "lb", "urlprefix-/haproxy" ]
  132. port = "http"
  133. check {
  134. name = "alive"
  135. type = "tcp"
  136. interval = "10s"
  137. timeout = "2s"
  138. }
  139. }
  140.  
  141. resources {
  142. cpu = 1000
  143. memory = 1500
  144. network {
  145. port "http_5000" {
  146. static = "5000"
  147. },
  148. port "http_5001" {
  149. static = "5001"
  150. },
  151. port "http" {
  152. static = 80
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement