JOB
Job de validation
Ce job permet de valider la communication inter-conteneurs.
job "kokitest" {
datacenters = ["gra"]
type = "service"
#constraint {
# attribute = "${meta.node_name}"
# value = "kokinode1"
#}
group "webapp" {
count = 1
network {
port "http" {
to = 80
}
port "fpm" {
to = 9000
}
}
task "nginx" {
service {
name = "nginx"
provider = "consul"
port = "http"
check {
name = "http"
type = "tcp"
port = "http"
interval = "10s"
timeout = "2s"
}
tags = [
"traefik.enable=true",
"traefik.http.routers.webapp.rule=Host(`kokitest.mon-nom-de-domaine.tld`)"
]
}
driver = "docker"
config {
image = "nginx:latest"
ports = ["http"]
volumes = [
"local/default.conf:/etc/nginx/conf.d/default.conf:ro",
"local/default_index.html:/usr/share/nginx/html/index.html:ro"
]
}
template {
data = <<EOF
<html>
<h2>KOKITEST</h2>
Env : '{{ env "meta.environment" }}'<br />
Hostname : '{{ env "attr.unique.hostname" }}'<br />
Consul version : '{{ env "attr.consul.version" }}'<br />
Advertise address : '{{ env "attr.unique.network.ip-address" }}'<br />
Nomad version : '{{ env "attr.nomad.version" }}'<br />
Consul version : '{{ env "attr.consul.version" }}'<br />
OS version : '{{ env "attr.os.version" }}'<br />
</html>
EOF
destination = "local/default_index.html"
}
template {
data = <<EOF
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root html;
fastcgi_pass '{{ env "NOMAD_ADDR_fpm" }}';
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
destination = "local/default.conf"
}
env = {
TZ = "Europe/Paris"
}
}
task "fpm" {
service {
name = "fpm"
provider = "consul"
port = "fpm"
check {
name = "fpm"
type = "tcp"
port = "fpm"
interval = "10s"
timeout = "2s"
}
}
driver = "docker"
config {
image = "bitnami/php-fpm"
ports = ["fpm"]
}
env = {
TZ = "Europe/Paris"
}
}
}
}