Skip to content

Instantly share code, notes, and snippets.

@dehuszar
Last active February 14, 2023 03:29
Show Gist options
  • Save dehuszar/dca21685dc7b8b9bb1b547be04e07da1 to your computer and use it in GitHub Desktop.
Save dehuszar/dca21685dc7b8b9bb1b547be04e07da1 to your computer and use it in GitHub Desktop.
A Nomad job template for running a redpanda-cluster with a kafka-connect cluster that shares the same nodes (TODO), and a Redpanda Console process for management (TODO)
variable "datacenters" {
type = list(string)
}
variable "image_tag" {
default = "v22.3.11-arm64"
type = string
}
job "redpanda" {
datacenters = var.datacenters
type = "service"
group "cluster" {
count = 3
network {
port "admin" {
to = 9644
}
port "connect" {
to = 8083
}
port "kafka" {
to = 9092
}
port "proxy" {
to = 8082
}
port "rpc" {
to = 33145
}
port "schema_registry" {
to = 8081
}
port "supervisor" {
to = 43189
}
}
service {
address = "${attr.unique.network.ip-address}"
name = "admin"
port = "admin"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "connect"
port = "connect"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "panda-proxy"
port = "proxy"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "redpanda"
port = "kafka"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "rpc"
port = "rpc"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "schema-registry"
port = "schema_registry"
provider = "consul"
tags = ["kafka", "events"]
}
service {
address = "${attr.unique.network.ip-address}"
name = "supervisor"
port = "supervisor"
provider = "consul"
tags = ["kafka", "events"]
}
task "broker" {
driver = "docker"
config {
image = "docker.redpanda.com/vectorized/redpanda:${var.image_tag}"
ports = [
"admin",
"kafka",
"proxy",
"rpc",
"schema_registry",
"supervisor"
]
command = "/local/start-redpanda-broker.sh"
entrypoint = ["bash"]
}
template {
data = <<EOF
rpk redpanda start \
--smp 1 \
--overprovisioned \
--seeds {{ range $i, $e := service "redpanda" -}}
{{- if eq $i 0 -}}
{{ .Address }}:{{ .Port }}
{{- else -}}
,{{ .Address }}:{{ .Port }}
{{- end -}}
{{- end}} \
--check=false \
--set redpanda.empty_seed_starts_cluster=false \
--set redpanda.auto_create_topics_enabled=false \
--kafka-addr INSIDE://{{- range $i, $e := service "redpanda" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
0.0.0.0:{{ .Port }}
{{- end -}}
{{- end}},OUTSIDE://0.0.0.0:{{ env "NOMAD_PORT_kafka" }} \
--advertise-kafka-addr INSIDE://{{- range $i, $e := service "redpanda" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
{{ .Address }}:{{ .Port }}
{{- end -}}
{{- end}},OUTSIDE://localhost:{{ env "NOMAD_PORT_kafka" }} \
--pandaproxy-addr INSIDE://{{- range $i, $e := service "panda-proxy" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
0.0.0.0:{{ .Port }}
{{- end -}}
{{- end}},OUTSIDE://0.0.0.0:{{ env "NOMAD_PORT_proxy" }} \
--advertise-pandaproxy-addr INSIDE://{{- range $i, $e := service "panda-proxy" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
{{ .Address }}:{{ .Port }}
{{- end -}}
{{- end}},OUTSIDE://localhost:{{ env "NOMAD_PORT_proxy" }} \
--rpc-addr {{ range $i, $e := service "rpc" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
0.0.0.0:{{ .Port }}
{{- end -}}
{{- end}} \
--advertise-rpc-addr {{ range $i, $e := service "rpc" -}}
{{- if eq .Address (env "attr.unique.network.ip-address") -}}
{{ .Address }}:{{ .Port }}
{{- end -}}
{{- end}} \
--kernel-page-cache 1
EOF
destination = "/local/start-redpanda-broker.sh"
perms = "555"
}
resources {
memory = 1024
}
}
// task "connect" {
// driver = "docker"
// config {
// image = "confluentinc/cp-kafka-connect:7.3.1"
// ports = ["connect"]
// }
// }
}
// group "console" {
// count = 1
// network {
// port "console" {
// to = 8080
// }
// }
// task "node" {
// driver = "docker"
// config {
// image = "docker.redpanda.com/vectorized/console:v2.1.1"
// ports = ["console"]
// }
// }
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment