ZooKeeper was the external service that held Kafka's cluster metadata, until Kafka 4.0 removed it in favour of KRaft mode.
In ZooKeeper mode it handled:
Broker discovery and health monitoring
Topic, partition and configuration metadata
Electing the controller broker, which then chose partition leaders
Consumer group coordination for the legacy consumer
In KRaft mode, a few controller nodes keep this metadata in a log inside Kafka. They agree on each change with Raft, a consensus protocol where a majority must accept it. Operators run one system instead of two. A Kafka cluster still in ZooKeeper mode must migrate to KRaft before upgrading to 4.x.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.