-
Notifications
You must be signed in to change notification settings - Fork 19
/
hello-world-vault.nomad
81 lines (66 loc) · 1.5 KB
/
hello-world-vault.nomad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
variable "datacenters" {
type = list(string)
description = "List of datacenters to deploy to."
default = ["dc1"]
}
variable "image_tag" {
type = string
description = "Docker image tag to deploy."
default = "latest"
}
job "hello-world-vault" {
datacenters = var.datacenters
group "web" {
count = 1
restart {
attempts = 3
interval = "2m"
delay = "15s"
mode = "fail"
}
network {
port "http" { to = 8080 }
}
task "frontend" {
driver = "docker"
config {
image = "ghcr.io/fhemberger/nomad-demo-hello-world-vault:${var.image_tag}"
cap_drop = [
"ALL",
]
ports = ["http"]
}
resources {
cpu = 100
memory = 50
}
service {
name = "hello-vault"
tags = ["http"]
port = "http"
check {
type = "http"
path = "/"
interval = "10s"
timeout = "2s"
}
}
template {
data = <<EOF
{{ with secret "kv/hello-world-vault" }}
VAULT_SECRET_URL="{{ .Data.url }}"
VAULT_SECRET_USERNAME="{{ .Data.username }}"
VAULT_SECRET_PASSWORD="{{ .Data.password }}"
{{ end }}
EOF
destination = "secrets/vault.env"
env = true
}
vault {
policies = ["hello-world-vault"]
change_mode = "signal"
change_signal = "SIGHUP"
}
}
}
}