kafka-ui icon indicating copy to clipboard operation
kafka-ui copied to clipboard

Login into kafka server with username and password failed.

Open nhatthanh020996 opened this issue 1 year ago • 4 comments

Issue submitter TODO list

  • [X] I've searched for an already existing issues here
  • [X] I'm running a supported version of the application which is listed here and the feature is not present there

Is your proposal related to a problem?

This is my docker compose file that helps me to create my kafka server.

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
    restart: unless-stopped

  kafka:
    image: wurstmeister/kafka
    depends_on:
    - zookeeper
    ports:
      - "9092:9092"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENERS: SASL_PLAINTEXT://:9092
      KAFKA_ADVERTISED_LISTENERS: SASL_PLAINTEXT://localhost:9092
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
      ALLOW_PLAINTEXT_LISTENER: 'yes'
      KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf"
      KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.auth.SimpleAclAuthorizer
      KAFKA_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
      KAFKA_SASL_ENABLED_MECHANISMS: PLAIN
      KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
      KAFKA_SECURITY_PROTOCOL: SASL_PLAINTEXT
      KAFKA_SUPER_USERS: User:admin,User:enzo
      KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: 'true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./kafka_server_jaas.conf:/etc/kafka/kafka_server_jaas.conf
    
    restart: unless-stopped

kafka_server_jaas.conf

 KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_enzo="cisternino";
};

KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
user_admin="admin-secret";
};

Client {};

This is my docker for creating kafka-ui

version: '2'
services:
  kafka-ui:
    image: provectuslabs/kafka-ui
    container_name: kafka-ui
    ports:
    - "8080:8080"
    environment:
      KAFKA_CLUSTERS_0_NAME: 'local'
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 'localhost:9092'
      KAFKA_CLUSTERS_0_ZOOKEEPER: 'zookeeper:2181'
      KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT
      KAFKA_CLUSTERS_0_PROPERTIES_SASL_MECHANISM: PLAIN
      KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG: 'org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin-secret";'

I get the following error after runing kafka-ui docker:

AdminClient clientId=kafka-ui-admin-1707208145-7] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

Describe the feature you're interested in

I want to log into the kafka server successfully.

Describe alternatives you've considered

I did read this issue, however the issue still remain. https://github.com/provectus/kafka-ui/issues/573

Version you're running

the latest version

Additional context

No response

nhatthanh020996 avatar Feb 06 '24 08:02 nhatthanh020996

Hello there nhatthanh020996! 👋

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. 👀

github-actions[bot] avatar Feb 06 '24 08:02 github-actions[bot]

KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 'localhost:9092'

If you point to localhost within a container it will send requests to the container's loopback interface and since Kafka lives in another container this cannot work.

Instead put kafka ui and kafka on the same docker network and resolve using the container name like so :

KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 'kafka:9092'

rgdev avatar Feb 27 '24 14:02 rgdev