Skip to content

Instantly share code, notes, and snippets.

@electric380v
Last active July 4, 2019 07:49
Show Gist options
  • Save electric380v/a61a9bba9a4efa683106109661619b12 to your computer and use it in GitHub Desktop.
Save electric380v/a61a9bba9a4efa683106109661619b12 to your computer and use it in GitHub Desktop.
nomad kv
job "nginx" {
datacenters = ["dc1"]
type = "service"
group "nginx" {
count = 3
task "nginx" {
driver = "docker"
config {
image = "nginx"
port_map {
http = 8080
}
port_map {
https = 443
}
volumes = [
"custom/default.conf:/etc/nginx/conf.d/default.conf"
]
}
template {
data = <<EOH
server {
listen 8080;
server_name nginx.service.consul;
location /nginx {
root /local/data;
}
}
EOH
destination = "custom/default.conf"
}
# consul kv put features/demo 'Consul Rocks!'
template {
data = <<EOH
Nomad Template example (Consul value)
<br />
<br />
{{ if keyExists "features/demo" }}
Consul Key Value: {{ key "features/demo" }}
{{ else }}
Good morning.
{{ end }}
<br />
<br />
Node Environment Information: <br />
node_id: {{ env "node.unique.id" }} <br/>
datacenter: {{ env "NOMAD_DC" }}
EOH
destination = "local/data/nginx/index.html"
}
resources {
cpu = 100 # 100 MHz
memory = 128 # 128 MB
network {
mbits = 10
port "http" {
static = 8080
}
port "https" {
static= 443
}
}
}
service {
name = "nginx"
tags = [ "nginx", "web", "urlprefix-/nginx" ]
port = "http"
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment