• This repository has been archived on 15/Oct/2021
  • Stars
    star
    185
  • Rank 201,723 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created almost 8 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

This service provides a REST interface for querying for the list of hosts that belong to all microservices.

⚠️ This repository has been archived and is no longer accepting contributions ⚠️

Discovery

This service provides a REST interface for querying for the list of hosts that belong to a given service in microservice infrastructure. Host information is written to and read from backend store (DynamoDB by default). This project relies on the following libraries:

  • Flask (web-framework)
  • Flask-Cache (for caching and reusing results for GET requests)
  • Pynamodb (for reading/writing DynamoDB data)

Also check requirements.txt for other dependencies.

Discovery service settings

Discovery service settings are controlled by environment variables.

  • HOST_TTL
    • If the last heartbeat was not performed in the last HOST_TTL seconds, discovery service will remove host from backend storage. Default value is 600 (10 minutes).
  • CACHE_TTL
    • Flask cache expiration in seconds, discovery calls BACKEND_STORAGE to fill the cache. This cache is used for hosts retrieval by service or service repo. Default value is 30 seconds.
  • BACKEND_STORAGE
    • Type of the backend storage used in discovery service. Supported values are: DynamoDB, InMemory, InFile. By default DynamoDB backend is used.
  • CACHE_TYPE
    • Supported values 'simple' or 'null'. Default value is 'null' which effectively turn flask caching off.
  • APPLICATION_DIR
    • Application directory.
  • APPLICATION_ENV
    • Environment discovery service runs in, e.g., development or production. Default value is development.
  • DEBUG
    • If debug mode is used. Default value is true.
  • LOG_LEVEL
    • Set logging level. Default value is DEBUG.
  • PORT
    • Port flask app using. Default value is 8080.
  • DYNAMODB_TABLE_HOSTS
    • Used only in case of DynamoDB backend.
  • DYNAMODB_URL
    • Used only for development in case of DynamoDB backend running locally.
  • DYNAMODB_CREATE_TABLES_IN_APP
    • Used for creating DynamoDB table, useful only in case DynamoDB backend storage used.

API

GET /v1/registration/:service

Returns metadata for the given :service.

  • service
    • (required, string) name of the service metadata is queried for.

On successful response, response body will be in the following JSON format:

{
    "env": "...",
    "hosts": [],
    "service": "..."
}
  • env
    • (required, string) environment discovery service runs in, e.g., development or production.
  • hosts
    • (required, object) list of non expired hosts (hosts that last checked in to discovery service in the last HOST_TTL period). Each host is in the following JSON format:

      {
          "ip_address": "...",
          "last_check_in": "...",
          "port": 9211,
          "revision": "...",
          "service": "...",
          "service_repo_name": "...",
          "tags": {}
      }
    • ip_address

      • (required, string) ip address of the host.
    • last_check_in

      • (required, string) heartbeat timestamp converted to string, last time host registered with discovery service.
    • port

      • (required, integer) port on which the host expects connections, Envoy will connect to this port.
    • revision

      • (required, string) service SHA running on the host.
    • service

      • (required, string) service name.
    • service_repo_name

      • (required, string) service repo, used for selecting hosts based on the service_repo (can be empty if not set).
    • tags

      • (required, object) see tags here.
  • service
    • (required, string) service name.

GET /v1/registration/repo/:service_repo_name

Returns list of non expired hosts for :service_repo_name (query based on secondary index, for example, DynamoDB GSI). Format is the same as query based on service.

POST /v1/registration/:service

Registers a host with a service. Response body does not contain any data.

  • service
    • (required, string) Service for which operation is performed.

Request params:

  • ip
    • (required, string) ip address of the host.
  • service_repo_name
    • (optional, string) service repository name, can be used for quick search.
  • port
    • (required, integer) port on which the host expects connections, Envoy will connect to this port.
  • revision
    • (required, string) SHA of the revision the service is currently running.
  • tags
    • (required, object) JSON in the following format.

DELETE /v1/registration/:service/:ip_address

Deletes the host for the given service with ip_address. Returns response code 400 if no service/ip_address entity exists.

  • service
    • (required, string) name of the service metadata is queried for.
  • ip
    • (required, string) ip address of the host.

POST /v1/loadbalancing/:service/:ip_address

Updates the weight of hosts for load balancing purposes.

  • service
    • (required, string) Service name for which weight is updated.
  • ip_address
    • (optional, string) IP address of the host for which weight is updated. If not given, all hosts for the given service will have their weights updated.

Request params:

  • load_balancing_weight
    • (required, integer) Host weight, an integer between 1 and 100.

Tags JSON

  {
     "az": "...",
     "region": "...",
     "instance_id": "...",
     "canary": false,
     "load_balancing_weight": 1
  }
  • az
    • (required, string) AWS availability zone that the host is running in. You can provide arbitrary but the same value for all hosts if zone aware stats/routing is not required. If you use non AWS backend storage currently you have to provide az anyway, you can use some fixed predefined value for all hosts.
  • region
    • (required, string) AWS region that the host is running in.
  • instance_id
    • (required, string) AWS instance_id of the host.
  • canary
    • (optional, boolean) Set to true if host is a canary instance, used by Envoy.
  • load_balancing_weight:
    • (optional, integer) Load balancing weight is used by Envoy for weighted routing. Values must be an integer between 1 and 100.

Main Classes

Unit Testing

Note currently it's not working on public repository without tweaking (there is an opened issue for this) To run all unit tests, run make test_unit.

More Repositories

1

cartography

Cartography is a Python tool that consolidates infrastructure assets and the relationships between them in an intuitive graph view powered by a Neo4j database.
Python
2,856
star
2

scissors

✂ Android image cropping library
Java
1,841
star
3

confidant

Confidant: your secret keeper. https://lyft.github.io/confidant
Python
1,781
star
4

clutch

Extensible platform for infrastructure management
Go
1,610
star
5

react-javascript-to-typescript-transform

Convert React JavaScript code to TypeScript with proper typing
TypeScript
1,574
star
6

mapper

A JSON deserialization library for Swift
Swift
1,174
star
7

scoop

🍦 micro framework for building view based modular Android applications.
Java
1,036
star
8

Hammer

iOS touch synthesis library
Swift
642
star
9

protoc-gen-star

protoc plugin library for efficient proto-based code generation
Go
563
star
10

xiblint

A tool for linting storyboard and xib files
Python
522
star
11

flinkk8soperator

Kubernetes operator that provides control plane for managing Apache Flink applications
Go
508
star
12

domic

Reactive Virtual DOM for Android.
Kotlin
482
star
13

metadataproxy

A proxy for AWS's metadata service that gives out scoped IAM credentials from STS
Python
450
star
14

cni-ipvlan-vpc-k8s

AWS VPC Kubernetes CNI driver using IPvlan
Go
357
star
15

nuscenes-devkit

Devkit for the public 2019 Lyft Level 5 AV Dataset (fork of https://github.com/nutonomy/nuscenes-devkit)
Jupyter Notebook
352
star
16

presto-gateway

A load balancer / proxy / gateway for prestodb
JavaScript
337
star
17

toasted-marshmallow

S'More speed for Marshmallow
Python
297
star
18

Kronos-Android

An Open Source Kotlin SNTP library
Kotlin
239
star
19

coloralgorithm

Javacript function to produce color sets
JavaScript
225
star
20

awspricing

Python library for AWS pricing.
Python
201
star
21

linty_fresh

✨ Surface lint errors during code review
Python
183
star
22

universal-async-component

React Universal Async Component that works with server side rendering
TypeScript
180
star
23

swift-index-store

Library to read from Swift / clang source code indexes
C++
123
star
24

python-blessclient

Python client for fetching BLESS certificates
Python
112
star
25

goruntime

Go client for Runtime application level feature flags and configuration
Go
84
star
26

omnibot

One slackbot to rule them all
Python
80
star
27

lyft-android-sdk

Public Lyft SDK for Android
Java
72
star
28

high-entropy-string

A library for classifying strings as potential secrets.
Python
60
star
29

gostats

Go client for Stats
Go
56
star
30

pynamodb-attributes

Common attributes for PynamoDB
Python
52
star
31

bandit-high-entropy-string

A high entropy string plugin for OpenStack's bandit project
Python
48
star
32

Lyft-iOS-sdk

Public Lyft SDK for iOS
Swift
43
star
33

python-kmsauth

A python library for reusing KMS for your own authentication and authorization
Python
38
star
34

opsreview

Compile a report of recent PagerDuty alerts for a single escalation policy.
Python
29
star
35

atlantis

Terraform automation for GitHub PRs (private fork of runatlantis/atlantis)
Go
18
star
36

lyft-node-sdk

Node SDK for the Lyft Public API
JavaScript
16
star
37

fake_sqs

An implementation of a local SQS service.
Ruby
15
star
38

lyft.github.io

This is code for oss.lyft.com website.
TypeScript
14
star
39

dockernetes

Run kubernetes inside a docker container.
Dockerfile
12
star
40

python-confidant-client

Client library and CLI for Confidant
Python
11
star
41

kustomizer

A container for running k8s kustomize
Shell
11
star
42

collectd-statsd

collectd plugin to write to statsd
Python
10
star
43

lyft-web-button

Build an actionable, Lyft-branded button for your website
JavaScript
9
star
44

dynamodb-hive-serde

Hive Deserializer for DynamoDB backup data format
Java
8
star
45

syx

Python 2 and 3 compatibility library from Lyft.
Python
7
star
46

lyft-node-samples

Sample applications using Node.js for the Lyft Public API
JavaScript
7
star
47

android-puzzlers

Android puzzles for Lyft Talks and more.
Java
6
star
48

lyft-go-sdk

Go SDK for the Lyft Public API
Go
6
star
49

lyft-django-sample

An API integration example using Django and social-auth.
Python
5
star
50

python-omnibot-receiver

Library for use by services that receive messages from omnibot.
Python
4
star
51

osscla

Open Source Contributor License Agreement service
Python
4
star
52

code-of-conduct

Code of Conduct for Lyft's open source projects
3
star
53

CLA

Contributor License Agreement (CLA) for Lyft's open source projects
3
star
54

awseipext

AWS Lambda that extends the EC2 Elastic IP API
Python
3
star
55

heroku-buildpack-php

Shell
2
star
56

lyft-go-samples

Sample applications in Go for the Lyft Public API
Go
1
star
57

flask-pystatsd

flask extension to simplify the use of the pystatsd library
Python
1
star
58

eventbot

A slackbot to help organize events
Python
1
star