Skip to content

Commit

Permalink
Expose pandaproxy port in Redpanda dev services
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-strate committed Jan 2, 2024
1 parent 7d15333 commit db323e0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 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.

Check warning on line 17 in docs/src/main/asciidoc/kafka-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'.", "location": {"path": "docs/src/main/asciidoc/kafka-dev-services.adoc", "range": {"start": {"line": 17, "column": 142}}}, "severity": "INFO"}

== Enabling / Disabling Dev Services for Kafka

Check warning on line 19 in docs/src/main/asciidoc/kafka-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Enabling / Disabling Dev Services for Kafka'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Enabling / Disabling Dev Services for Kafka'.", "location": {"path": "docs/src/main/asciidoc/kafka-dev-services.adoc", "range": {"start": {"line": 19, "column": 4}}}, "severity": "INFO"}

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.

Check warning on line 109 in docs/src/main/asciidoc/kafka-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'Redpanda'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'Redpanda'?", "location": {"path": "docs/src/main/asciidoc/kafka-dev-services.adoc", "range": {"start": {"line": 109, "column": 17}}}, "severity": "WARNING"}

Check warning on line 109 in docs/src/main/asciidoc/kafka-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'idempotence'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'idempotence'?", "location": {"path": "docs/src/main/asciidoc/kafka-dev-services.adoc", "range": {"start": {"line": 109, "column": 74}}}, "severity": "WARNING"}
You can disable those using:

Check warning on line 110 in docs/src/main/asciidoc/kafka-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/kafka-dev-services.adoc", "range": {"start": {"line": 110, "column": 22}}}, "severity": "INFO"}

[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
Expand Up @@ -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 <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
@@ -1,34 +1,33 @@
package io.quarkus.kafka.client.deployment;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import com.github.dockerjava.api.command.InspectContainerResponse;
import io.quarkus.devservices.common.ConfigureUtil;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.Transferable;
import org.testcontainers.utility.DockerImageName;

import com.github.dockerjava.api.command.InspectContainerResponse;

import io.quarkus.devservices.common.ConfigureUtil;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

/**
* 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 +100,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 db323e0

Please sign in to comment.