postgres/upgrade.nomad.hcl

52 lines
1.1 KiB
HCL

[[ $c := merge .pg.upgrade . -]]
job "[[ .instance ]]-upgrade" {
[[ template "common/job_start.tpl" $c ]]
type = "batch"
meta {
# Force job to be different for each execution
run_uuid = "${uuidv4()}"
}
group "upgrade" {
volume "data" {
type = [[ .pg.volumes.data.type | toJSON ]]
source = [[ .pg.volumes.data.source | toJSON ]]
[[- if ne .pg.volumes.data.type "host" ]]
access_mode = "single-node-writer"
attachment_mode = "file-system"
[[- end ]]
per_alloc = true
}
task "[[ .instance ]]-upgrade" {
driver = [[ $c.nomad.driver | toJSON ]]
config {
image = [[ $c.image | toJSON ]]
readonly_rootfs = true
}
env {
PG_FROM = [[ $c.from | toJSON ]]
PG_TO = [[ $c.to | toJSON ]]
PG_DO_UPGRADE = [[ $c.do_upgrade | toJSON ]]
}
[[ template "common/file_env.tpl" $c ]]
volume_mount {
volume = "data"
destination = "/data"
}
[[ template "common/resources.tpl" $c.resources ]]
}
}
}