chore(monica): add Nomad job and CSI volume registration
This commit is contained in:
parent
4d6d43f950
commit
3bf9dd1c8a
3 changed files with 133 additions and 0 deletions
4
main.tf
4
main.tf
|
@ -46,3 +46,7 @@ module "ollama" {
|
||||||
module "jayne-martin-counselling" {
|
module "jayne-martin-counselling" {
|
||||||
source = "./modules/jayne-martin-counselling"
|
source = "./modules/jayne-martin-counselling"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "monica" {
|
||||||
|
source = "./modules/monica"
|
||||||
|
}
|
||||||
|
|
94
modules/monica/jobspec.nomad.hcl
Normal file
94
modules/monica/jobspec.nomad.hcl
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
job "monica" {
|
||||||
|
|
||||||
|
group "monica" {
|
||||||
|
|
||||||
|
network {
|
||||||
|
mode = "bridge"
|
||||||
|
port "http" {
|
||||||
|
to = 80
|
||||||
|
}
|
||||||
|
port "envoy_metrics" {
|
||||||
|
to = 9102
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
service {
|
||||||
|
provider = "consul"
|
||||||
|
port = "80"
|
||||||
|
|
||||||
|
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.monica.rule=Host(`monica.brmartin.co.uk`)",
|
||||||
|
"traefik.http.routers.monica.entrypoints=websecure",
|
||||||
|
"traefik.consulcatalog.connect=true",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
volume "storage" {
|
||||||
|
type = "csi"
|
||||||
|
read_only = false
|
||||||
|
source = "martinibar_prod_monica_storage"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
access_mode = "multi-node-single-writer"
|
||||||
|
}
|
||||||
|
|
||||||
|
task "monica" {
|
||||||
|
driver = "docker"
|
||||||
|
|
||||||
|
config {
|
||||||
|
image = "docker.io/library/monica:4.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
env = {
|
||||||
|
DB_HOST = "martinibar.lan"
|
||||||
|
DB_USERNAME = "monica"
|
||||||
|
}
|
||||||
|
|
||||||
|
template {
|
||||||
|
data = <<-EOF
|
||||||
|
{{ with nomadVar "nomad/jobs/monica/monica/monica" }}
|
||||||
|
APP_KEY={{.api_key}}
|
||||||
|
DB_PASSWORD={{.db_password}}
|
||||||
|
{{ end }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
destination = "secrets/file.env"
|
||||||
|
env = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resources {
|
||||||
|
cpu = 500
|
||||||
|
memory = 1024
|
||||||
|
}
|
||||||
|
|
||||||
|
volume_mount {
|
||||||
|
volume = "storage"
|
||||||
|
destination = "/var/www/html/storage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
modules/monica/main.tf
Normal file
35
modules/monica/main.tf
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
resource "nomad_job" "monica" {
|
||||||
|
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_monica_storage"
|
||||||
|
volume_id = "martinibar_prod_monica_storage"
|
||||||
|
external_id = "martinibar_prod_monica_storage"
|
||||||
|
|
||||||
|
capability {
|
||||||
|
access_mode = "multi-node-single-writer"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
}
|
||||||
|
|
||||||
|
context = {
|
||||||
|
"server" = "martinibar.lan",
|
||||||
|
"share" = "/volume1/csi/monica/storage",
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue