Skip to content

Instantly share code, notes, and snippets.

@kakoni
Created November 19, 2021 15:21
Show Gist options
  • Select an option

  • Save kakoni/0807f204ce714d46f710f8ade6dcf1cf to your computer and use it in GitHub Desktop.

Select an option

Save kakoni/0807f204ce714d46f710f8ade6dcf1cf to your computer and use it in GitHub Desktop.

Revisions

  1. kakoni renamed this gist Nov 19, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. kakoni renamed this gist Nov 19, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. kakoni created this gist Nov 19, 2021.
    121 changes: 121 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,121 @@
    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
    }
    }
    }
    }