You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently started to learn kafka and kubernetes. In order to learn more about setting up kubernetes and kafka clusters, I started a simple project involving a single node kubernetes 'cluster'. I intentionally did not opt for Minikube, as I want to be able to add more nodes to the cluster once I have solved the error described below. The goal is merely to learn more about how kubernetes and kafka works. Unfortunately, I ran into an error which after days of trying I have not been able to solve, so I hope someone can kindly help me out here. Issue is also posted on SO (https://stackoverflow.com/questions/65540179/problem-running-simple-ephemeral-kafka-instance-on-local-kubernetes-cluster)
I installed the kubernetes using kubeadm and use Calico as CNI plugin
kubeadm init
--apiserver-advertise-address=192.168.1.37 --pod-network-cidr=10.200.0.0/16. Note that I did not use 192.168.0.0/16 as pod-network-cidr (as described here: https://docs.projectcalico.org/getting-started/kubernetes/quickstart) since it conflicts with my home network)
File "/usr/src/app/main.py", line 18, in <module>
sc.run()
File "/usr/local/lib/python3.9/sched.py", line 151, in run
action(*argument, **kwargs)
File "/usr/src/app/src/data/send_data.py", line 17, in send_data
producer.send(topic=topic, value=data)
File "/usr/local/lib/python3.9/site-packages/kafka/producer/kafka.py", line 576, in send
self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
File "/usr/local/lib/python3.9/site-packages/kafka/producer/kafka.py", line 702, in _wait_on_metadata
raise Errors.KafkaTimeoutError(
kafka.errors.KafkaTimeoutError: KafkaTimeoutError: Failed to update metadata after 60.0 secs.
Logs of kafka-broker (only added the last lines, as log is quite long):
[2021-01-02 13:09:07,893] INFO [GroupCoordinator 0]: Starting up. (kafka.coordinator.group.GroupCoordinator)
[2021-01-02 13:09:07,894] INFO [GroupCoordinator 0]: Startup complete. (kafka.coordinator.group.GroupCoordinator)
[2021-01-02 13:09:07,897] INFO [GroupMetadataManager brokerId=0] Removed 0 expired offsets in 3 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
[2021-01-02 13:09:07,902] INFO [ProducerId Manager 0]: Acquired new producerId block (brokerId:0,blockStartProducerId:0,blockEndProducerId:999) by writing to Zk with path version 1 (kafka.coordinator.transaction.ProducerIdManager)
[2021-01-02 13:09:07,918] INFO [TransactionCoordinator id=0] Starting up. (kafka.coordinator.transaction.TransactionCoordinator)
[2021-01-02 13:09:07,919] INFO [Transaction Marker Channel Manager 0]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)
[2021-01-02 13:09:07,919] INFO [TransactionCoordinator id=0] Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)
[2021-01-02 13:09:07,948] INFO [/config/changes-event-process-thread]: Starting (kafka.common.ZkNodeChangeNotificationListener$ChangeEventProcessThread)
[2021-01-02 13:09:07,956] INFO [SocketServer brokerId=0] Started data-plane processors for 2 acceptors (kafka.network.SocketServer)
[2021-01-02 13:09:07,959] INFO Kafka version: 2.2.0 (org.apache.kafka.common.utils.AppInfoParser)
[2021-01-02 13:09:07,960] INFO Kafka commitId: 05fcfde8f69b0349 (org.apache.kafka.common.utils.AppInfoParser)
[2021-01-02 13:09:07,960] INFO [KafkaServer id=0] started (kafka.server.KafkaServer)
creating topics: testtopic25:1:1
Created topic testtopic25.
[2021-01-02 13:19:07,894] INFO [GroupMetadataManager brokerId=0] Removed 0 expired offsets in 0 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
[2021-01-02 13:29:07,894] INFO [GroupMetadataManager brokerId=0] Removed 0 expired offsets in 0 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
Logs of zookeeper pod:
2021-01-02 13:08:48,630 [myid:] - INFO [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
2021-01-02 13:08:48,630 [myid:] - INFO [main:ZooKeeperServerMain@95] - Starting server
2021-01-02 13:08:48,633 [myid:] - INFO [main:Environment@100] - Server environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:host.name=zookeeper-deploy-666b4657cd-m87rw
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.version=1.7.0_65
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper-3.4.6/bin/../build/classes:/opt/zookeeper-3.4.6/bin/../build/lib/*.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/opt/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/opt/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.6/bin/../conf:
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2021-01-02 13:08:48,634 [myid:] - INFO [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:java.compiler=<NA>
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:os.name=Linux
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:os.arch=amd64
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:os.version=5.5.2-050502-generic
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:user.name=root
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:user.home=/root
2021-01-02 13:08:48,636 [myid:] - INFO [main:Environment@100] - Server environment:user.dir=/opt/zookeeper-3.4.6
2021-01-02 13:08:48,637 [myid:] - INFO [main:ZooKeeperServer@755] - tickTime set to 2000
2021-01-02 13:08:48,637 [myid:] - INFO [main:ZooKeeperServer@764] - minSessionTimeout set to -1
2021-01-02 13:08:48,637 [myid:] - INFO [main:ZooKeeperServer@773] - maxSessionTimeout set to -1
2021-01-02 13:08:48,643 [myid:] - INFO [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
2021-01-02 13:09:07,233 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@197] - Accepted socket connection from /10.200.194.69:45848
2021-01-02 13:09:07,236 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@868] - Client attempting to establish new session at /10.200.194.69:45848
2021-01-02 13:09:07,238 [myid:] - INFO [SyncThread:0:FileTxnLog@199] - Creating new log file: log.1
2021-01-02 13:09:07,249 [myid:] - INFO [SyncThread:0:ZooKeeperServer@617] - Established session 0x176c336f9890000 with negotiated timeout 6000 for client /10.200.194.69:45848
2021-01-02 13:09:07,292 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x176c336f9890000 type:create cxid:0x2 zxid:0x3 txntype:-1 reqpath:n/a Error Path:/brokers Error:KeeperErrorCode = NoNode for /brokers
2021-01-02 13:09:07,296 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x176c336f9890000 type:create cxid:0x6 zxid:0x7 txntype:-1 reqpath:n/a Error Path:/config Error:KeeperErrorCode = NoNode for /config
2021-01-02 13:09:07,300 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x176c336f9890000 type:create cxid:0x9 zxid:0xa txntype:-1 reqpath:n/a Error Path:/admin Error:KeeperErrorCode = NoNode for /admin
2021-01-02 13:09:07,438 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x176c336f9890000 type:create cxid:0x15 zxid:0x15 txntype:-1 reqpath:n/a Error Path:/cluster Error:KeeperErrorCode = NoNode for /cluster
2021-01-02 13:09:07,958 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@592] - Got user-level KeeperException when processing sessionid:0x176c336f9890000 type:multi cxid:0x38 zxid:0x1c txntype:-1 reqpath:n/a aborting remaining multi ops. Error Path:/admin/preferred_replica_election Error:KeeperErrorCode = NoNode for /admin/preferred_replica_election
2021-01-02 13:09:17,204 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@197] - Accepted socket connection from /10.200.194.69:45918
2021-01-02 13:09:17,205 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@868] - Client attempting to establish new session at /10.200.194.69:45918
2021-01-02 13:09:17,208 [myid:] - INFO [SyncThread:0:ZooKeeperServer@617] - Established session 0x176c336f9890001 with negotiated timeout 30000 for client /10.200.194.69:45918
2021-01-02 13:09:17,394 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x176c336f9890001 type:setData cxid:0x4 zxid:0x1e txntype:-1 reqpath:n/a Error Path:/config/topics/testtopic25 Error:KeeperErrorCode = NoNode for /config/topics/testtopic25
2021-01-02 13:09:17,422 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@494] - Processed session termination for sessionid: 0x176c336f9890001
2021-01-02 13:09:17,424 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1007] - Closed socket connection for client /10.200.194.69:45918 which had sessionid 0x176c336f9890001
The zookeeper logs also seem to give an error:
KeeperErrorCode = NoNode for ...
I read many Stackoverflow posts, blogs, youtube vidoes, etc. to figure out what causes this, but haven't found a solution yet. I assume that the kafka broker cannot be reached, which seems to be confirmed by what I tried in the Troubleshooting section.
Troubleshooting
I tried disabling ufw, but issue still persisted.
When I log in to shell of the kafka-producer pod, I can ping the IP address of the kafka broker pod.
When I log in to shell of the kafka broker pod, I can ping the IP address of the zookeeper Pod and I can list the topics:
Hi,
I recently started to learn kafka and kubernetes. In order to learn more about setting up kubernetes and kafka clusters, I started a simple project involving a single node kubernetes 'cluster'. I intentionally did not opt for Minikube, as I want to be able to add more nodes to the cluster once I have solved the error described below. The goal is merely to learn more about how kubernetes and kafka works. Unfortunately, I ran into an error which after days of trying I have not been able to solve, so I hope someone can kindly help me out here. Issue is also posted on SO (https://stackoverflow.com/questions/65540179/problem-running-simple-ephemeral-kafka-instance-on-local-kubernetes-cluster)
I installed the kubernetes using kubeadm and use Calico as CNI plugin
OS:
18.04.4 LTS (Bionic Beaver)
Kubernetes version
Process to reproduce
/var/lib/etcd)
--apiserver-advertise-address=192.168.1.37 --pod-network-cidr=10.200.0.0/16. Note that I did not use 192.168.0.0/16 as pod-network-cidr (as described here: https://docs.projectcalico.org/getting-started/kubernetes/quickstart) since it conflicts with my home network)
zookeeper-service.yaml
kafka-service.yaml
zookeeper-deployment.yaml
kafka-deployment.yaml
kafka-producer.yaml
main.py
kafka-producer Dockerfile
Error
All services and pods are up and running, except the pod running the kafka-producer keeps failing:
kube-system pods
Calico
Service status
Logs of kafka-producer pod:
Logs of kafka-broker (only added the last lines, as log is quite long):
Logs of zookeeper pod:
The zookeeper logs also seem to give an error:
KeeperErrorCode = NoNode for ...
I read many Stackoverflow posts, blogs, youtube vidoes, etc. to figure out what causes this, but haven't found a solution yet. I assume that the kafka broker cannot be reached, which seems to be confirmed by what I tried in the Troubleshooting section.
Troubleshooting
I tried disabling ufw, but issue still persisted.
When I log in to shell of the kafka-producer pod, I can ping the IP address of the kafka broker pod.
When I log in to shell of the kafka broker pod, I can ping the IP address of the zookeeper Pod and I can list the topics:
However, when I try to send a message to this topic, I get an error:
Anyone an idea what causes these errors? Your help is much appreciated!
The text was updated successfully, but these errors were encountered: