Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka with in-docker and out-of-docker listening interfaces #1303

Closed
vilunov opened this issue Nov 2, 2020 · 1 comment · Fixed by #1869
Closed

Kafka with in-docker and out-of-docker listening interfaces #1303

vilunov opened this issue Nov 2, 2020 · 1 comment · Fixed by #1869

Comments

@vilunov
Copy link
Contributor

vilunov commented Nov 2, 2020

We found this useful for our e2e tests: while our application is running in a docker container and interacting with kafka using its inside interface, our e2e test run outside of docker and interact with kafka using its outside interface.

If you think this could be useful to supply as a part of distage-framework-docker, I could prepare a PR to modify the existing kafka configuration.

The implementation is basically this:

object KafkaTwofaceDocker extends ContainerDef {
  val insidePort: DockerPort = DockerPort.DynamicTCP("dynamic_kafka_port_inside")
  val outsidePort: DockerPort = DockerPort.DynamicTCP("dynamic_kafka_port_outside")

  private[this] def portVars: String = Seq(
    s"""KAFKA_LISTENERS=INSIDE://:$$${insidePort.toEnvVariable},OUTSIDE://:$$${outsidePort.toEnvVariable}""",
    s"""KAFKA_ADVERTISED_LISTENERS=INSIDE://:$$${insidePort.toEnvVariable},OUTSIDE://127.0.0.1:$$${outsidePort.toEnvVariable}""",
    """KAFKA_INTER_BROKER_LISTENER_NAME=INSIDE""",
    """KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT""",
  ).map(defn => s"export $defn").mkString("; ")

  override def config: Config = {
    Config(
      image = "wurstmeister/kafka:2.12-2.4.1",
      ports = Seq(insidePort, outsidePort),
      entrypoint = Seq("sh", "-c", s"$portVars ; start-kafka.sh"),
    )
  }
}
@pshirshov
Copy link
Member

Will be exposed with twoface identifier.

DIStage automation moved this from To do to Done Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
DIStage
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants