1Panel icon indicating copy to clipboard operation
1Panel copied to clipboard

[Bug] Kafka installation cannot be used on the host machine

Open xiahao90 opened this issue 1 year ago • 2 comments

Contact Information

No response

1Panel Version

v1.10.21

Problem Description

默认安装的kafka是使用的bitnami/kafka,在该镜像官方下面的描述中有一段描述如下: image 按照1panel默认启动的话没有配置9094端口,所以会导致kafka只能在同默认网络1panel-network下的其他容器中使用。如果想宿主机或内网其他服务器或外网使用则会报错。

我试了修改默认docker-composer配置的三行后可以正常在宿主机中使用127.0.0.1:9094访问

services:
  kafka:
    container_name: ${CONTAINER_NAME}
    restart: always
    environment:
      ALLOW_PLAINTEXT_LISTENER: 'yes'
      KAFKA_CFG_LOG_RETENTION_MS: 60000
      KAFKA_CFG_MAX_REQUEST_SIZE: 524288000
      KAFKA_CFG_MESSAGE_MAX_BYTES: 524288000
      KAFKA_CFG_REPLICA_FETCH_MAX_BYTES: 524288000
      KAFKA_CFG_FETCH_MESSAGE_MAX_BYTES: 524288000
      KAFKA_CFG_PARTITION_FETCH_BYTES: 524288000
      KAFKA_CFG_NODE_ID: 0
      KAFKA_CFG_PROCESS_ROLES: controller,broker
+     KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
+     KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://${CONTAINER_NAME}:${PANEL_APP_PORT_HTTP},EXTERNAL://localhost:9094
+     KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
      KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_HEAP_OPTS: '-Xmx512m -Xms256m'
    networks:
      - 1panel-network
    ports:
      - "${PANEL_APP_PORT_HTTP}:9092"
+     - "9094:9094"
    image: bitnami/kafka:3.9.0
    labels:
      createdBy: "Apps"
networks:  
  1panel-network:  
    external: true

建议修复该问题

Steps to Reproduce

直接点击安装kafka就能重现

The expected correct result

No response

Related log output

No response

Additional Information

No response

xiahao90 avatar Dec 11 '24 08:12 xiahao90

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Contact Information

No response

1Panel Version

v1.10.21

Problem Description

**The default installed kafka is bitnami/kafka. There is a description in the official description of the image as follows: ** image **If 1panel is started by default, port 9094 is not configured, so kafka can only be used in other containers under the same default network 1panel-network. If you want to use the host machine or other servers in the internal network or the external network, an error will be reported. **

I tried modifying the three lines of the default docker-composer configuration and I can access it normally using 127.0.0.1:9094 on the host

services:
  kafka:
    container_name: ${CONTAINER_NAME}
    restart: always
    environment:
      ALLOW_PLAINTEXT_LISTENER: 'yes'
      KAFKA_CFG_LOG_RETENTION_MS: 60000
      KAFKA_CFG_MAX_REQUEST_SIZE: 524288000
      KAFKA_CFG_MESSAGE_MAX_BYTES: 524288000
      KAFKA_CFG_REPLICA_FETCH_MAX_BYTES: 524288000
      KAFKA_CFG_FETCH_MESSAGE_MAX_BYTES: 524288000
      KAFKA_CFG_PARTITION_FETCH_BYTES: 524288000
      KAFKA_CFG_NODE_ID: 0
      KAFKA_CFG_PROCESS_ROLES: controller,broker
+ KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
+ KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://${CONTAINER_NAME}:${PANEL_APP_PORT_HTTP},EXTERNAL://localhost:9094
+ KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
      KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_HEAP_OPTS: '-Xmx512m -Xms256m'
    networks:
      - 1panel-network
    ports:
      - "${PANEL_APP_PORT_HTTP}:9092"
+ - "9094:9094"
    image: bitnami/kafka:3.9.0
    labels:
      createdBy: "Apps"
networks:
  1panel-network:
    external: true

It is recommended to fix this issue

Steps to Reproduce

Just click to install kafka and you can reproduce it

The expected correct result

No response

Related log output

No response

Additional Information

No response

wanghe-fit2cloud avatar Dec 11 '24 08:12 wanghe-fit2cloud

建议是将 9094 端口相关配置设为可配置项,这样可以支持用户在创建应用时自定义设置。

https://github.com/1Panel-dev/appstore/tree/dev/apps/kafka

wanghe-fit2cloud avatar Dec 11 '24 10:12 wanghe-fit2cloud