• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Perl
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HostDB: a new tool to help manage data center inventory and write applications around it.

HostDB

HostDB: a new tool to help manage data center inventory and write applications around it.

HostDB is our attempt to solve the problem of finding hosts and their purposes in a large environment. HostDB acts as a Single source of truth about all Physical and Virtual servers and is used to define their purpose. It helps us group our servers through tags and all the software written by the operations team revolves around HostDB. HostDB acts as the centralized configuration store for all sorts of information.

PS: Though the names are same, this project is not related to this hostdb

Hosts

Any Host that exists is created inside HostDB upon birth and has information about itself in YAML. This info can be Hardware info, amount of CPU/RAM or Network FQDN, IP address, Rack, Switch, Physical location or Function, e.g what application software the host needs? The YAML can contain just about anything, it can be varied across hosts and can be ever evolving.

Tags

Hosts are grouped together with tags, similar to a host - a tag also has information about itself in YAML This information is applied to all hosts which are members of a tag. e.g a tag called VM can be applied to all virtual machines and can be used to define properties that are shared by all VMs. To be useful a tag must have member hosts.

Versioning

HostDB provides versioning and the ability to roll back to a previous version for each and every host or tag.

API

The above concepts may look simple, but, can be used in extremely powerful ways with an API. and that’s exactly what HostDB provides. HostDB provides a REST api which can be used to create hosts, get members of a particular tag etc. We use this feature to automate just about everything at flipkart. Creating Virtual hosts, creating DNS records, automatic monitoring and escalations and building automated infrastructures. Services can do a periodic lookups to Hostdb and keep updating themselves of changes.

User Interfaces

HostDB provides a variety of user interfaces which can be used to interact with HostDB by applications and users.

  • Web Application
  • Rest API
  • Command Line Interface
  • HostDB::Client Perl Module
  • Some example use of HostDB

HostDB: Key/Value Store with a difference

HostDB is a key-value store, keys are grouped into namespaces based on type. ‘hosts’ is a special namespace which is central to all other namespaces. Keys inside ‘hosts’ are server names and their values contains mostly information and configuration details needed by server itself or applications it runs.

Applications can create unique keys(tags) which are application specific. You can add servers as ‘members’ of these keys which in turn helps you to consider your key(tag) as a group of hosts.

HostDB provides namespaces e.g you can create keys(tags) that exist in a specific namespace and are access controlled, only member applications can read/write to keys of this namespace. One can create access controls for each namespace or even for each key.

HostDB uses plain text files as its storage. The namespaces are represented as directories and keys are files inside the namespace directory. These files contain a key’s config in YAML.

The ‘members’ are also stored in files in a subdirectory in the namespace’s directory. The access permissions on the namespaces are also stored in a subdirectory.

GIT

The complete file structure of HostDB is in a git repository and git handles the versioning and transactions for HostDB. leveraging git means that we have a simple transactional store, which offers history as well as versioning. We can go to a previous version of a host or tag config at any point in time.

Web based Interface

HostDB provides a Web based interface for uses to interact.

Command Line tool

HostDB provides a command line tool that is extremely helpful in writing those small bash one liners to get information out fast. Want to find out all machines with 24 GB of ram which are part of the search cluster. no problem!

Add an object:
$ hostdb add hosts/host1.yourdomain.com
Add host to tag:
$ hostdb add -m "adding new member" tags/nm-prod/members/new.yourdomain.com
Get host IP: 
$ hostdb get hosts/host1.yourdomain.com/Network/IP
Get tag members: 
$ hostdb get tags/nm-prod/members

HostDB::Client Perl Module

We use Perl extensively and have a Perl Module that can be used by applications to interact with HostDB. This module provides an object oriented interface over HostDB REST API.

use HostDB::Client;
my $hdb - HostDB::Client->new(\%options);
my $output - $hdb->get($id[, $revision, $raw]);
my $output - $hdb->revisions($id[, $limit]);

HostDB has been central to almost all software written by the devops at flipkart and has allowed us to scale exponentially without a fuss. We hope you find it useful too. HostDB is now available on github, so go fork it,

Setting up Server

Update: The install-server-debian.sh scripts does almost everything for you without creating debian packages.

  1. Go to src/server/
  2. Make config changes as necessary. You might need to modify these:
DEBIAN/control                     - Package name and version
etc/apache2/sites-available/hostdb - Apache config for API
etc/hostdb/server_conf.yaml        - Main server config
etc/hostdb/clients                 - App users config
/etc/logrotate.d/hostdb            - Log rotation config

  1. Go back to src
  2. dpkg-deb -b server/ hostdb-server.deb
  3. dpkg -i hostdb-server.deb
  4. Put a cipher key in /var/lib/hostdb/cipher_key - Used for creating session token
  5. Create a directory structure like this in /var/lib/hostdb/namespaces
namespaces/
|-- .git/            
|-- hosts/           <’hosts’ namespace>
|   |-- server1      
|   |-- server2
|   |-- .perms/
|       |-- .default  
|       |-- server2  
|-- tags/            <’tags’ namespace>
    |-- tag1         
    |-- tag2
    |-- .members/
    |   |-- tag1     
    |   |-- tag2
    |-- .perms/
        |-- .default  
        |-- tag1     

ACL file format:
---
user1:
  data: RO
  members: RW
group1:
  members: RO

  1. All above files should be readable and writable for your apache user
  2. Restart apache
  3. Test - https://hostdb.yourdomain.com/v1/

Setting up CLI tool

Update: The install-client-debian.sh scripts does almost everything for you without creating debian packages.

  1. Go to src/client
  2. Make config changes as necessary. You might need to modify these:
DEBIAN/control              - Package name and version
etc/hostdb/client_conf.yaml - Mention server name in this

  1. Go back to src
  2. dpkg-deb -b client/ hostdb-client.deb
  3. dpkg -i hostdb-client.deb
  4. Test - /usr/local/bin/hostdb get hosts

Setting up Web interface

Update: The install-server-debian.sh scripts does almost everything for you without creating debian packages.

  1. Go to src/webui/
  2. Make config changes as necessary. You might need to modify these:
DEBIAN/control                     - Package name and version
var/www/hostdb/index.html          - Change cookie domain name, modify to support your namespaces.
etc/apache2/sites-available/hostdb - Apache config for WEB UI

  1. Go back to src
  2. dpkg-deb -b webui/ hostdb-webui.deb
  3. dpkg -i hostdb-webui.deb
  4. Test - https://hostdb.yourdomain.com

More Repositories

1

recyclerlistview

High performance listview for React Native and web!
TypeScript
5,236
star
2

DUS

A differential download based Over The Air(OTA) Update system for React Native
Java
75
star
3

Swifty

Swifty is a networking stack designed to serve modern iOS apps
Swift
55
star
4

flipcast

A scalable push notification platform for mobile, devices and web.
Scala
53
star
5

loader

Distributed Load generation Platform with Server Side Monitoring Capabilities.
JavaScript
24
star
6

aesop

A keen Observer of changes that can also relay change events reliably to interested parties. Provides useful infrastructure for building Eventually Consistent data sources and systems.
Java
23
star
7

phantom-mysql-proxy

The Mysql proxy leverages the Phantom extensibility support.
Java
22
star
8

typescriptpoet

A Java API for generating typescript source files (.ts files)
Java
14
star
9

foxtrot

A store abstraction and analytics system for real-time event data.
Java
14
star
10

fk-ios-chat-heads

Chat heads for collaborative shopping
Objective-C
13
star
11

GraceKelly

A Best Effort Cache Synchronization Library In Java
Java
13
star
12

now-you-see-me

View tracking framework for iOS
Swift
9
star
13

quartz

Java
9
star
14

kingsmoot

Leader election library based on etcd
Go
7
star
15

netmap

netmap and VALE - very fast packet I/O from userspace (FreeBSD/Linux)
C
7
star
16

now-you-see-react

View tracking framework for React Native on iOS
Swift
6
star
17

harness

Harness project - an automation test framework for functional tests
Java
5
star
18

multitenancy

Tenant gem for supply chain
Ruby
5
star
19

sample-cart-app

4
star
20

MySQL-replication-listener

This is a fork of MySQL-replication-listener on launchpad. https://launchpad.net/mysql-replication-listener
C++
4
star
21

GenericTrackingFramework

View Tracking Framework
Swift
3
star
22

nosh

Interactive text-based console with pluggable commands for Java applications
Java
3
star
23

linux

Flipkart fork of Linux kernel
C
3
star
24

test5

2
star
25

espion

Codahale Metrics for Scala
Scala
2
star
26

Test

2
star
27

fk-apache-camel-kafka-async

Apache Camel Kafka Component - which uses Kafka Asynchronous producer
Java
2
star
28

grafana-plugins

2
star
29

ilip-motion-meter

Java
2
star
30

test-for-transfer-ownership

For GHE lock test
1
star
31

autodeploy

Java
1
star
32

ceph-tools

Misc tools for a Ceph admin
Python
1
star
33

testing

1
star
34

l3tc

layer-3 transparent compressor
C
1
star
35

ask-me

Ask any question about a flipkart product and we will give you relevant answers from reliable sources.
JavaScript
1
star
36

vishwa-test

test repo
1
star
37

hash-utility

A simple utility to authenticate a service call, based on HMAC (signature).
Java
1
star
38

obelix

Java
1
star
39

git-test

To check the integration of git with reviewboard
1
star
40

git-test-new

1
star
41

pwa-mocks

HTML
1
star
42

fixit-felix

Fixit-Felix troubleshooting workshop
JavaScript
1
star
43

hibernate-addons

Java
1
star
44

apl-bulkingestor

Java
1
star
45

fbe_fa_tagging_poc_storm

Java
1
star