aboutsummaryrefslogtreecommitdiff
path: root/app/postgres/deploy/postgres.hcl
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2021-01-18 08:18:21 +0100
committerQuentin <quentin@dufour.io>2021-01-18 08:18:21 +0100
commitad6017eea058f7cb6fdf078783f992a4f45a3e15 (patch)
tree6620bcc9e1ea61a5689b763b9ad8280275e35e76 /app/postgres/deploy/postgres.hcl
parent79b7273ff2a487d6721d393682c8ad3927467a75 (diff)
parentc642370def01f09d966b3b9c643cfe416ea115cf (diff)
downloadinfrastructure-ad6017eea058f7cb6fdf078783f992a4f45a3e15.tar.gz
infrastructure-ad6017eea058f7cb6fdf078783f992a4f45a3e15.zip
Merge pull request 'Reorganize app/ and add script for secret management' (#29) from test_reorganize into master
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/infrastructure/pulls/29
Diffstat (limited to 'app/postgres/deploy/postgres.hcl')
-rw-r--r--app/postgres/deploy/postgres.hcl134
1 files changed, 134 insertions, 0 deletions
diff --git a/app/postgres/deploy/postgres.hcl b/app/postgres/deploy/postgres.hcl
new file mode 100644
index 0000000..f5eec51
--- /dev/null
+++ b/app/postgres/deploy/postgres.hcl
@@ -0,0 +1,134 @@
+job "postgres" {
+ datacenters = ["dc1"]
+ type = "system"
+ priority = 90
+
+ update {
+ max_parallel = 1
+ stagger = "2m"
+ }
+
+ group "postgres" {
+ network {
+ port "psql_proxy_port" { static = 5432 }
+ port "psql_port" { static = 5433 }
+ }
+
+ task "sentinel" {
+ driver = "docker"
+
+ config {
+ image = "superboum/amd64_postgres:v3"
+ network_mode = "host"
+ readonly_rootfs = false
+ command = "/usr/local/bin/stolon-sentinel"
+ args = [
+ "--cluster-name", "pissenlit",
+ "--store-backend", "consul",
+ "--store-endpoints", "http://consul.service.2.cluster.deuxfleurs.fr:8500",
+ ]
+ }
+ resources {
+ memory = 100
+ }
+ }
+
+ task "proxy" {
+ driver = "docker"
+
+ config {
+ image = "superboum/amd64_postgres:v3"
+ network_mode = "host"
+ readonly_rootfs = false
+ command = "/usr/local/bin/stolon-proxy"
+ args = [
+ "--cluster-name", "pissenlit",
+ "--store-backend", "consul",
+ "--store-endpoints", "http://consul.service.2.cluster.deuxfleurs.fr:8500",
+ "--port", "${NOMAD_PORT_psql_proxy_port}",
+ "--listen-address", "0.0.0.0"
+ ]
+ ports = [ "psql_proxy_port" ]
+ }
+
+ resources {
+ memory = 100
+ }
+
+ service {
+ tags = ["sql"]
+ port = "psql_proxy_port"
+ address_mode = "host"
+ name = "psql-proxy"
+ check {
+ type = "tcp"
+ port = "psql_proxy_port"
+ interval = "60s"
+ timeout = "5s"
+ check_restart {
+ limit = 3
+ grace = "10m"
+ ignore_warnings = false
+ }
+ }
+ }
+ }
+
+ task "keeper" {
+ driver = "docker"
+
+ config {
+ image = "superboum/amd64_postgres:v3"
+ network_mode = "host"
+ readonly_rootfs = false
+ command = "/usr/local/bin/stolon-keeper"
+ args = [
+ "--cluster-name", "pissenlit",
+ "--store-backend", "consul",
+ "--store-endpoints", "http://consul.service.2.cluster.deuxfleurs.fr:8500",
+ "--data-dir", "/mnt/persist",
+ "--pg-su-password", "${PG_SU_PWD}",
+ "--pg-repl-username", "${PG_REPL_USER}",
+ "--pg-repl-password", "${PG_REPL_PWD}",
+ "--pg-listen-address", "${attr.unique.network.ip-address}",
+ "--pg-port", "${NOMAD_PORT_psql_port}",
+ "--pg-bin-path", "/usr/lib/postgresql/9.6/bin/"
+ ]
+ ports = [ "psql_port" ]
+ volumes = [
+ "/mnt/ssd/postgres:/mnt/persist"
+ ]
+ }
+
+ template {
+ data = file("../config/keeper/env.tpl")
+ destination = "secrets/env"
+ env = true
+ }
+
+ resources {
+ memory = 500
+ }
+
+ service {
+ tags = ["sql"]
+ port = "psql_port"
+ address_mode = "host"
+ name = "keeper"
+ check {
+ type = "tcp"
+ port = "psql_port"
+ interval = "60s"
+ timeout = "5s"
+
+ check_restart {
+ limit = 3
+ grace = "60m"
+ ignore_warnings = false
+ }
+ }
+ }
+ }
+ }
+}
+