Get kafka and zookeeper running via consul connect
@@ -171,10 +171,6 @@ job "grapl-local-infra" {
group "kafka" {
network {
mode = "bridge"
-
- port "kafka" {
- to = var.KAFKA_BROKER_PORT
- }
}
task "kafka" {
@@ -182,15 +178,11 @@ job "grapl-local-infra" {
config {
image = "confluentinc/cp-kafka:6.2.0"
- ports = ["kafka"]
- network_aliases = [
- var.KAFKA_BROKER_HOST
- ]
}
env {
KAFKA_BROKER_ID = 1
- KAFKA_ZOOKEEPER_CONNECT = "${var.ZOOKEEPER_HOST}:${var.ZOOKEEPER_PORT}"
+ KAFKA_ZOOKEEPER_CONNECT = "localhost:${var.ZOOKEEPER_PORT}"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP = "PLAINTEXT:PLAINTEXT"
KAFKA_LISTENERS = "PLAINTEXT://${var.KAFKA_BROKER_HOST}:${var.KAFKA_BROKER_PORT}"
KAFKA_ADVERTISED_LISTENERS = "PLAINTEXT://${var.KAFKA_BROKER_HOST}:${var.KAFKA_BROKER_PORT}"
@@ -201,18 +193,34 @@ job "grapl-local-infra" {
KAFKA_JMX_PORT = var.KAFKA_JMX_PORT
KAFKA_JMX_HOSTNAME = "localhost"
KAFKA_LOG4J_ROOT_LOGLEVEL = "INFO"
+ }
+ }
+
+ service {
+ name = "kafka-broker"
+ port = var.KAFKA_BROKER_PORT
+ tags = ["kafka"]
+ connect {
+ sidecar_service {
+ proxy {
+ # connect to zookeeper
+ upstreams {
+ destination_name = "zookeeper"
+ local_bind_port = var.ZOOKEEPER_PORT
}
}
}
+ }
+
+ }
+
+
+ }
group "zookeeper" {
network {
mode = "bridge"
-
- port "zookeeper" {
- to = var.ZOOKEEPER_PORT
- }
}
task "zookeeper" {
@@ -220,10 +228,6 @@ job "grapl-local-infra" {
config {
image = "confluentinc/cp-zookeeper:6.2.0"
- ports = ["zookeeper"]
- network_aliases = [
- var.ZOOKEEPER_HOST
- ]
}
env {
@@ -231,5 +235,25 @@ job "grapl-local-infra" {
ZOOKEEPER_TICK_TIME = 2000
}
}
+
+ service {
+ name = "zookeeper"
+ port = var.ZOOKEEPER_PORT
+ tags = ["zookeeper"]
+
+ connect {
+ sidecar_service {
+ proxy {
+ upstreams {
+ destination_name = "kafka-broker"
+ local_bind_port = var.KAFKA_BROKER_PORT
+ }
+ }
+ }
+ }
+
+ }
+
+
}
}
\ No newline at end of file
