Quellcode durchsuchen

make application ready in 2 commands

Zhenya Taran vor 5 Jahren
Ursprung
Commit
4ef0ef873f

+ 21 - 0
README.md

@@ -0,0 +1,21 @@
+# Kafka-UI
+UI for Apache Kafka management
+
+## Table of contents
+- [Getting started](#getting-started)
+
+## Getting started
+
+Build docker container
+
+```
+./mvnw clean install -Pprod
+```
+
+Run docker-compose
+
+```
+docker-compose -f ./docker/kafka.yaml
+```
+
+Access application via http://localhost:8080

+ 0 - 27
docker/kafka-second.yaml

@@ -1,27 +0,0 @@
----
-version: '2'
-services:
-  zookeeperSecond:
-    image: confluentinc/cp-zookeeper:5.1.0
-    environment:
-      ZOOKEEPER_CLIENT_PORT: 2181
-      ZOOKEEPER_TICK_TIME: 2000
-    ports:
-      - 2182:2181
-
-  kafkaSecond:
-    image: confluentinc/cp-kafka:5.1.0
-    depends_on:
-      - zookeeperSecond
-    ports:
-      - 9093:9092
-      - 9998:9998
-    environment:
-      KAFKA_BROKER_ID: 1
-      KAFKA_ZOOKEEPER_CONNECT: zookeeperSecond:2181
-      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafkaSecond:29092,PLAINTEXT_HOST://localhost:9092
-      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
-      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
-      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
-      JMX_PORT: 9998
-      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.rmi.port=9998

+ 38 - 11
docker/kafka.yaml

@@ -1,27 +1,54 @@
 ---
 version: '2'
 services:
-  zookeeper:
+
+  kafka-ui:
+    container_name: kafka-ui-api
+    image: kafka-ui-api:latest
+    ports:
+      - 8080:8080
+    depends_on:
+      - zookeeper0
+      - zookeeper1
+      - kafka0
+      - kafka1
+
+  zookeeper0:
     image: confluentinc/cp-zookeeper:5.1.0
     environment:
       ZOOKEEPER_CLIENT_PORT: 2181
       ZOOKEEPER_TICK_TIME: 2000
-    ports:
-      - 2181:2181
 
-  kafka:
+  kafka0:
     image: confluentinc/cp-kafka:5.1.0
     depends_on:
-      - zookeeper
-    ports:
-      - 9092:9092
-      - 9997:9997
+      - zookeeper0
+    environment:
+      KAFKA_BROKER_ID: 1
+      KAFKA_ZOOKEEPER_CONNECT: zookeeper0:2181
+      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka0:29092,PLAINTEXT_HOST://localhost:9092
+      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
+      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
+      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
+      JMX_PORT: 9997
+      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
+
+  zookeeper1:
+    image: confluentinc/cp-zookeeper:5.1.0
+    environment:
+      ZOOKEEPER_CLIENT_PORT: 2181
+      ZOOKEEPER_TICK_TIME: 2000
+
+  kafka1:
+    image: confluentinc/cp-kafka:5.1.0
+    depends_on:
+      - zookeeper1
     environment:
       KAFKA_BROKER_ID: 1
-      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
-      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
+      KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2181
+      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9092
       KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
       KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
       KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
       JMX_PORT: 9997
-      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.rmi.port=9997
+      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=9997

+ 7 - 0
kafka-ui-api/Dockerfile

@@ -0,0 +1,7 @@
+FROM openjdk:13
+VOLUME /tmp
+ARG JAR_FILE
+COPY "/target/${JAR_FILE}" "/kafka-ui-api.jar"
+
+EXPOSE 8080
+CMD java -jar kafka-ui-api.jar

+ 34 - 3
kafka-ui-api/pom.xml

@@ -17,6 +17,7 @@
         <java.version>13</java.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <node.version>v12.13.1</node.version>
+        <git.revision>latest</git.revision>
     </properties>
 
     <dependencyManagement>
@@ -90,6 +91,14 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.2.4.RELEASE</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -169,11 +178,33 @@
                             </execution>
                         </executions>
                     </plugin>
+                    <plugin>
+                        <groupId>com.spotify</groupId>
+                        <artifactId>dockerfile-maven-plugin</artifactId>
+                        <version>1.4.10</version>
+                        <configuration>
+                            <skipPush>true</skipPush>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>default</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                </goals>
+                                <configuration>
+                                    <tag>${git.revision}</tag>
+                                    <repository>${project.artifactId}</repository>
+                                    <buildArgs>
+                                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
+                                        <JAR_NAME>${project.artifactId}.jar</JAR_NAME>
+                                    </buildArgs>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
                 </plugins>
             </build>
-            <properties>
-                <spring.profiles.active>prod</spring.profiles.active>
-            </properties>
         </profile>
     </profiles>
 

+ 7 - 7
kafka-ui-api/src/main/resources/application.yml

@@ -3,14 +3,14 @@ kafka:
     -
       id: wrYGf-csNgiGdK7B_ADF7Z
       name: local
-      bootstrapServers: localhost:9092
-      jmxHost: localhost
+      bootstrapServers: kafka0:29092
+      jmxHost: kafka0
       jmxPort: 9997
-      zookeeper: localhost:2181
+      zookeeper: zookeeper0:2181
     -
       id: dMMQx-WRh77BKYas_g2ZTz
       name: secondLocal
-      bootstrapServers: localhost:9093
-      jmxHost: localhost
-      jmxPort: 9998
-      zookeeper: localhost:2182
+      bootstrapServers: kafka1:29092
+      jmxHost: kafka1
+      jmxPort: 9997
+      zookeeper: zookeeper1:2181