Setup some example apps behing traefik

This commit is contained in:
2025-04-25 21:27:31 +10:00
parent 793d77dce9
commit bdacd1d6a3
9 changed files with 435 additions and 72 deletions

View File

@@ -3,55 +3,14 @@ provider "nomad" {
address = "http://jaglan-beta-m01:4646"
}
# Define a Nomad job for a Hello World service
resource "nomad_job" "app" {
jobspec = <<EOT
job "hello-world" {
group "servers" {
network {
port "www" {
to = 8002
}
}
service {
provider = "nomad"
port = "www"
}
# Tasks are individual units of work that are run by Nomad.
task "web" {
# This particular task starts a simple web server within a Docker container
driver = "docker"
config {
image = "busybox:1"
command = "httpd"
args = ["-v", "-f", "-p", "$${NOMAD_PORT_www}", "-h", "/local"]
ports = ["www"]
}
template {
data = <<-EOF
<h1>Hello, Nomad!</h1>
<ul>
<li>Task: {{env "NOMAD_TASK_NAME"}}</li>
<li>Group: {{env "NOMAD_GROUP_NAME"}}</li>
<li>Job: {{env "NOMAD_JOB_NAME"}}</li>
<li>Metadata value for foo: {{env "NOMAD_META_foo"}}</li>
<li>Currently running on port: {{env "NOMAD_PORT_www"}}</li>
</ul>
EOF
destination = "local/index.html"
}
# Specify the maximum resources required to run the task
resources {
cpu = 50
memory = 64
}
}
}
resource "nomad_job" "hello_world" {
jobspec = file("hello-world.nomad")
}
resource "nomad_job" "traefik" {
jobspec = file("traefik.nomad")
}
resource "nomad_job" "webapp" {
jobspec = file("webapp.nomad")
}
EOT
}