Add Postgres Service
This commit is contained in:
53
nomad_jobs/services/postgres/postgres.nomad.hcl
Normal file
53
nomad_jobs/services/postgres/postgres.nomad.hcl
Normal file
@@ -0,0 +1,53 @@
|
||||
job "postgres" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
group "database" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
mode = "bridge"
|
||||
port "ingress" {
|
||||
to = 5432
|
||||
}
|
||||
}
|
||||
|
||||
volume "postgres-data" {
|
||||
type = "host"
|
||||
source = "postgres"
|
||||
}
|
||||
|
||||
service {
|
||||
# Make available to other services by the 'postgres' name
|
||||
name = "postgres"
|
||||
port = "5432"
|
||||
tags = ["traefik.enable=false"] # Hide postgres from traefik
|
||||
|
||||
# Make available through the consul service mesh
|
||||
connect {
|
||||
sidecar_service {
|
||||
tags = ["traefik.enable=false"] # Hide postgres envoy from traefik
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task "postgres" {
|
||||
driver = "docker"
|
||||
|
||||
volume_mount {
|
||||
volume = "postgres-data"
|
||||
destination = "/var/lib/postgresql/data"
|
||||
}
|
||||
|
||||
config {
|
||||
image = "postgres:16.1-alpine3.19"
|
||||
ports = ["ingress"]
|
||||
}
|
||||
|
||||
env = {
|
||||
"POSTGRES_USER"="op://InfraSecrets/Postgres Root/username",
|
||||
"POSTGRES_PASSWORD"="op://InfraSecrets/Postgres Root/password"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user