From 61d075301072440ead9b279acf841f3f742c9ee1 Mon Sep 17 00:00:00 2001 From: Stephan Strate Date: Tue, 2 Jan 2024 11:35:34 +0100 Subject: [PATCH] Expose pandaproxy port in Redpanda dev services --- .../src/main/asciidoc/kafka-dev-services.adoc | 4 ++-- .../deployment/DevServicesKafkaProcessor.java | 4 ++-- .../KafkaDevServicesBuildTimeConfig.java | 6 +++--- ...nfig.java => RedpandaBuildTimeConfig.java} | 20 ++++++++++++++----- ...ainer.java => RedpandaKafkaContainer.java} | 17 +++++++++++----- 5 files changed, 34 insertions(+), 17 deletions(-) rename extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/{RedPandaBuildTimeConfig.java => RedpandaBuildTimeConfig.java} (58%) rename extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/{RedPandaKafkaContainer.java => RedpandaKafkaContainer.java} (85%) diff --git a/docs/src/main/asciidoc/kafka-dev-services.adoc b/docs/src/main/asciidoc/kafka-dev-services.adoc index a94da965a3a21..f27baa5064896 100644 --- a/docs/src/main/asciidoc/kafka-dev-services.adoc +++ b/docs/src/main/asciidoc/kafka-dev-services.adoc @@ -14,7 +14,7 @@ If any Kafka-related extension is present (e.g. `quarkus-smallrye-reactive-messa So, you don't have to start a broker manually. The application is configured automatically. -IMPORTANT: Because starting a Kafka broker can be long, Dev Services for Kafka uses https://vectorized.io/redpanda[Redpanda], a Kafka compatible broker which starts in ~1 second. +IMPORTANT: Because starting a Kafka broker can be long, Dev Services for Kafka uses https://redpanda.com[Redpanda], a Kafka compatible broker which starts in ~1 second. == Enabling / Disabling Dev Services for Kafka @@ -106,7 +106,7 @@ You can configure timeout for Kafka admin client calls used in topic creation us [[redpanda-transactions]] == Transactional and Idempotent producers support -By default, the Red Panda broker is configured to enable transactions and idempotence features. +By default, the Redpanda broker is configured to enable transactions and idempotence features. You can disable those using: [source, properties] diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java index e6d20a2e7e7df..312628e10b9ac 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java @@ -227,7 +227,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem final Supplier defaultKafkaBrokerSupplier = () -> { switch (config.provider) { case REDPANDA: - RedPandaKafkaContainer redpanda = new RedPandaKafkaContainer( + RedpandaKafkaContainer redpanda = new RedpandaKafkaContainer( DockerImageName.parse(config.imageName).asCompatibleSubstituteFor("vectorized/redpanda"), config.fixedExposedPort, launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null, @@ -321,7 +321,7 @@ private static final class KafkaDevServiceCfg { private final KafkaDevServicesBuildTimeConfig.Provider provider; - private final RedPandaBuildTimeConfig redpanda; + private final RedpandaBuildTimeConfig redpanda; public KafkaDevServiceCfg(KafkaDevServicesBuildTimeConfig config) { this.devServicesEnabled = config.enabled.orElse(true); diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java index 5c909c99a674a..756662efdd317 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java @@ -33,7 +33,7 @@ public class KafkaDevServicesBuildTimeConfig { * Redpanda, Strimzi and kafka-native container providers are supported. Default is redpanda. *

* For Redpanda: - * See https://vectorized.io/docs/quick-start-docker/ and https://hub.docker.com/r/vectorized/redpanda + * See https://docs.redpanda.com/current/get-started/quick-start/ and https://hub.docker.com/r/vectorized/redpanda *

* For Strimzi: * See https://github.com/strimzi/test-container and https://quay.io/repository/strimzi-test-container/test-container @@ -123,9 +123,9 @@ public String getDefaultImageName() { public Map containerEnv; /** - * Allows configuring the Red Panda broker. + * Allows configuring the Redpanda broker. */ @ConfigItem - public RedPandaBuildTimeConfig redpanda; + public RedpandaBuildTimeConfig redpanda; } diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaBuildTimeConfig.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaBuildTimeConfig.java similarity index 58% rename from extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaBuildTimeConfig.java rename to extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaBuildTimeConfig.java index f8e7ebfbdec03..19f052f11cd59 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaBuildTimeConfig.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaBuildTimeConfig.java @@ -3,20 +3,22 @@ import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import java.util.Optional; + /** - * Allows configuring the Red Panda broker. - * Notice that Red Panda is not a "genuine" Kafka, it's a 100% compatible implementation of the protocol. + * Allows configuring the Redpanda broker. + * Notice that Redpanda is not a "genuine" Kafka, it's a 100% compatible implementation of the protocol. * - * Find more info about Red Panda on https://vectorized.io/redpanda/. + * Find more info about Redpanda on https://redpanda.com/. */ @ConfigGroup -public class RedPandaBuildTimeConfig { +public class RedpandaBuildTimeConfig { /** * Enables transaction support. * Also enables the producer idempotence. * - * Find more info about Red Panda transaction support on + * Find more info about Redpanda transaction support on * https://vectorized.io/blog/fast-transactions/. * * Notice that @@ -28,4 +30,12 @@ public class RedPandaBuildTimeConfig { */ @ConfigItem(defaultValue = "true") public boolean transactionEnabled; + + /** + * Port to access the Redpanda HTTP Proxy (pandaproxy). + *

+ * If not defined, the port will be chosen randomly. + */ + @ConfigItem + public Optional proxyPort; } diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaKafkaContainer.java similarity index 85% rename from extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java rename to extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaKafkaContainer.java index e885b936d3b11..22f023e27a4d1 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedpandaKafkaContainer.java @@ -15,20 +15,21 @@ /** * Container configuring and starting the Redpanda broker. - * See https://vectorized.io/docs/quick-start-docker/ + * See https://docs.redpanda.com/current/get-started/quick-start/ */ -final class RedPandaKafkaContainer extends GenericContainer { +final class RedpandaKafkaContainer extends GenericContainer { private final Integer fixedExposedPort; private final boolean useSharedNetwork; - private final RedPandaBuildTimeConfig redpandaConfig; + private final RedpandaBuildTimeConfig redpandaConfig; private String hostName = null; private static final String STARTER_SCRIPT = "/var/lib/redpanda/redpanda.sh"; + private static final int PANDAPROXY_PORT = 8082; - RedPandaKafkaContainer(DockerImageName dockerImageName, int fixedExposedPort, String serviceName, - boolean useSharedNetwork, RedPandaBuildTimeConfig redpandaConfig) { + RedpandaKafkaContainer(DockerImageName dockerImageName, int fixedExposedPort, String serviceName, + boolean useSharedNetwork, RedpandaBuildTimeConfig redpandaConfig) { super(dockerImageName); this.fixedExposedPort = fixedExposedPort; this.useSharedNetwork = useSharedNetwork; @@ -101,6 +102,12 @@ protected void configure() { if (fixedExposedPort != null) { addFixedExposedPort(fixedExposedPort, DevServicesKafkaProcessor.KAFKA_PORT); } + + if (redpandaConfig.proxyPort.isPresent()) { + addFixedExposedPort(redpandaConfig.proxyPort.get(), PANDAPROXY_PORT); + } else { + addExposedPort(PANDAPROXY_PORT); + } } public String getBootstrapServers() {