Created
March 3, 2023 08:20
-
-
Save langerma/9e0e8b6a58a52a62e9675a58b151d600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
job "zookeeper" { | |
datacenters = ["hetzner"] | |
type = "service" | |
#update { | |
# max_parallel = 1 | |
#} | |
group "zookeeper" { | |
count = 3 | |
constraint { | |
attribute = "${attr.unique.hostname}" | |
operator = "regexp" | |
value = "^client1|client2|client3$" | |
} | |
service { | |
name = "zookeeper" | |
port = "zk" | |
tags = ["zookeeper", "log"] | |
check { | |
type = "script" | |
name = "zk_isok" | |
command = "/bin/sh" | |
args = ["-c", "echo ruok | nc 127.0.0.1 2181"] | |
interval = "10s" | |
timeout = "30s" | |
initial_status = "passing" | |
task = "zookeeper" | |
} | |
#check { | |
# type = "tcp" | |
# port = "zk" | |
# interval = "10s" | |
# timeout = "1s" | |
#} | |
} | |
service { | |
name = "zookeeper-discovery1" | |
port = "zk_cluster1" | |
#check { | |
# type = "tcp" | |
# port = "zk_cluster1" | |
# interval = "10s" | |
# timeout = "15s" | |
#} | |
} | |
service { | |
name = "zookeeper-discovery2" | |
port = "zk_cluster2" | |
check { | |
type = "tcp" | |
port = "zk_cluster2" | |
interval = "10s" | |
timeout = "15s" | |
} | |
} | |
network { | |
port "zk" { | |
static = 2181 | |
} | |
port "zk_cluster1" { | |
static = 2888 | |
} | |
port "zk_cluster2" { | |
static = 3888 | |
} | |
mode = "host" | |
} | |
task "zookeeper-data-dir" { | |
driver = "raw_exec" | |
lifecycle { | |
hook = "prestart" | |
sidecar = false | |
} | |
template { | |
data = <<EOF | |
#!/usr/bin/env bash | |
ZOOKEEPER_PATH=/data/zookeeper | |
mkdir -p $ZOOKEEPER_PATH | |
chmod -R 777 $ZOOKEEPER_PATH | |
chown -R 1001:1001 $ZOOKEEPER_PATH | |
EOF | |
perms = 777 | |
destination = "local/zookeeper-data-dir.sh" | |
} | |
config { | |
command = "/bin/bash" | |
args = ["local/zookeeper-data-dir.sh"] | |
} | |
} | |
task "zookeeper" { | |
driver = "docker" | |
config { | |
image = "zookeeper:latest" | |
ports = [ | |
"zk", | |
"zk_cluster1", | |
"zk_cluster2" | |
] | |
network_mode = "host" | |
volumes = [ | |
"/data/zookeeper/datalog:/datalog", | |
"/data/zookeeper/data:/data" | |
] | |
} | |
template { | |
data = <<EOT | |
#ZOO_SERVERS={{ range $index, $element := service "zookeeper-discovery1|any" }}{{ printf "server.%d:%s:%d:%d:participant;0.0.0.0:%d " $index .Node 2888 3888 2181 }}{{ end }} | |
ZOO_SERVERS= | |
ZOO_MY_ID="{{ env "NOMAD_ALLOC_INDEX" | parseInt | add 1 }}" | |
EOT | |
destination = "secrets/file.env" | |
env = true | |
change_mode = "restart" | |
} | |
env = { | |
ZOO_CFG_EXTRA = "clientPort=${NOMAD_HOST_PORT_zk} quorumListenOnAllIPs=true" | |
JVMFLAGS = "-Xmx128m" | |
ZOO_4LW_COMMANDS_WHITELIST = "stat,ruok,conf,isro" | |
ZOO_INIT_LIMIT = "60" | |
ZOO_SYNC_LIMIT = "30" | |
ZOO_MAX_CLIENT_CNXNS = "200" | |
ZOO_STANDALONE_ENABLED = "false" | |
} | |
resources { | |
memory = 150 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment