我正在使用 MINIKUBE 在 Kubernetes 中部署 Kafka/Zookeeper。下面是我的 YAML 文件:
##################################
# Setup Zookeeper Deployment
##################################
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: zookeeper
name: zookeeper
spec:
replicas: 1
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- image: wurstmeister/zookeeper
# imagePullPolicy: Always
name: zookeeper
ports:
- containerPort: 2181
##################################
# Setup Zookeeper Service
##################################
---
apiVersion: v1
kind: Service
metadata:
labels:
app: zookeeper-service
name: zookeeper-service
spec:
type: NodePort
ports:
- name: zookeeper-port
port: 2181
nodePort: 30181
targetPort: 2181
selector:
app: zookeeper
---
##################################
# Setup Kafka service
##################################
apiVersion: v1
kind: Service
metadata:
labels:
app: kafka-service
name: kafka-service
spec:
type: NodePort
ports:
- name: kafka-port
port: 9092
nodePort: 30092
targetPort: 9092
selector:
app: kafka
---
##################################
# Setup Kafka Broker Deployment
##################################
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: kafka
name: kafka
spec:
replicas: 1
template:
metadata:
labels:
app: kafka
spec:
containers:
- env:
- name: KAFKA_ADVERTISED_HOST_NAME
value: 192.168.99.100
- name: KAFKA_ADVERTISED_PORT
value: "30092"
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: 192.168.99.100:30181
- name: KAFKA_ADVERTISED_LISTENERS
value: "PLAINTEXT://192.168.99.100:30092"
# - name: KAFKA_LISTENERS
# value: "PLAINTEXT://192.168.99.100:9092"
- name: KAFKA_CREATE_TOPICS
value: "vignesh-topic:1:1"
- name: LOG4J_LOGGER_KAFKA_AUTHORIZER_LOGGER
value: "DEBUG"
image: wurstmeister/kafka
#imagePullPolicy: Always
name: kafka
ports:
- containerPort: 9092
我已经使用 MINIKUBE 使用以下命令在本地机器 Kubernetes 中成功创建了部署/服务。
kubectl create -f kafka.yml
我已经在 Kafka pod 中导航,并且可以使用以下命令创建主题,
./bin/kafka-topics.sh --create --zookeeper 192.168.99.100:30181 --replication-factor 1 --partitions 1 --topic test-topic
但是,当我尝试向主题(测试主题)发送消息时,系统会抛出以下错误。
笔记
当我运行netstat -tunap时,端口 30092 和 30181 都显示已建立。
我不知道我在这里错过了什么。请帮助我前进。
感谢并感谢您的帮助。