From 5e38c481eb04dff0c19c160e3df0bf5865694cd0 Mon Sep 17 00:00:00 2001 From: Jose Antonio Carmona Date: Fri, 7 Aug 2020 12:23:07 +0200 Subject: [PATCH] [bitnami/kafka] Add external connection to cluster LB (#3343) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add external connection to cluster LB Signed-off-by: joancafom * Chart version bump * Document the change in Upgrading section Co-authored-by: Carlos Rodríguez Hernández --- bitnami/kafka/Chart.yaml | 2 +- bitnami/kafka/README.md | 14 ++++++++++++-- bitnami/kafka/templates/svc.yaml | 13 +++++++++++-- bitnami/kafka/values-production.yaml | 7 ++++++- bitnami/kafka/values.yaml | 7 ++++++- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/bitnami/kafka/Chart.yaml b/bitnami/kafka/Chart.yaml index 445d1a8dd..56cccb647 100644 --- a/bitnami/kafka/Chart.yaml +++ b/bitnami/kafka/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: kafka -version: 11.7.3 +version: 11.8.0 appVersion: 2.6.0 description: Apache Kafka is a distributed streaming platform. keywords: diff --git a/bitnami/kafka/README.md b/bitnami/kafka/README.md index c65d92806..be99059f3 100644 --- a/bitnami/kafka/README.md +++ b/bitnami/kafka/README.md @@ -161,8 +161,10 @@ The following tables lists the configurable parameters of the Kafka chart and th |---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------| | `service.type` | Kubernetes Service type | `ClusterIP` | | `service.port` | Kafka port for client connections | `9092` | -| `service.internalPort` | Kafka port for inter-broker connectionsKafka port for inter-broker connections | `9093` | -| `service.nodePort` | Nodeport for client connections | `""` | +| `service.internalPort` | Kafka port for inter-broker connections | `9093` | +| `service.externalPort` | Kafka port for external connections | `9094` | +| `service.nodePorts.client` | Nodeport for client connections | `""` | +| `service.nodePorts.external` | Nodeport for external connections | `""` | | `service.loadBalancerIP` | loadBalancerIP for Kafka Service | `nil` | | `service.loadBalancerSourceRanges` | Address(es) that are allowed when service is LoadBalancer | `[]` | | `service.annotations` | Service annotations | `{}`(evaluated as a template) | @@ -523,6 +525,8 @@ Note: You need to know in advance the node ports that will be exposed so each Ka The pod will try to get the external ip of the node using `curl -s https://ipinfo.io/ip` unless `externalAccess.service.domain` is provided. +Following the aforementioned steps will also allow to connect the brokers from the outside using the cluster's default service (when `service.type` is `LoadBalancer` or `NodePort`). Use the property `service.externalPort` to specify the port used for external connections. + ### Sidecars If you have a need for additional containers to run within the same pod as Kafka (e.g. an additional metrics or logging exporter), you can do so via the `sidecars` config parameter. Simply define your container according to the Kubernetes container spec. @@ -631,6 +635,12 @@ You can enable this initContainer by setting `volumePermissions.enabled` to `tru ## Upgrading +### To 11.8.0 + +External access to brokers can now be achived through the cluster's Kafka service. + +- `service.nodePort` -> deprecated in favor of `service.nodePorts.client` and `service.nodePorts.external` + ### To 11.7.0 The way to configure the users and passwords changed. Now it is allowed to create multiple users during the installation by providing the list of users and passwords. diff --git a/bitnami/kafka/templates/svc.yaml b/bitnami/kafka/templates/svc.yaml index 673c53ac7..189cb9ffd 100644 --- a/bitnami/kafka/templates/svc.yaml +++ b/bitnami/kafka/templates/svc.yaml @@ -31,10 +31,19 @@ spec: port: {{ .Values.service.port }} protocol: TCP targetPort: kafka-client - {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePort)) }} - nodePort: {{ .Values.service.nodePort }} + {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.client)) }} + nodePort: {{ .Values.service.nodePorts.client }} {{- else if eq .Values.service.type "ClusterIP" }} nodePort: null {{- end }} + {{- if and .Values.externalAccess.enabled (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) }} + - name: tcp-external + port: {{ .Values.service.externalPort }} + protocol: TCP + targetPort: kafka-external + {{- if (not (empty .Values.service.nodePorts.external)) }} + nodePort: {{ .Values.service.nodePorts.external }} + {{- end }} + {{- end }} selector: {{- include "kafka.matchLabels" . | nindent 4 }} app.kubernetes.io/component: kafka diff --git a/bitnami/kafka/values-production.yaml b/bitnami/kafka/values-production.yaml index 3aff06e0f..24e02c21f 100644 --- a/bitnami/kafka/values-production.yaml +++ b/bitnami/kafka/values-production.yaml @@ -474,10 +474,15 @@ service: ## Kafka port for inter-broker connections ## internalPort: 9093 + ## Kafka port for external connections + ## + externalPort: 9094 ## Specify the nodePort value for the LoadBalancer and NodePort service types. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport ## - nodePort: "" + nodePorts: + client: "" + external: "" ## Set the LoadBalancer service type to internal only. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer ## diff --git a/bitnami/kafka/values.yaml b/bitnami/kafka/values.yaml index 3044bcf0c..392f0e432 100644 --- a/bitnami/kafka/values.yaml +++ b/bitnami/kafka/values.yaml @@ -479,10 +479,15 @@ service: ## Kafka port for inter-broker connections ## internalPort: 9093 + ## Kafka port for external connections + ## + externalPort: 9094 ## Specify the nodePort value for the LoadBalancer and NodePort service types. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport ## - nodePort: "" + nodePorts: + client: "" + external: "" ## Set the LoadBalancer service type to internal only. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer ##