Skip to content

Instantly share code, notes, and snippets.

@kakoni
Created November 19, 2021 15:21
Show Gist options
  • Save kakoni/0807f204ce714d46f710f8ade6dcf1cf to your computer and use it in GitHub Desktop.
Save kakoni/0807f204ce714d46f710f8ade6dcf1cf to your computer and use it in GitHub Desktop.
Elasticsearch nomad cluster
job "elasticsearch" {
datacenters = ["dc1"]
type = "service"
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "3m"
progress_deadline = "10m"
auto_revert = false
canary = 0
}
migrate {
max_parallel = 1
health_check = "checks"
min_healthy_time = "10s"
healthy_deadline = "5m"
}
group "master" {
count = 3
network {
port "request" {
}
port "communication" {
}
}
service {
name = "es-req"
port = "request"
check {
name = "rest-tcp"
type = "tcp"
interval = "10s"
timeout = "2s"
}
check {
name = "rest-http"
type = "http"
path = "/"
interval = "5s"
timeout = "4s"
}
}
service {
name = "es-master-comm"
port = "communication"
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
restart {
attempts = 1
delay = "30s"
interval = "5m"
mode = "fail"
}
ephemeral_disk {
size = 300
}
task "elasticsearch" {
driver = "docker"
kill_timeout = "300s"
kill_signal = "SIGTERM"
env = {
"node.name" = "${NOMAD_GROUP_NAME}-${NOMAD_ALLOC_INDEX}"
"cluster.initial_master_nodes" = "master-0, master-1, master-2"
"cluster.name" = "es-docker-cluster"
"ES_JAVA_OPTS" = "-Xms256m -Xmx256m"
"discovery.seed_providers" = "file"
"network.publish_host" = "${NOMAD_IP_request}"
"http.publish_port" = "${NOMAD_HOST_PORT_request}"
"http.port" = "${NOMAD_PORT_request}"
"transport.publish_port" = "${NOMAD_HOST_PORT_communication}"
"transport.tcp.port" = "${NOMAD_PORT_communication}"
}
template {
destination = "/local/unicast_hosts.txt"
change_mode = "noop"
data = "{{ range service \"es-master-comm\" }}{{ .Address }}:{{ .Port }}\n{{ end }}"
}
config {
image = "docker.elastic.co/elasticsearch/elasticsearch:7.15.2"
entrypoint = [
"/bin/tini",
"--",
"/bin/sh",
"-c",
"ln -s /local/unicast_hosts.txt /usr/share/elasticsearch/config && /usr/local/bin/docker-entrypoint.sh"
]
ports = [
"request",
"communication"
]
ulimit {
memlock = "-1"
nofile = "65536"
nproc = "8192"
}
}
resources {
cpu = 500
memory = 512
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment