Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[incubator/kafka] Support option to expose Kafka via NodePort #3754

Merged
merged 1 commit into from
Mar 2, 2018

Conversation

ghost
Copy link

@ghost ghost commented Feb 16, 2018

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.

{{ .Release.Name }}.{{ .Values.external.domain }}

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 a replicas value of 3, 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 toward
the a containerPort with a number matching its respective NodePort. 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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 16, 2018
@ghost
Copy link
Author

ghost commented Feb 16, 2018

/assign @mattfarina

@ghost ghost changed the title Support option to expose Kafka via NodePort [incubator/kafka] Support option to expose Kafka via NodePort Feb 22, 2018
@ghost
Copy link
Author

ghost commented Feb 22, 2018

/assign @unguiculus

@unguiculus
Copy link
Member

Copy link
Collaborator

@benjigoldberg benjigoldberg left a 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
Copy link
Collaborator

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?

Copy link
Contributor

@eicnix eicnix Feb 27, 2018

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.

Copy link
Author

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!!!

@@ -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`.
Copy link
Author

Choose a reason for hiding this comment

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

Note to self: typo ^

Copy link
Author

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.

@ghost ghost force-pushed the external-kafka-option branch from 9bc1e89 to a350248 Compare March 2, 2018 03:25
@jdumars
Copy link

jdumars commented Mar 2, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 2, 2018
@benjigoldberg
Copy link
Collaborator

LGTM

@unguiculus
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2018
@k8s-ci-robot k8s-ci-robot merged commit 603abee into helm:master Mar 2, 2018
@piter42zx
Copy link

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": |-
EXTERNAL://192.168.99.100:$((31090 + ${KAFKA_BROKER_ID}))
where 192.168.99.100 is the ip of the minikube.

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:
kafka-console-producer --broker-list 192.168.99.100:31090 --topic test1

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!

@benjigoldberg
Copy link
Collaborator

@josdotso I havent used the external config yet personally, any advice you can offer to @piter42zx?

@ghost
Copy link
Author

ghost commented Mar 21, 2018

@piter42zx : Thanks for the bug report!

See: #4400

cc: @benjigoldberg

rolanddb pushed a commit to Eneco/charts that referenced this pull request Apr 9, 2018
ichtar pushed a commit to Bestmile/charts that referenced this pull request May 15, 2018
voron pushed a commit to dysnix/helm-charts that referenced this pull request Sep 5, 2018
Signed-off-by: voron <av@arilot.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants