feat: added Redis to homelab

This commit is contained in:
Luigi Oliveira 2024-10-23 20:25:38 -03:00
parent 531886d13b
commit 204f04081a
4 changed files with 79 additions and 1 deletions

View file

@ -20,6 +20,13 @@ module "postgree" {
} }
} }
module "redis" {
source = "./modules/redis"
providers = {
nomad = nomad
}
}
module "keycloak" { module "keycloak" {
source = "./modules/keycloak" source = "./modules/keycloak"
postgree_user = var.postgree_user postgree_user = var.postgree_user

View file

@ -0,0 +1,57 @@
job "redis" {
datacenters = ["dc"]
type = "service"
group "redis" {
count = 1
network {
port "redis" {
static = 6379
to = 6379
}
}
restart {
attempts = 2
interval = "5m"
delay = "30s"
mode = "delay"
}
task "redis" {
driver = "docker"
config {
image = "redis:7.2"
ports = ["redis"]
volumes = [
"${NOMAD_ALLOC_DIR}/postiz-redis-data:/data"
]
}
resources {
cpu = 500
memory = 512
}
service {
name = "redis"
port = "redis"
provider = "nomad"
check {
name = "redis-check"
type = "tcp"
port = "redis"
interval = "10s"
timeout = "3s"
}
}
logs {
max_files = 5
max_file_size = 15
}
}
}
}

View file

@ -0,0 +1,5 @@
resource "nomad_job" "app" {
jobspec = templatefile("${path.module}/conf/redis.hcl", {
NOMAD_ALLOC_DIR = "/alloc"
})
}

View file

@ -0,0 +1,9 @@
terraform {
required_providers {
nomad = {
source = "hashicorp/nomad"
version = "2.0.0-rc.1"
}
}
required_version = ">= 0.14"
}