From 594cae279d01c21081278e66710086e7f7ae07a5 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 22 Apr 2024 14:22:11 +0200 Subject: [PATCH] Cleanup --- elasticsearch.nomad.hcl | 22 +++++++--------------- example/elasticsearch.nomad.hcl | 16 ++++++++++------ example/prep.d/10-build-base-images.sh | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/elasticsearch.nomad.hcl b/elasticsearch.nomad.hcl index 7ba0764..7810f33 100644 --- a/elasticsearch.nomad.hcl +++ b/elasticsearch.nomad.hcl @@ -4,13 +4,7 @@ job "[[ .instance ]]" { group "server" { [[ $c := merge .elasticsearch.server .elasticsearch . ]] - - count = [[ $c.count ]] - -[[ template "common/constraints" $c ]] - - # Wait a few seconds between service deregistration from consul catalog and task kill - shutdown_delay = "6s" +[[ template "common/group_start" $c ]] network { mode = "bridge" @@ -40,8 +34,8 @@ job "[[ .instance ]]" { "-c", "set -e; STATUS=$(curl localhost:9200/_cluster/health?local=true | jq -r .status); if [ \"$STATUS\" == \"green\" ]; then exit 0; elif [ \"$STATUS\" == \"yellow\" ]; then exit 1; else exit 2; fi" ] - interval = "30s" - timeout = "8s" + interval = "[[ $c.consul.check.interval ]]" + timeout = "[[ $c.consul.check.timeout ]]" } tags = [ @@ -68,9 +62,8 @@ job "[[ .instance ]]" { kill_timeout = "120s" config { - image = "[[ $c.image ]]" +[[ template "common/image" $c ]] pids_limit = 1024 - readonly_rootfs = true volumes = [ "secrets/entrypoint.env:/entrypoint.d/94-elasticsearch-users.env" ] @@ -184,6 +177,8 @@ _EOT [[- if conv.ToBool $c.prometheus.enabled ]] [[- $e := merge .elasticsearch.exporter .elasticsearch . ]] +[[ template "common/task.metrics_proxy" $e ]] + # Prometheus exporter task "exporter" { driver = "[[ $e.nomad.driver ]]" @@ -194,9 +189,8 @@ _EOT } config { - image = "[[ $e.image ]]" +[[ template "common/image" $e ]] pids_limit = 100 - readonly_rootfs = true command = "elasticsearch_exporter" args = [ "--web.listen-address=127.0.0.1:9114" @@ -208,8 +202,6 @@ _EOT [[ template "common/resources" $e ]] } -[[ template "common/task.metrics_proxy" $e ]] - [[- end ]] } } diff --git a/example/elasticsearch.nomad.hcl b/example/elasticsearch.nomad.hcl index aebf610..3acbe91 100644 --- a/example/elasticsearch.nomad.hcl +++ b/example/elasticsearch.nomad.hcl @@ -8,8 +8,8 @@ job "elasticsearch" { group "server" { - count = 3 - + count = 3 + shutdown_delay = "6s" constraint { @@ -18,8 +18,11 @@ job "elasticsearch" { } - # Wait a few seconds between service deregistration from consul catalog and task kill - shutdown_delay = "6s" + ephemeral_disk { + # Use minimal ephemeral disk + size = 101 + } + network { mode = "bridge" @@ -89,7 +92,7 @@ job "elasticsearch" { "set -e; STATUS=$(curl localhost:9200/_cluster/health?local=true | jq -r .status); if [ \"$STATUS\" == \"green\" ]; then exit 0; elif [ \"$STATUS\" == \"yellow\" ]; then exit 1; else exit 2; fi" ] interval = "30s" - timeout = "8s" + timeout = "5s" } tags = [ @@ -118,8 +121,9 @@ job "elasticsearch" { config { image = "danielberteaud/elasticsearch:8.13.2-1" - pids_limit = 1024 readonly_rootfs = true + + pids_limit = 1024 volumes = [ "secrets/entrypoint.env:/entrypoint.d/94-elasticsearch-users.env" ] diff --git a/example/prep.d/10-build-base-images.sh b/example/prep.d/10-build-base-images.sh index 9b5c5d8..a3778cf 100755 --- a/example/prep.d/10-build-base-images.sh +++ b/example/prep.d/10-build-base-images.sh @@ -342,6 +342,23 @@ function build_sqlite { fi IMAGE_SQLITE_AVAILABLE=1 } +function build_valkey { + if [ "${IMAGE_VALKEY_AVAILABLE:-0}" = "1" ]; then + echo "Image danielberteaud/valkey:24.4-1 already available" + return + fi + if ! docker manifest inspect danielberteaud/valkey:24.4-1 > /dev/null 2>&1; then + echo "Building valkey:24.4-1" + export BUILDKIT_PROGRESS=plain + docker build -t danielberteaud/valkey:24.4-1 -t danielberteaud/valkey:latest output/images/valkey &&\ + docker push danielberteaud/valkey:24.4-1 &&\ + docker push danielberteaud/valkey:latest &&\ + echo "danielberteaud/valkey:24.4-1 pushed to remote repo" + else + echo "Image danielberteaud/valkey:24.4-1 already available" + fi + IMAGE_VALKEY_AVAILABLE=1 +} function build_wait_for { if [ "${IMAGE_WAIT_FOR_AVAILABLE:-0}" = "1" ]; then echo "Image danielberteaud/wait-for:24.4-1 already available" @@ -396,6 +413,7 @@ build_php83 build_postgres15 build_postgres16 build_sqlite +build_valkey build_wait_for build_wkhtmltopdf