使用helm安装kafka
1. 安装helm
下载:curl https://labfileapp.oss-cn-hangzhou.aliyuncs.com/helm-v3.9.0-linux-amd64.tar.gz -o helm-v3.9.0-linux-amd64.tar.gz
tar -zxvf helm-v3.9.0-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm
2. 添加仓库并安装kafka:
helm repo add my-repo https://charts.bitnami.com/bitnamihelm install my-release my-repo/kafka
安装完成之后会有如下信息输出:
[galaxykube@localhost ~]$ helm install my-kafak bitnami/kafka
NAME: my-kafak
LAST DEPLOYED: Tue Jan 3 18:01:14 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: kafka
CHART VERSION: 20.0.2
APP VERSION: 3.3.1
** Please be patient while the chart is being deployed **
Kafka can be accessed by consumers via port 9092 on the following DNS name from within your cluster:
my-kafak-kafka.default.svc.cluster.local
Each Kafka broker can be accessed by producers via port 9092 on the following DNS name(s) from within your cluster:
my-kafak-kafka-0.my-kafak-kafka-headless.default.svc.cluster.local:9092
To create a pod that you can use as a Kafka client run the following commands:
kubectl run my-kafak-kafka-client --restart='Never' --image docker.io/bitnami/kafka:3.3.1-debian-11-r25 --namespace default --command -- sleep infinity
kubectl exec --tty -i my-kafak-kafka-client --namespace default -- bash
PRODUCER:
kafka-console-producer.sh \
--broker-list my-kafak-kafka-0.my-kafak-kafka-headless.default.svc.cluster.local:9092 \
--topic test
CONSUMER:
kafka-console-consumer.sh \
--bootstrap-server my-kafak-kafka.default.svc.cluster.local:9092 \
--topic test \
--from-beginning
默认kafka的部署只有1个节点和1个zookeeper,集器部署可以参考官网的参数配置。
https://artifacthub.io/packages/helm/bitnami/kafka
3. 删除kafka
helm delete my-release