Skip to content

Commit

Permalink
Merge pull request quarkusio#37972 from stephan-strate/redpanda-panda…
Browse files Browse the repository at this point in the history
…proxy

Expose pandaproxy port in Redpanda dev services
  • Loading branch information
geoand authored Jan 3, 2024
2 parents 11424db + fd358d3 commit 72b3808
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/kafka-dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem
final Supplier<RunningDevService> 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,
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class KafkaDevServicesBuildTimeConfig {
* Redpanda, Strimzi and kafka-native container providers are supported. Default is redpanda.
* <p>
* 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
* <p>
* For Strimzi:
* See https://github.com/strimzi/test-container and https://quay.io/repository/strimzi-test-container/test-container
Expand Down Expand Up @@ -123,9 +123,9 @@ public String getDefaultImageName() {
public Map<String, String> containerEnv;

/**
* Allows configuring the Red Panda broker.
* Allows configuring the Redpanda broker.
*/
@ConfigItem
public RedPandaBuildTimeConfig redpanda;
public RedpandaBuildTimeConfig redpanda;

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package io.quarkus.kafka.client.deployment;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

/**
* 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 <a href="https://vectorized.io/redpanda/">https://vectorized.io/redpanda/</a>.
* Find more info about Redpanda on <a href="https://redpanda.com/">https://redpanda.com/</a>.
*/
@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
* <a href="https://vectorized.io/blog/fast-transactions/">https://vectorized.io/blog/fast-transactions/</a>.
*
* Notice that
Expand All @@ -28,4 +30,12 @@ public class RedPandaBuildTimeConfig {
*/
@ConfigItem(defaultValue = "true")
public boolean transactionEnabled;

/**
* Port to access the Redpanda HTTP Proxy (<a href="https://docs.redpanda.com/current/develop/http-proxy/">pandaproxy</a>).
* <p>
* If not defined, the port will be chosen randomly.
*/
@ConfigItem
public Optional<Integer> proxyPort;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@

/**
* Container configuring and starting the Redpanda broker.
* See https://vectorized.io/docs/quick-start-docker/
* See <a href=
* "https://docs.redpanda.com/current/get-started/quick-start/">https://docs.redpanda.com/current/get-started/quick-start/</a>
*/
final class RedPandaKafkaContainer extends GenericContainer<RedPandaKafkaContainer> {
final class RedpandaKafkaContainer extends GenericContainer<RedpandaKafkaContainer> {

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;
Expand Down Expand Up @@ -101,6 +103,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() {
Expand Down

0 comments on commit 72b3808

Please sign in to comment.