provectus / kafka-ui

Open-Source Web UI for Apache Kafka Management
Apache License 2.0
9.77k stars 1.18k forks source link

kafka ui can not connect to local kafka cluster #1846

Closed CharlesJu1 closed 2 years ago

CharlesJu1 commented 2 years ago

Describe the bug

follow the documentation to run kafka ui, it can not connect to local kafka cluster. Both kakfa ui and kafka cluster are running on a macos, not in docker container.

Set up

(base) ~/kafka-ui $ git log commit b4e52afbdb383c378404905d54fd32f8b2b58617 (HEAD -> master, origin/master, origin/HEAD) Author: Mgrdich 46796009+Mgrdich@users.noreply.github.com Date: Thu Apr 14 20:24:58 2022 +0400

Issues/1740 live tailing order (#1824)

* fixing Message addition order during Live tailing

* fixing Message addition order during Live tailing adding tests suites

* minor changes in the function name for prepending addTopics during live mode

* delete minor code repetition

Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>

Steps to Reproduce Steps to reproduce the behavior:

  1. start local kafka cluster.
    (base) /usr/local/etc/kafka $ /usr/local/opt/kafka/bin/kafka-server-start --version
    [2022-04-18 18:06:03,204] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)
    3.1.0 (Commit:37edeed0777bacb3).
  2. start kafka ui
    
    (base) ~/kafka-ui/kafka-ui-api $ ./mvnw spring-boot:run -Pprod
    [INFO] Scanning for projects...
    [INFO] 
    [INFO] ---------------------< com.provectus:kafka-ui-api >---------------------
    [INFO] Building kafka-ui-api 0.0.1-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] 
    [INFO] >>> spring-boot-maven-plugin:2.6.3:run (default-cli) > test-compile @ kafka-ui-api >>>
    [INFO] 
    [INFO] --- maven-checkstyle-plugin:3.1.1:check (checkstyle) @ kafka-ui-api ---
    [INFO] You have 0 Checkstyle violations.
    [INFO] 
    [INFO] --- git-commit-id-plugin:4.0.0:revision (get-the-git-infos) @ kafka-ui-api ---
    [INFO] 
    [INFO] --- antlr4-maven-plugin:4.7.1:antlr4 (default) @ kafka-ui-api ---
    [INFO] No grammars to process
    [INFO] ANTLR 4: Processing source directory /Users/cju/kafka-ui/kafka-ui-api/src/main/antlr4
    [INFO] 
    [INFO] --- frontend-maven-plugin:1.12.0:install-node-and-npm (install node and npm) @ kafka-ui-api ---
    [INFO] Node v14.17.1 is already installed.
    [INFO] 
    [INFO] --- frontend-maven-plugin:1.12.0:npm (npm install) @ kafka-ui-api ---
    [INFO] Running 'npm install' in /Users/cju/kafka-ui/kafka-ui-react-app
    [INFO] 
    [INFO] > kafka-ui@0.1.0 prepare /Users/cju/kafka-ui/kafka-ui-react-app
    [INFO] > cd .. && husky install kafka-ui-react-app/.husky
    [INFO] 
    [INFO] husky - Git hooks installed
    [INFO] npm WARN acorn-import-assertions@1.8.0 requires a peer of acorn@^8 but none is installed. You must install peer dependencies yourself.
    [INFO] npm WARN ajv-keywords@3.5.2 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
    [INFO] npm WARN ts-jest@26.5.6 requires a peer of jest@>=26 <27 but none is installed. You must install peer dependencies yourself.
    [INFO] 
    [INFO] audited 2315 packages in 7.811s
    [INFO] 
    [INFO] 227 packages are looking for funding
    [INFO]   run `npm fund` for details
    [INFO] 
    [INFO] found 3 vulnerabilities (1 moderate, 2 high)
    [INFO]   run `npm audit fix` to fix them, or `npm audit` for details
    [INFO] 
    [INFO] --- frontend-maven-plugin:1.12.0:npm (npm run build) @ kafka-ui-api ---
    [INFO] Running 'npm run build' in /Users/cju/kafka-ui/kafka-ui-react-app
    [INFO] 
    [INFO] > kafka-ui@0.1.0 build /Users/cju/kafka-ui/kafka-ui-react-app
    [INFO] > react-scripts build
    [INFO] 
    [INFO] Creating an optimized production build...

[INFO] Compiled successfully. [INFO] [INFO] File sizes after gzip: [INFO] [INFO] 445.99 kB build/static/js/main.a920c06c.js [INFO] 34.87 kB build/static/css/main.bf915e18.css [INFO] [INFO] The project was built assuming it is hosted at ./. [INFO] You can control this with the homepage field in your package.json. [INFO] [INFO] The build folder is ready to be deployed. [INFO] [INFO] Find out more about deployment here: [INFO] [INFO] https://cra.link/deployment [INFO] [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ kafka-ui-api --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 8 resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ kafka-ui-api --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:3.1.0:copy-resources (copy-resources) @ kafka-ui-api --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 29 resources [INFO] [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ kafka-ui-api --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ kafka-ui-api --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] <<< spring-boot-maven-plugin:2.6.3:run (default-cli) < test-compile @ kafka-ui-api <<< [INFO] [INFO] [INFO] --- spring-boot-maven-plugin:2.6.3:run (default-cli) @ kafka-ui-api --- [INFO] Attaching agents: []


| | | | | / _| /\ | |_ _ | |/ /_ / _| |___ | || || | | / | '| / | ' / ` / | ' \/ -) | ' </ | _| / / _| _/|__| || _|| // _| ._,_|||\| ||__,|| |__,| |_|

2022-04-18 18:09:03,391 INFO [background-preinit] o.h.v.i.u.Version: HV000001: Hibernate Validator 6.2.0.Final 2022-04-18 18:09:03,403 INFO [main] c.p.k.u.KafkaUiApplication: Starting KafkaUiApplication using Java 17.0.2 on Charless-MacBook-Pro-3.local with PID 14961 (/Users/cju/kafka-ui/kafka-ui-api/target/classes started by cju in /Users/cju/kafka-ui/kafka-ui-api) 2022-04-18 18:09:03,403 DEBUG [main] c.p.k.u.KafkaUiApplication: Running with Spring Boot v2.6.3, Spring v5.3.15 2022-04-18 18:09:03,403 INFO [main] c.p.k.u.KafkaUiApplication: No active profile set, falling back to default profiles: default 2022-04-18 18:09:04,308 INFO [main] o.s.d.r.c.RepositoryConfigurationDelegate: Bootstrapping Spring Data LDAP repositories in DEFAULT mode. 2022-04-18 18:09:04,350 INFO [main] o.s.d.r.c.RepositoryConfigurationDelegate: Finished Spring Data repository scanning in 37 ms. Found 0 LDAP repository interfaces. 2022-04-18 18:09:05,355 INFO [main] o.s.b.a.e.w.EndpointLinksResolver: Exposing 2 endpoint(s) beneath base path '/actuator' 2022-04-18 18:09:05,468 INFO [main] o.s.b.a.s.r.ReactiveUserDetailsServiceAutoConfiguration:

Using generated security password: 9b507c0c-51da-4d12-b9ca-24b9404aa6c8

2022-04-18 18:09:05,544 WARN [main] c.p.k.u.c.a.DisabledAuthSecurityConfig: Authentication is disabled. Access will be unrestricted. 2022-04-18 18:09:05,649 INFO [main] o.s.l.c.s.AbstractContextSource: Property 'userDn' not set - anonymous context will be used for read-write operations 2022-04-18 18:09:05,864 INFO [main] o.s.b.w.e.n.NettyWebServer: Netty started on port 8080 2022-04-18 18:09:05,877 INFO [main] c.p.k.u.KafkaUiApplication: Started KafkaUiApplication in 3.126 seconds (JVM running for 3.522)



**Expected behavior**
<!--
(A clear and concise description of what you expected to happen)
-->

Kafka UI should show the local kafka cluster. But it does not.

**Screenshots**
<!--
(If applicable, add screenshots to help explain your problem)
-->
<img width="1302" alt="Screen Shot 2022-04-18 at 6 12 12 PM" src="https://user-images.githubusercontent.com/1816882/163794007-4c3f87f5-b96f-4bc9-a0a0-68fb0051a67e.png">

**Additional context**
<!--
(Add any other context about the problem here)
-->
Haarolean commented 2 years ago

Hey, thanks for reaching out. Have you edit the app config? application.yml in your case.

github-actions[bot] commented 2 years ago

Hello there CharlesJu1! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀

CharlesJu1 commented 2 years ago

Hey, thanks for reaching out. Have you edit the app config? application.yml in your case.

No. I did not edit any of the config files in the src/main/resources folder.

Haarolean commented 2 years ago

You have to either specify your external config path location or edit the once in resources. You have to specify bootstrapServers and other properties to reach your kafka clusters.

CharlesJu1 commented 2 years ago

You have to either specify your external config path location or edit the once in resources. You have to specify bootstrapServers and other properties to reach your kafka clusters.

I copied the content from application-local.yml to application.yml and it worked. Thanks.

Haarolean commented 2 years ago

Glad it works!

Thilaknath commented 2 years ago

@CharlesJu1 Do you mind sharing your config in application.yaml?

Haarolean commented 2 years ago

@Thilaknath basically there are still all the same env variables (see bottom of the README file) but each underscore symbol is a new indentation line in yaml. An example

adrian-moisa commented 1 year ago

I've wasted a lot of time trying to get Kafka-GUI running. Thanks to the tutorial bellow now I understand properly how to setup a podman bridge network and how to configure advertised listeners in kafka. I'll list all the docker commands I've used to get a local one node setup running. Note: podman or docker, the commands are the same. Both kafka and kafka-ui are in containers. If you read the tutorial carefully you'll see this matters a lot. If you then want to connect from local app to container kafka you'll need extra settings.

Download Kafka & Zookeeper

Kafka Network

Zookeeper Volumes Needed to persist data. Notice that we are creating volumes for one zookeeper instance. In production we will have more instances.

Kafka Volume

Run Zookeeper Note: we are running zookeeper outside of the any api pods that are defined. We will have more pods all connected to the same kafka server. This one node setup needs to be improved in production to ensure scalability and resilience.

podman run -dt --name zookeeper \
--network=kafka-bridge \
-p 2181:2181 \
-e ZOOKEEPER_CLIENT_PORT=2181 \
-v 'zookeeper-dataDir:/data:Z' \
-v 'zookeeper-dataLogDir:/datalog:Z' \
-v 'zookeeper-logs:/logs:Z' \
docker.io/library/zookeeper

Run Kafka Note: we are running zookeeper outside of the mock-api-pod. Warning! ALLOW_PLAINTEXT_LISTENER=yes is for development env, not production.

podman run -dt --name kafka \
--network=kafka-bridge \
-p 7203:7203 \
-p 9092:9092 \
-v kafka-data:/kafka/data \
-e KAFKA_BROKER_ID=1 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
docker.io/bitnami/kafka

Create Topic This instruction can be defined in docker-compose or k8 yaml as an init instruction. For now (May 2023) we will manually configure it. Docker compose create kafka topics.

Kafka GUI Warning, starting kafka ui with this command does not create a password. In prod this needs to be auth.

Connecting to Kafka container CLI

Inspecting Kafka via local CLI

image