kubesphere部署kafka单点
Kafka默认端口是9092。这是Kafka broker之间通信和客户端连接的默认端口。
想要改变默认端口到9093,你可以这样设置
listeners=PLAINTEXT://:9093
其他:
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper.test-project:2181
- KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka.test-project:9092,EXTERNAL://{外网IP}:31163
- KAFKA_HEAP_OPTS: -Xms128m -Xmx512m
1-镜像:
bitnami/kafka:3.2.1
2- 需要暴漏 9092和 9094
配置外网一定要注意:
env:
- name: KAFKA_BROKER_ID
value: '0'
- name: ALLOW_PLAINTEXT_LISTENER
value: 'yes'
- name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
value: 'INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT'
- name: KAFKA_CFG_ZOOKEEPER_CONNECT
value: 'zookeeper-v2-node.katgattbase:2181'
- name: KAFKA_CFG_LISTENERS
value: ' INTERNAL://:9092,EXTERNAL://:9094'
- name: KAFKA_CFG_ADVERTISED_LISTENERS
value: >-
INTERNAL://kafka-one-node.katgattbase:9092,EXTERNAL://123.57.143.145:32006
- name: KAFKA_HEAP_OPTS
value: '-Xms128m -Xmx512m'
- name: KAFKA_INTER_BROKER_LISTENER_NAME
value: INTERNAL
- name: TZ
value: Asia/Shanghai
折中的方法只能是外网测试用,
最好在 白名单中设置一下ip, 这样更安全一些
对应截图:
4-设置存储卷
存储: kafka-pvc nfsRWO /bitnami/kafka/data
配置:
秘钥:
服务: 有状态服务
名称: kafka
镜像: bitnami/kafka:3.2.1
副本数量:
环境变量:
- TZ: Asia/Shanghai
- KAFKA_BROKER_ID: 0
- ALLOW_PLAINTEXT_LISTENER: yes
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper.test-project:2181
- KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka.test-project:9092,EXTERNAL://{外网IP}:31163
- KAFKA_HEAP_OPTS: -Xms128m -Xmx512m
启动命令:
端口: TCP 9092
资源:
时区: 同步主机时区
svc: NodePort 9094 31163
服务:
欢迎来撩 : 汇总all