Code Monkey home page Code Monkey logo

kafka-admin-api's Introduction

kafka-admin-api

Provides simple REST endpoints for listing and creating Kafka topics.

About

This is a REST API for Kafka services administration on Trusted Analytics Platform.

This application utilizes a Kafka service broker (from TAP) and its client API to manage Kafka resources.

It performs basic operations, like:

  • list all available topics
  • create a topic
  • read topic messages

Configuring the application

The web service uses application.properties or application-cloud.properties to provide configuration data:

key description
kafka.brokersUri A list of Kafka brokers
kafka.zookeeperUri A list of all zookeeper brokers URI addresses

To configure logging level the following property can be used:

logging.level.org.trustedanalytics=DEBUG

API

After deployment to TAP the Kafka Admin API provides the following endpoints:

URL method operation
/api/topics GET list the topics
/api/topics POST create a new topic
/api/topics/{name} GET read topic messages
/api/topics/{name} POST write plain text message to a topic

Swagger UI

You can work with the API via the SwaggerUI.

Just go to the following example URL and use the Swagger functionality:

http://kafka-admin-api.{domain.com}/swagger-ui.html

Deploying to Cloud Foundry

Manual deployment

To deploy this application to Cloud Foundry you could use the following manifest file (after putting your own configuration data):

---
applications:
- name: kafka-admin-api
  memory: 512MB
  instances: 1
  host: kafka-admin-api
  path: target/kafka-admin-api-0.1.0.jar
  services:
  - kafka-instance

Notes:

  • Executing any mvn clean or mvn package will delete or override any changes to manifest.yml respectively.

  • Replacing "kafka-instance" service binding to some other service requires updating application-cloud.properties:

      kafka.brokerUri=${vcap.services.YOUR-KAFKA-INSTANCE.credentials.uri}
      kafka.zookeeperUri=${vcap.services.YOUR-KAFKA-INSTANCE.credentials.zookeeperUri}
    

Automated deployment

  • Switch to deploy directory: cd deploy
  • Install tox: sudo -E pip install --upgrade tox
  • Run: tox
  • Activate virtualenv with installed dependencies: . .tox/py27/bin/activate
  • Run deployment script: python deploy.py providing required parameters when running script (python deploy.py -h to check script parameters with their descriptions).

Local development

For local development Zookeeper and Kafka must be installed.

Zookeeper

Zookeeper can be downloaded from Apache ZooKeeper Releases

I assume you are working on Linux machine and will be using kafka-admin-api directory as a workspace.

Simple installation could look like this:

cd ~/kafka-admin-api
mkdir zookeeper
cd zookeeper
wget http://apache.mirrors.lucidnetworks.net/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar -xvf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6/

To test the installation:

cp conf/zoo_sample.cfg conf/zoo.cfg
bin/zkServer.sh start

You should see something similar to:

JMX enabled by default
Using config: /home/ubuntu/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

Kafka

Kafka downloads ara available here: http://kafka.apache.org/downloads.html. The current stable version is 0.10.0.0.

I pick version kafka_2.11-0.10.0.0.tgz from the following mirror: http://mirrors.sonic.net/apache/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz

cd ~/kafka-admin-api
mkdir kafka
cd kafka
wget http://mirrors.sonic.net/apache/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz
tar xvzf kafka_2.11-0.10.0.0.tgz  

To test if it works, start the server:

cd kafka_2.11-0.10.0.0
bin/kafka-server-start.sh config/server.properties

Building and running

To run this API locally you can execute the following commands:

mvn clean package
mvn spring-boot:run

Testing

For testing you can use SwaggerUI or curl.

Future improvements

  • new operation: delete topic
  • performance improvement: Zookeeper connection handling
  • exception handling: zookeeper connection lost during service startup

kafka-admin-api's People

Contributors

szymonbultrowicz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.