嗨,我是kubernets的新手,我正在使用minikube单节点集群进行本地开发和测试。
Host: Ubuntu 16.04 LTS.
Minikube: Virtual box running minikube cluster
我的要求是我需要在minikube上部署kafka和zookeeper,应该用来生成或消费消息。我遵循这个链接,并成功地部署在minikube它的详细信息如下
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kafka-service 10.0.0.15 <pending> 9092:30244/TCP 46m
kubernetes 10.0.0.1 <none> 443/TCP 53m
zoo1 10.0.0.43 <none> 2181/TCP,2888/TCP,3888/TCP 50m
zoo2 10.0.0.226 <none> 2181/TCP,2888/TCP,3888/TCP 50m
zoo3 10.0.0.6 <none> 2181/TCP,2888/TCP,3888/TCP 50m
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
kafka-deployment-3583985961-f2301 1/1 Running 0 48m
zookeeper-deployment-1-1598963595-vgx1l 1/1 Running 0 52m
zookeeper-deployment-2-2038841231-tdsff 1/1 Running 0 52m
zookeeper-deployment-3-2478718867-5vjcj 1/1 Running 0 52m
$ kubectl describe service kafka-service
Name: kafka-service
Namespace: default
Labels: app=kafka
Annotations: <none>
Selector: app=kafka
Type: LoadBalancer
IP: 10.0.0.15
Port: kafka-port 9092/TCP
NodePort: kafka-port 30244/TCP
Endpoints: 172.17.0.7:9092
Session Affinity: None
Events: <none>
我已经将kafka\u播发的\u主机名设置为minikube ip(192.168.99.100)。现在我使用的消息生产者 $cat textfile.log | kafkacat -b $(minikube ip):30244 -t mytopic
它不发布下面给出的消息消息
% Auto-selecting Producer mode (use -P or -C to override)
% Delivery failed for message: Local: Message timed out
任何人都可以帮助如何发布和消费信息。
4条答案
按热度按时间ryoqjall1#
离开前面的答案和您的评论,这里是一个kafka服务的非常基本的示例代码
type=Nodeport
.wsxa1bj12#
我遵循如下所示。
放http://minikube-ip:在浏览器中输入端口以获取kafka manager的ui页。
来源https://technology.amis.nl/2019/03/24/running-apache-kafka-on-minikube/
pgpifvop3#
我知道这是一篇很老的文章。你能在minikube解决并运行kafka+zookeeper吗?我能够使用minikubev0.17.1成功地运行一个简单的单集群kafka和zookeeper部署,并分别使用kafkacat producer和consumer生成和使用消息。我能够在ubuntu和macosx上成功运行这些程序。部署和服务YAML如下:
zookeeper-deployment.yml
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: IfNotPresent name: zookeeper ports: - containerPort: 2181
zookeeper-service.yml
```apiVersion: v1
kind: Service
metadata:
labels:
app: zookeeper-service
name: zookeeper-service
spec:
type: NodePort
ports:
port: 2181
nodePort: 30181
targetPort: 2181
selector:
app: zookeeper
`kafka-deployment.yml`
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: kafka
name: kafka
spec:
replicas: 1
template:
metadata:
labels:
app: kafka
spec:
containers:
value: "192.168.99.100"
value: "30092"
value: "1"
value: 192.168.99.100:30181
value: "test-topic:1:1"
image: wurstmeister/kafka
imagePullPolicy: IfNotPresent
name: kafka
ports:
`kafka-service.yml`
apiVersion: v1
kind: Service
metadata:
labels:
app: kafka-service
name: kafka-service
spec:
type: NodePort
ports:
port: 9092
nodePort: 30092
targetPort: 9092
selector:
app: kafka
tpxzln5u4#
您使用了一个类型为loadbalancer的服务,该服务用于云提供程序(您可以看到该服务正在等待外部ip地址)。。挂起状态。。。这永远不会发生)。你应该试试nodeport。