Skip to content

Commit

Permalink
chore: demo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mxab committed Mar 22, 2023
1 parent 61ff96f commit 2d4065c
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/example3/example3.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ job "app" {
config { # a very simple docker container
image = "busybox:latest"
command = "sh"
args = ["-c", "while true; do echo \"hello @ $(date)\"; sleep 5; done"]
args = ["-c", "echo \"Environment:\"; env | sort; while true; do echo .; sleep 100; done"]
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions example/infra/nomad/jobs/keycloak.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
job "keycloak" {

datacenters = ["dc1"]
type = "service"

group "keycloak" {
count = 1

network {
port "http" {
to = 8080
}
}
task "keycloak" {
driver = "docker"


config {
image = "quay.io/keycloak/keycloak:21.0.1"

ports = ["http"]
command = "start-dev"
}
env {
KEYCLOAK_ADMIN = "admin"
KEYCLOAK_ADMIN_PASSWORD = "admin"
}
resources {

memory = 2048

}
}
service {
name = "keycloak"
port = "http"
provider = "nomad"
tags = [
"traefik.enable=true",

]
check {
type = "http"
path = "/"
interval = "10s"
timeout = "2s"
}
}
}
}
9 changes: 9 additions & 0 deletions example/infra/nomad/jobs/nomad.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ terraform {
provider "nomad" {
address = "http://localhost:4646"
}

resource "nomad_job" "pg" {
jobspec = file("${path.module}/pg.nomad")
}

resource "nomad_job" "traefik" {
jobspec = file("${path.module}/traefik.nomad")
}

resource "nomad_job" "keycloak" {
jobspec = file("${path.module}/keycloak.nomad")
}
53 changes: 53 additions & 0 deletions example/infra/nomad/jobs/traefik.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
job "traefik" {
datacenters = ["dc1"]
type = "service"


group "traefik" {
network {
port "http" {

static = 80
}
port "admin"{
static = 8080
}
}

task "traefik" {
driver = "docker"



config {
image = "traefik:v2.9.9"

ports = ["admin", "http"]
args = [
"--log.level=DEBUG",
"--api.dashboard=true",
"--api.insecure=true", ### For Test only, please do not use that in production
"--entrypoints.web.address=:${NOMAD_PORT_http}",
"--entrypoints.traefik.address=:${NOMAD_PORT_admin}",
"--providers.nomad=true",
"--providers.nomad.endpoint.address=http://host.docker.internal:4646", ### IP to your nomad server
"--providers.nomad.defaultRule=Host(`{{ .Name }}.nomad.local`)"

]
}


resources {

memory = 256

}
}
service {
name = "traefik-http"
provider = "nomad"
port = "http"
}

}
}
2 changes: 1 addition & 1 deletion example/infra/vault/vault.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "vault_database_secret_backend_connection" "postgres" {
allowed_roles = ["dev", "prod"]

postgresql {
connection_url = "postgres://postgres:secret@localhost:5432/postgres"
connection_url = "postgres://postgres:secret@postgres.nomad.local:5432/postgres"
}
}

Expand Down

0 comments on commit 2d4065c

Please sign in to comment.