Skip to content

Commit

Permalink
chore: access Kafka brokers from outside the k8s cluster (#5811) (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt authored Nov 14, 2023
1 parent b21facb commit 4d1d60d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions addons/kafka/configs/kafka-server-constraint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,6 @@
// other parameters
...
}

configuration: #KafkaParameter & {
}
11 changes: 11 additions & 0 deletions addons/kafka/scripts/kafka-server-setup.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ if [[ -n "$KB_KAFKA_BROKER_HEAP" ]]; then
echo "[jvm][KB_KAFKA_BROKER_HEAP]export KAFKA_HEAP_OPTS=${KB_KAFKA_BROKER_HEAP}"
fi

# for support access Kafka brokers from outside the k8s cluster
if [[ -n "$KAFKA_CFG_K8S_NODEPORT" ]];then
if [[ "broker,controller" = "$KAFKA_CFG_PROCESS_ROLES" ]] || [[ "broker" = "$KAFKA_CFG_PROCESS_ROLES" ]]; then
export KAFKA_CFG_ADVERTISED_LISTENERS="PLAINTEXT://${KB_HOST_IP}:${KAFKA_CFG_K8S_NODEPORT}"
echo "[cfg]KAFKA_CFG_ADVERTISED_LISTENERS=$KAFKA_CFG_ADVERTISED_LISTENERS"
echo "[cfg]KAFKA_CFG_LISTENERS=$KAFKA_CFG_LISTENERS"
echo "[cfg]KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=$KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP"
echo "[cfg]KAFKA_CFG_INTER_BROKER_LISTENER_NAME=$KAFKA_CFG_INTER_BROKER_LISTENER_NAME"
fi
fi

# cfg setting
if [[ "broker,controller" = "$KAFKA_CFG_PROCESS_ROLES" ]] || [[ "broker" = "$KAFKA_CFG_PROCESS_ROLES" ]]; then
# deleting this information can reacquire the controller members when the broker restarts,
Expand Down
2 changes: 1 addition & 1 deletion addons/kafka/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
templateRef: {{ include "kafka.name" . }}-configuration-tpl
volumeName: kafka-config
namespace: {{ .Release.Namespace }}
- name: kafka-jmx-configuration-tpl
- name: {{ include "kafka.name" . }}-jmx-configuration-tpl
templateRef: {{ include "kafka.name" . }}-jmx-configuration-tpl
volumeName: jmx-config
namespace: {{ .Release.Namespace }}
Expand Down
2 changes: 2 additions & 0 deletions addons/kafka/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ images:
##
debugEnabled: true

commonAnnotations: {}

kafkaBroker:
minNodeId: 100

Expand Down

0 comments on commit 4d1d60d

Please sign in to comment.