Add Juan feedback

This commit is contained in:
tompizmor
2020-01-28 14:05:27 +01:00
parent 136776bf40
commit 32d9f637da
6 changed files with 97 additions and 47 deletions
+29
View File
@@ -321,6 +321,35 @@ auth.certificatesSecret=kafka-certificates
> **Note**: If the JKS files are password protected (recommended), you will need to provide the password to get access to the keystores. To do so, use the `auth.certificatesPassword` option to provide your password.
### Accessing Kafka brokers from outside the cluster
In order to access Kafka Brokers from outside the cluster, an additional listener and advertised listener must be configured. Additionally, a specific service per kafka pod will be created.
There are two ways of configuring external access. Using LoadBalancer services or using NodePort services.
#### Using LoadBalancer services
```console
externalAccess.enabled=true
externalAccess.service.type=LoadBalancer
externalAccess.service.port=19092
externalAccess.service.loadBalancerIP={'external-ip-1', 'external-ip-2'}
```
You need to know in advance the load balancer IPs so each Kafka broker advertised listener is configured with it.
#### Using NodePort services
```console
externalAccess.enabled=true
externalAccess.service.type=NodePort
externalAccess.service.nodePort={'node-port-1', 'node-port-2'}
```
You need to know in advance the NodePort that will be exposed for each Kafka broker. It will be used to configure the advertised listener of each broker.
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.
## Persistence
The [Bitnami Kafka](https://github.com/bitnami/bitnami-docker-kafka) image stores the Kafka data at the `/bitnami/kafka` path of the container.
+5 -5
View File
@@ -60,8 +60,12 @@ To connect to your Kafka server from outside the cluster check the following inf
{{- else }}
Kafka brokers domain: You can get the external node ip from the Kafka configuration file with the following command (Check the EXTERNAL listener)
Kafka brokers domain: You can get the external node IP from the Kafka configuration file with the following commands (Check the EXTERNAL listener)
1. Obtain the pod name:
kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "kafka.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=kafka"
2. Obtain pod configuration
kubectl exec -it KAFKA_POD -- cat /opt/bitnami/kafka/conf/server.properties | grep advertised.listeners
{{- end }}
@@ -76,10 +80,6 @@ To connect to your Kafka server from outside the cluster check the following inf
Kafka Brokers domain: You will have a different external IP for each Kafka broker. Get the external ip from `-external` suffixed services: `kubectl get svc`.
Kafka Brokers port: {{ .Values.externalAccess.service.port }}
{{- else }}
Unsupported service type for external access.
{{- end }}
{{- end }}
+3 -3
View File
@@ -265,8 +265,8 @@ Compile all warnings into a single message, and call fail.
*/}}
{{- define "kafka.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "kafka.validateValues.loadBalancerIPListLength" .) -}}
{{- $messages := append $messages (include "kafka.validateValues.nodePortListLength" .) -}}
{{- $messages := append $messages (include "kafka.validateValues.loadBalancerIPListLength" .) -}}
{{- $messages := append $messages (include "kafka.validateValues.externalAccessServiceType" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
@@ -281,7 +281,7 @@ Compile all warnings into a single message, and call fail.
{{- $replicaCount := int .Values.replicaCount }}
{{- $loadBalancerIPListLength := len .Values.externalAccess.service.loadBalancerIP }}
{{- if and ( .Values.externalAccess.enabled ) ( not (eq $replicaCount $loadBalancerIPListLength )) (eq .Values.externalAccess.service.type "LoadBalancer") -}}
kafka: .Values.externalAccess.service.loadBalancerIP
kafka: externalAccess.service.loadBalancerIP
Number of replicas and loadBalancerIP array length must be the same.
{{- end -}}
{{- end -}}
@@ -299,7 +299,7 @@ kafka: .Values.externalAccess.service.nodePort
{{/* Validate values of Kafka - service type for external access */}}
{{- define "kafka.validateValues.externalAccessServiceType" -}}
{{- if and (not (eq .Values.externalAccess.service.type "NodePort")) (not (eq .Values.externalAccess.service.type "LoadBalancer")) -}}
kafka: .Values.externalAccess.service.type
kafka: externalAccess.service.type
Available servive type for external access are NodePort or LoadBalancer.
{{- end -}}
{{- end -}}
@@ -0,0 +1,39 @@
{{- if .Values.externalAccess.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "kafka.fullname" . }}-scripts
labels: {{- include "kafka.labels" . | nindent 4 }}
data:
setup.sh: |-
#!/bin/bash
HOSTNAME=$(hostname -s)
ID=${HOSTNAME:(-1)}
# Configure external ip and port
{{- if eq .Values.externalAccess.service.type "LoadBalancer" }}
export EXTERNAL_ACCESS_IP=$(echo '{{ .Values.externalAccess.service.loadBalancerIP }}' | tr -d '[]' | cut -d ' ' -f "$(($ID + 1))")
export EXTERNAL_ACCESS_PORT={{ .Values.externalAccess.service.port }}
{{- else if eq .Values.externalAccess.service.type "NodePort" }}
{{- if .Values.externalAccess.service.domain }}
export EXTERNAL_ACCESS_IP={{ .Values.externalAccess.service.domain }}
{{- else }}
export EXTERNAL_ACCESS_IP=$(curl -s https://ipinfo.io/ip)
{{- end }}
export EXTERNAL_ACCESS_PORT=$(echo '{{ .Values.externalAccess.service.nodePort }}' | tr -d '[]' | cut -d ' ' -f "$(($ID + 1))")
{{- end }}
# Configure Kafka internal and external listeners
export KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
export KAFKA_CFG_LISTENERS=INTERNAL://:{{ .Values.service.port }},EXTERNAL://:${EXTERNAL_ACCESS_PORT}
export KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL
{{- if .Values.advertisedListeners }}
export KAFKA_CFG_ADVERTISED_LISTENERS={{ .Values.advertisedListeners }}
{{- else }}
export KAFKA_CFG_ADVERTISED_LISTENERS="INTERNAL://${MY_POD_NAME}.{{ template "kafka.fullname" . }}-headless.{{.Release.Namespace}}.svc.{{ .Values.clusterDomain }}:{{ .Values.service.port }},EXTERNAL://${EXTERNAL_ACCESS_IP}:${EXTERNAL_ACCESS_PORT}"
{{- end }}
exec /entrypoint.sh /run.sh
{{- end }}
+14 -32
View File
@@ -59,39 +59,10 @@ spec:
{{- if .Values.resources }}
resources: {{ toYaml .Values.resources | nindent 12 }}
{{- end }}
{{- if .Values.externalAccess.enabled }}
command:
- bash
- -ec
- |
HOSTNAME=$(hostname -s)
ID=${HOSTNAME:(-1)}
# Configure external ip and port
{{- if eq .Values.externalAccess.service.type "LoadBalancer" }}
export EXTERNAL_ACCESS_IP=$(echo '{{ .Values.externalAccess.service.loadBalancerIP }}' | tr -d '[]' | cut -d ' ' -f "$(($ID + 1))")
export EXTERNAL_ACCESS_PORT={{ .Values.externalAccess.service.port }}
{{- else if eq .Values.externalAccess.service.type "NodePort" }}
{{- if .Values.externalAccess.service.domain }}
export EXTERNAL_ACCESS_IP={{ .Values.externalAccess.service.domain }}
{{- else }}
export EXTERNAL_ACCESS_IP=$(curl -s https://ipinfo.io/ip)
{{- end }}
export EXTERNAL_ACCESS_PORT=$(echo '{{ .Values.externalAccess.service.nodePort }}' | tr -d '[]' | cut -d ' ' -f "$(($ID + 1))")
{{- end }}
# Configure Kafka internal and external listeners
{{- if .Values.externalAccess.enabled }}
export KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
export KAFKA_CFG_LISTENERS=INTERNAL://:{{ .Values.service.port }},EXTERNAL://:${EXTERNAL_ACCESS_PORT}
export KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL
{{- if .Values.advertisedListeners }}
export KAFKA_CFG_ADVERTISED_LISTENERS={{ .Values.advertisedListeners }}
{{- else }}
export KAFKA_CFG_ADVERTISED_LISTENERS="INTERNAL://${MY_POD_NAME}.{{ template "kafka.fullname" . }}-headless.{{.Release.Namespace}}.svc.{{ .Values.clusterDomain }}:{{ .Values.service.port }},EXTERNAL://${EXTERNAL_ACCESS_IP}:${EXTERNAL_ACCESS_PORT}"
{{- end }}
{{- end }}
exec /entrypoint.sh /run.sh
- /scripts/setup.sh
{{- end }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.image.debug | quote }}
@@ -267,6 +238,11 @@ spec:
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
volumeMounts:
{{- if .Values.externalAccess.enabled }}
- name: scripts
mountPath: /scripts/setup.sh
subPath: setup.sh
{{- end }}
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /bitnami/kafka
@@ -306,6 +282,12 @@ spec:
mountPath: /etc/jmx-kafka
{{ end }}
volumes:
{{- if .Values.externalAccess.enabled }}
- name: scripts
configMap:
name: {{ include "kafka.fullname" . }}-scripts
defaultMode: 0755
{{- end }}
{{ if .Values.metrics.jmx.enabled }}
- name: jmx-config
configMap:
@@ -1,10 +1,10 @@
{{- if .Values.externalAccess.enabled -}}
{{- $fullName := include "kafka.fullname" . }}
{{- $replicaCount := .Values.replicaCount | int }}
{{- $root := . }}
{{- if .Values.externalAccess.enabled }}
{{- $fullName := include "kafka.fullname" . }}
{{- $replicaCount := .Values.replicaCount | int }}
{{- $root := . }}
{{- range $i, $e := until $replicaCount }}
{{- $targetPod := printf "%s-%d" (printf "%s" $fullName) $i }}
{{- $targetPod := printf "%s-%d" (printf "%s" $fullName) $i }}
---
apiVersion: v1
@@ -28,7 +28,7 @@ spec:
{{- else }}
port: {{ index $root.Values.externalAccess.service.nodePort $i }}
{{- end }}
{{- if and $root.Values.externalAccess.service.nodePort (eq $root.Values.externalAccess.service.type "NodePort") }}
{{- if $root.Values.externalAccess.service.nodePort }}
nodePort: {{ index $root.Values.externalAccess.service.nodePort $i }}
{{- end }}
{{- if eq $root.Values.externalAccess.service.type "LoadBalancer" }}
@@ -41,4 +41,4 @@ spec:
statefulset.kubernetes.io/pod-name: {{ $targetPod }}
---
{{- end }}
{{- end -}}
{{- end }}