chore(n8n): add module and job specification for Nomad deployment
This commit is contained in:
parent
2c3fd199c1
commit
28e9ead743
3 changed files with 136 additions and 0 deletions
97
modules/n8n/jobspec.nomad.hcl
Normal file
97
modules/n8n/jobspec.nomad.hcl
Normal file
|
@ -0,0 +1,97 @@
|
|||
job "n8n" {
|
||||
|
||||
group "n8n" {
|
||||
|
||||
network {
|
||||
mode = "bridge"
|
||||
port "http" {
|
||||
to = 5678
|
||||
}
|
||||
port "envoy_metrics" {
|
||||
to = 9102
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
provider = "consul"
|
||||
port = "5678"
|
||||
|
||||
meta {
|
||||
envoy_metrics_port = "${NOMAD_HOST_PORT_envoy_metrics}"
|
||||
}
|
||||
|
||||
connect {
|
||||
sidecar_service {
|
||||
proxy {
|
||||
config {
|
||||
protocol = "http"
|
||||
}
|
||||
expose {
|
||||
path {
|
||||
path = "/metrics"
|
||||
protocol = "http"
|
||||
local_path_port = 9102
|
||||
listener_port = "envoy_metrics"
|
||||
}
|
||||
}
|
||||
transparent_proxy {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tags = [
|
||||
"traefik.enable=true",
|
||||
|
||||
"traefik.http.routers.n8n.rule=Host(`n8n.brmartin.co.uk`)",
|
||||
"traefik.http.routers.n8n.entrypoints=websecure",
|
||||
"traefik.consulcatalog.connect=true",
|
||||
]
|
||||
}
|
||||
|
||||
volume "data" {
|
||||
type = "csi"
|
||||
read_only = false
|
||||
source = "martinibar_prod_n8n_data"
|
||||
attachment_mode = "file-system"
|
||||
access_mode = "multi-node-single-writer"
|
||||
}
|
||||
|
||||
task "n8n" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "docker.n8n.io/n8nio/n8n:1.97.0"
|
||||
}
|
||||
|
||||
env = {
|
||||
DB_TYPE = "postgresdb"
|
||||
DB_POSTGRESDB_DATABASE = "n8n"
|
||||
DB_POSTGRESDB_HOST = "martinibar.lan"
|
||||
DB_POSTGRESDB_PORT = "5433"
|
||||
DB_POSTGRESDB_USER = "n8n"
|
||||
DB_POSTGRESDB_SCHEMA = "n8n"
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<-EOF
|
||||
{{ with nomadVar "nomad/jobs/n8n/n8n/n8n" }}
|
||||
DB_POSTGRESDB_PASSWORD={{.db_password}}
|
||||
{{ end }}
|
||||
EOF
|
||||
|
||||
destination = "secrets/file.env"
|
||||
env = true
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 500
|
||||
memory = 1024
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "data"
|
||||
destination = "/home/node/.n8n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
modules/n8n/main.tf
Normal file
35
modules/n8n/main.tf
Normal file
|
@ -0,0 +1,35 @@
|
|||
resource "nomad_job" "n8n" {
|
||||
depends_on = [
|
||||
nomad_csi_volume_registration.nfs_volume,
|
||||
]
|
||||
|
||||
jobspec = file("${path.module}/jobspec.nomad.hcl")
|
||||
}
|
||||
|
||||
data "nomad_plugin" "nfs" {
|
||||
plugin_id = "nfs"
|
||||
wait_for_healthy = true
|
||||
}
|
||||
|
||||
resource "nomad_csi_volume_registration" "nfs_volume" {
|
||||
depends_on = [data.nomad_plugin.nfs]
|
||||
|
||||
lifecycle {
|
||||
prevent_destroy = true
|
||||
}
|
||||
|
||||
plugin_id = "nfs"
|
||||
name = "martinibar_prod_n8n_data"
|
||||
volume_id = "martinibar_prod_n8n_data"
|
||||
external_id = "martinibar_prod_n8n_data"
|
||||
|
||||
capability {
|
||||
access_mode = "multi-node-single-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
"server" = "martinibar.lan",
|
||||
"share" = "/volume1/csi/n8n/data",
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue