Small cleanup

This commit is contained in:
Daniel Berteaud 2024-02-20 12:04:06 +01:00
parent f6c0873811
commit 90798be9b4
2 changed files with 11 additions and 6 deletions

View File

@ -31,7 +31,7 @@ job "[[ .instance ]]" {
name = "[[ .instance ]][[ .consul.suffix ]]"
port = 9200
[[ template "common/metrics_meta" $c ]]
[[ template "common/service_meta" $c ]]
[[ template "common/connect" $c ]]
# Use a script check instead of http so we can report ok for green, warning for yellow and critical for any other state
@ -49,7 +49,7 @@ job "[[ .instance ]]" {
}
tags = [
"[[ .instance ]]-${NOMAD_ALLOC_INDEX}",
"es-${NOMAD_ALLOC_INDEX}",
[[ template "common/traefik_tags" $c ]]
]
}
@ -58,8 +58,8 @@ job "[[ .instance ]]" {
service {
name = "[[ .instance ]]-transport[[ .consul.suffix ]]"
port = "transport"
meta {
# Publish the alloc index in service metadata
alloc = "${NOMAD_ALLOC_INDEX}"
}
}
@ -136,8 +136,8 @@ _EOT
template {
data = <<_EOT
{{ with secret "[[ $c.vault.pki.path ]]/issue/server"
"common_name=[[ .instance ]].service.[[ .consul.domain ]]"
(printf "alt_names=es-%s.[[ .instance ]].service.[[ .consul.domain ]]" (env "NOMAD_ALLOC_INDEX"))
"common_name=[[ .instance ]][[ .consul.suffix ]].service.[[ .consul.domain ]]"
(printf "alt_names=es-%s.[[ .instance ]][[ .consul.suffix ]].service.[[ .consul.domain ]]" (env "NOMAD_ALLOC_INDEX"))
(printf "ip_sans=%s,127.0.0.1" (env "NOMAD_HOST_IP_transport"))
(printf "ttl=%dh" (env "NOMAD_ALLOC_INDEX" | parseInt | multiply 24 | add 72)) }}
{{ .Data.certificate }}
@ -153,7 +153,7 @@ _EOT
data = <<_EOT
{{ with secret "[[ $c.vault.pki.path ]]/issue/server"
"common_name=[[ .instance ]].service.[[ .consul.domain ]]"
(printf "alt_names=es-%s.[[ .instance ]].service.[[ .consul.domain ]]" (env "NOMAD_ALLOC_INDEX"))
(printf "alt_names=es-%s.[[ .instance ]][[ .consul.suffix ]].service.[[ .consul.domain ]]" (env "NOMAD_ALLOC_INDEX"))
(printf "ip_sans=%s,127.0.0.1" (env "NOMAD_HOST_IP_transport"))
(printf "ttl=%dh" (env "NOMAD_ALLOC_INDEX" | parseInt | multiply 24 | add 72)) }}
{{ .Data.private_key }}

View File

@ -37,6 +37,11 @@ elasticsearch:
path: '[[ .vault.root ]]pki/[[ .instance ]]'
ou: Elasticsearch Cluster
consul:
meta:
# Publish the node addr in the metadata of the service
addr: 'es-${NOMAD_ALLOC_INDEX}.[[ .instance ]][[ .consul.suffix ]].service.[[ .consul.domain ]]'
# Resource allocation
resources:
cpu: 300