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

feat: enable access to kafka using container hostname #1786

Closed

Conversation

sermio-te
Copy link
Contributor

@sermio-te sermio-te commented Oct 20, 2023

What does this PR do?

This PR applies a fix to the entrypoint script template variables used in the kafka module container in order to make kafka accessible to other containers in the same network.

Why is it important?

Kafka container created by the kafka module needs to be exposed to the other containers in the same network.

Related issues

  • No

How to test this PR

After starting a Kafka container using the Kafka module, the KAFKA_ADVERTISED_LISTENERS should contain the endpoint of the container host.

E.g.
For Kafka container name set to broker, the /usr/sbin/testcontainers_start.sh script should contain the following value:

export KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:51702,BROKER://broker:9092

@sermio-te sermio-te requested a review from a team as a code owner October 20, 2023 09:26
@netlify
Copy link

netlify bot commented Oct 20, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 4adc310
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/653247d859b57000084c2ed8
😎 Deploy Preview https://deploy-preview-1786--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, although there is something needed to be changed. See comments inline

}
containerHost := strings.TrimPrefix(name, "/")

scriptContent := fmt.Sprintf(starterScriptContent, host, port.Int(), containerHost)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, I think we do not need to get the host in L70 anymore, right?

Could you update it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are one thing to care about. The advertised listeners should be two:

  1. one will be listening from outside the containers and used by the clients through Brokers fn. This one used the host from where docker executes and not the container host
  2. other will be listening in the container itself

You can look at the Java implementation. We can align both implementations and get the config.Hostname which looks like is not available in testcontainers.Container interface.

@sermio-te sermio-te deleted the kafka-advertised-listener-fix branch May 9, 2024 12:19
@sermio-te sermio-te restored the kafka-advertised-listener-fix branch May 9, 2024 12:19
@sermio-te sermio-te deleted the kafka-advertised-listener-fix branch May 9, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants