Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, it'll only bind internally to the compose network
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am no Kafka expert, but this change should not be necessary as exposure to the outside world via
localhost:9092
is assured byKAFKA_ADVERTISED_LISTENERS
on the above line, see docs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable sets the bind address of the Java server. The advertised listeners are what's stored in Zookeeper and what are returned to clients for future connections. They are very different settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also worth mentioning that setting the advertised listener to localhost will not allow you to add other Kafka client services to the compose network, as they will then try to connect to themselves rather than the broker container. Perhaps you should add two listeners
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to admit I don't understand what scenario the proposed change is trying to solve...
9092:9092
andKAFKA_ADVERTISED_LISTENERS
atlocalhost:9092
KAFKA_LISTENERS
atkafka:9092
.All this PR is trying to achieve is to replace deprecated
KAFKA_ADVERTISED_HOST_NAME
, no further improvements in mind, feel free to open your own PR if you feel a need to have e.g. multiple listeners in this example, but there are no "other kafka client services in the compose network" to worry about. Trying to keep the example minimalistic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bootstrap is. The actual client protocol is not.
Try this
Like I said, it'll try to connect to itself. That would be fine from outside the container, but not in the Compose bridge network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the proposed change (
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
) is not solving it, is it? It is likely my limited Kafka knowledge, but what s the addition of 0.0.0.0 good for here?The steps you provided in you last post demonstrate the issue with
localhost
, not why the0.0.0.0
should be added, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct that I'm proposing a different solution, I was simply referring to your previous comment that said the advertised listeners would work.
You've set this listeners value as the default, and so it'll bind to the container's canonical hostname. Since Compose allows containers over the bridge network to address hosts using service names, then it'll continue to work, but also, as linked setting to
0.0.0.0
"binds to all interfaces", which is generally more appropriate for allowing external connections.