-
Notifications
You must be signed in to change notification settings - Fork 16.8k
[incubator/kafka] Support option to expose Kafka via NodePort #3754
Conversation
/assign @mattfarina |
/assign @unguiculus |
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.
@josdotso This is a huge step for this chart! Thanks for doing this work. I can think of a number of people who will be thrilled that external access is now an option.
One question about image tags.
The init container/pod selector game is a bit amusing, but really Kubernetes doesnt give many other options. I attempted this same functionality with nginx-ingress/headless service/TCP exposure but never had much luck, I think mostly due to kafka configurations which you appear to have nailed in your config. Lovely to see this configuration though -- it involves far fewer moving parts than other attempts that I have seen!
## ref: https://github.com/Yolean/kubernetes-kafka/blob/master/kafka/50kafka.yml | ||
initContainers: | ||
- name: init-config | ||
image: solsson/kafka-initutils@sha256:c98d7fb5e9365eab391a5dcd4230fc6e72caf929c60f29ff091e3b0215124713 |
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.
Is there a better image tag by any chance?
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.
Shouldn't the image also be configureable? Otherwise people that cannot download from docker hub are unable to use this feature.
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.
Agreed on both points. I'll fix this ASAP. Thanks!!!
incubator/kafka/README.md
Outdated
@@ -106,8 +112,32 @@ my-release-zookeeper:2181 --list` | |||
|
|||
Where `my-release` is the name of your helm release. | |||
|
|||
### Connecting to Kafka from outside Kubernetes | |||
|
|||
Review and optioanlly override to enable the example text concerned with external access in `values.yaml`. |
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.
Note to self: typo ^
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.
@benjigoldberg , @eicnix : Please take another look. I believe I've addressed all concerns above.
9bc1e89
to
a350248
Compare
/ok-to-test |
LGTM |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: josdotso, unguiculus The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi, First of all, thanks a lot for this! I installed the chart locally in a minikube with the external access enabled and configured "advertised.listeners": |- My objective is to access the Kafka broker from outside the K8s cluster. I used port-forward on the zookeeper pod and successfully created the topic test1 (as explained in the chart notes). However, when I try to create a message using the following command to start an interactive message producer session I get the error shown below: WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) Am I missing some configuration? Thanks in advance! |
@josdotso I havent used the external config yet personally, any advice you can offer to @piter42zx? |
@piter42zx : Thanks for the bug report! See: #4400 cc: @benjigoldberg |
Signed-off-by: voron <av@arilot.com>
README.md excerpt:
Connecting to Kafka from outside Kubernetes
Review and optioanlly override to enable the example text concerned with external access in
values.yaml
.Once configured, you should be able to reach Kafka via NodePorts, one per replica. In kops where private, topology is enabled, this feature publishes an internal round-robin DNS record using the following naming scheme. The external access feature of this chart was tested with kops on AWS using flannel networking. If you wish to enable external access to Kafka running in kops, your security groups will likely need to be adjusted to allow non-Kubernetes nodes (e.g. bastion) to access the Kafka external listener port range.
Port numbers for external access used at container and NodePort are unique to each container in the StatefulSet. Using the default
external.firstListenerPort
number with areplicas
value of3
, the following container and NodePorts will be opened for external access:31090
,31091
,31092
. All of these ports should be reachable from any host to NodePorts are exposed because Kubernetes routes each NodePort from entry node to pod/container listening on the same port (e.g.31091
).The
external.servicePort
at each external access service (one such service per pod) is a relay towardthe a
containerPort
with a number matching its respectiveNodePort
. The range of NodePorts is set, but should not actually listen, on all Kafka pods in the StatefulSet. As any given pod will listen only one such port at a time, setting the range at every Kafka pod is a reasonably safe configuration.