Giter Club home page Giter Club logo

kafka-aws's Introduction

Multi-Broker HA Kafka Cluster in AWS

This Packer, Ansible, Docker and Terraform code can be used to instantiate your Kafka Cluster in AWS with its own Zookeeper cluster.

Getting Started

These instructions will get you a copy of the infrastructure up and running on your AWS account.

Prerequisites

  • AWS-Cli
  • Packer
  • Ansible-2.8
  • Terraform v0.12.20 or above
  • AWS account with an IAM user having appropriate permissions

Installing Ansible 2.8 on a Ubuntu 18.04 machine

sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository ppa:ansible/ansible-2.8
sudo apt-get install ansible=2.8.8-1ppa~bionic

Installing Ansible 2.8 using pip

pip install ansible==2.8.0

Underlying Concept

The idea here is that we'll be first creating an AMI with Packer using the Ansible provisioner having Kafka and Scala bundled inside a docker container on the Machine Image.

Once the image is created we'll be calling another Ansible script which uses Terraform module to provision the AWS Infrastructure. The module provisions virtual machines or cloud instances, and then we hand over the reins to Ansible again to finish up the configuration of our OS and Kafka Cluster.

Building the Golden Image

Clone the repository on your local machine with all the pre-requisites installed.

The easiest way to use AWS credentials is creating a profile and exporting the profile name as an environment variable.

$ aws configure --profile <name of your profile>
AWS Access Key ID [None]: *****************
AWS Secret Access Key [None]: *******************
Default region name [None]: us-east-1
Default output format [None]:

$ export AWS_PROFILE=<name of your profile>

Browse to the directory with packer manifests

$ cd packer

Open the variables.json file and add the variables for the version and region in which you need to create the AMI.

{
    "aws_region": "us-west-2",
    "ami_name": "KAFKA_AMI",
    "kafka_version": "0.8.2.0",
    "scala_version": "2.9.1"
}

Run the following command for creating an AMI with the appropriate version of Kafka and Zookeeper installed

$ packer build -var-file=variables.json packer.json

Note the AMI-ID as this would be required in the next step.

Variants

There are two variants for the infrastructure deployment. One is for Existing VPC and the other one for a New-VPC. Browse to the specific directory and follow further instructions.

SSH pem file

You'll need to create a key pair in AWS. This would be used by the Cluster instances and later by Ansible script to do the config changes. Once the key pair is created download the .pem file and move it to the ansible dir for eg. in case of New-VPC it would be placed at:

New-VPC/ansible/<key-filename>.pem

Remember to change the permission of the key file !

In the subsequent steps add the name of the key to variables in external_vars.yml

Cluster Variables

Open the external_var.yml and change the values for your environment.

$ nano ansible/vars/external_vars.yml

Things to note

  • For using Existing-VPC deployment there must be 1 VPC and id 3 subnet ids in the variables file.

  • For using New-VPC 1 VPC cidr block and 3 subnet cidr blocks must be provided.

Deployment

Browse to the ansible directory and run the ansible playbook command

$ cd ../ansible
$ ansible-playbook -i dyn_inven terraform.yaml

Testing

After ansible playbook is done deploying and configuring the resources, open the exhibitor console for anyone of the deployed servers by browsing to the following endpoint:

<public-ip>:8181

Built With

  • Packer - The EBS image builder
  • Docker - Kafka and Zookeeper libraries packer
  • Terraform - Used to Provision the underlying infrastructure on AWS
  • Ansible - The main scripts handler and joining all the things together

Authors

  • Arsalan Ul Haq Khan

Acknowledgments

kafka-aws's People

Contributors

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