• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created about 10 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

a distributed HTTP and websocket proxy inspired by Hipache

PlanB: a distributed HTTP and websocket proxy

Build Status

What Is It?

PlanB is a HTTP and websocket proxy backed by Redis and inspired by Hipache.

It aims to be fully compatible with Hipache when Redis is used as a backend. The same format is used for all keys stored in Redis so migrating from Hipache to PlanB should be completely seamless. The process should be as simple as replacing Hipache's executable for PlanB.

Start-up flags

The following flags are available for configuring PlanB on start-up:

  • --listen value, -l value: Address to listen (default: "0.0.0.0:8989")
  • --tls-listen value: Address to listen with tls
  • --tls-preset value: Preset containing supported TLS versions and cyphers, according to https://wiki.mozilla.org/Security/Server_Side_TLS. Possible values are [modern, intermediate, old] (default: "modern")
  • --metrics-address value: Address to expose prometheus /metrics
  • --load-certificates-from value: Path where certificate will found. If value equals 'redis' certificate will be loaded from redis service. (default: "redis")
  • --read-redis-network value: Redis address network, possible values are "tcp" for tcp connection and "unix" for connecting using unix sockets (default: "tcp")
  • --read-redis-host value: Redis host address for tcp connections or socket path for unix sockets (default: "127.0.0.1")
  • --read-redis-port value: Redis port (default: 6379)
  • --read-redis-sentinel-addrs value: Comma separated list of redis sentinel addresses
  • --read-redis-sentinel-name value: Redis sentinel name
  • --read-redis-password value: Redis password
  • --read-redis-db value: Redis database number (default: 0)
  • --write-redis-network value: Redis address network, possible values are "tcp" for tcp connection and "unix" for connecting using unix sockets (default: "tcp")
  • --write-redis-host value: Redis host address for tcp connections or socket path for unix sockets (default: "127.0.0.1")
  • --write-redis-port value: Redis port (default: 6379)
  • --write-redis-sentinel-addrs value: Comma separated list of redis sentinel addresses
  • --write-redis-sentinel-name value: Redis sentinel name
  • --write-redis-password value: Redis password
  • --write-redis-db value: Redis database number (default: 0)
  • --access-log value: File path where access log will be written. If value equals 'syslog' log will be sent to local syslog. The value 'none' can be used to disable access logs. (default: "./access.log")
  • --request-timeout value: Total backend request timeout in seconds (default: 30)
  • --dial-timeout value: Dial backend request timeout in seconds (default: 10)
  • --client-read-timeout value: Maximum duration for reading the entire request, including the body (default: 0s)
  • --client-read-header-timeout value: Amount of time allowed to read request headers (default: 0s)
  • --client-write-timeout value: Maximum duration before timing out writes of the response (default: 0s)
  • --client-idle-timeout value: Maximum amount of time to wait for the next request when keep-alives are enabled (default: 0s)
  • --dead-backend-time value: Time in seconds a backend will remain disabled after a network failure (default: 30)
  • --flush-interval value: Time in milliseconds to flush the proxied request (default: 10)
  • --request-id-header value: Header to enable message tracking
  • --active-healthcheck: Enable active healthcheck on dead backends once they are marked as dead. Enabling this flag will result in dead backends only being enabled again once the active healthcheck routine is able to reach them.
  • --engine value: Reverse proxy engine, options are 'native', 'sni' and 'fasthttp'. Using 'sni' and 'fasthttp' is highly experimental and not recommended for production environments. (default: "native")
  • --backend-cache: Enable caching backend results for 2 seconds. This may cause temporary inconsistencies.
  • --help, -h: show help
  • --version, -v: print the version

The --read-redis-* flags refer to the Redis server used for read-only operations (reading the backends for each frontend).

The --write-redis-* flags refer to the Redis server used for write operations (marking and publishing dead backends).

Separating the read and write servers is not mandatory but is useful for improving performance. A common scenario is having a slave Redis server on localhost configured as --read-redis and a remote Redis master configured as --write-redis.

Features

  • Load-Balancing
  • Dead Backend Detection
  • Dynamic Configuration
  • WebSocket
  • TLS

Install

The easiest way to install PlanB is to pull the trusted build from the hub.docker.com and launch it in the container:

# run Redis
docker run -d -p 6379:6379 redis

# run PlanB
docker run -d --net=host tsuru/planb:v1 --listen ":80"

VHOST Configuration

The configuration is managed by Redis that makes possible to update the configuration dynamically and gracefully while the server is running, and have that state shared across workers and even across instances.

Let's take an example to proxify requests to 2 backends for the hostname www.tsuru.io. The 2 backends IP are 192.168.0.42 and 192.168.0.43 and they serve the HTTP traffic on the port 80.

redis-cli is the standard client tool to talk to Redis from the terminal.

Follow these steps:

Create the frontend:

$ redis-cli rpush frontend:www.tsuru.io mywebsite
(integer) 1

The frontend identifer is mywebsite, it could be anything.

Add the 2 backends:

$ redis-cli rpush frontend:www.tsuru.io http://192.168.0.42:80
(integer) 2
$ redis-cli rpush frontend:www.tsuru.io http://192.168.0.43:80
(integer) 3

Review the configuration:

$ redis-cli lrange frontend:www.tsuru.io 0 -1
1) "mywebsite"
2) "http://192.168.0.42:80"
3) "http://192.168.0.43:80"

TLS Configuration using redis (optional)

$ redis-cli -x hmset tls:www.tsuru.io certificate < server.crt
$ redis-cli -x hmset tls:www.tsuru.io key < server.key

$ redis-cli -x hmset tls:*.tsuru.com certificate < wildcard.crt
$ redis-cli -x hmset tls:*.tsuru.io key < wildcard.key

TLS Configuration using FS (optional)

create directory following this structure

cd certficates
ls
*.domain-wildcard.com.key
*.domain-wildcard.com.crt
absolute-domain.key
absolute-domain.crt

While the server is running, any of these steps can be re-run without messing up with the traffic.

Debbugging and Troubleshooting

One way to debug/toubleshoot planb is by analyzing the running goroutines.

Planb is able to handle the USR1 signal to dump goroutines in its execution screen:

$ kill -s USR1 <planb-PID>

Links

More Repositories

1

tsuru

Open source and extensible Platform as a Service (PaaS).
Go
4,782
star
2

gandalf

Gandalf is an HTTP API for managing Git repositories.
Go
268
star
3

docker-cluster

Go library for clustering support on Docker.
Go
249
star
4

tsuru-dashboard

Web dashboard for tsuru PaaS.
Python
142
star
5

docker-nginx-with-modules

Build nginx docker image image with custom modules
Dockerfile
106
star
6

tsuru-client

tsuru-client is a tsuru command line tool for application developers.
Go
94
star
7

now

Yet another script to install Tsuru and its dependencies.
Shell
91
star
8

tsuru-bootstrap

bootstraping tsuru with vagrant
Shell
87
star
9

platforms

Official platforms for the tsuru PaaS.
Shell
75
star
10

tsuru.io

Tsuru PaaS website.
SCSS
46
star
11

config

Go package for dealing with YAML configuration files.
Go
45
star
12

rpaas

Reverse proxy as a service.
Python
40
star
13

basebuilder

Testing infrastructure for the tsuru PaaS platforms
Shell
40
star
14

rpaas-operator

RPaaS operator manages reverse proxy as service instances inside a Kubernetes cluster
Go
34
star
15

tsuru-django-sample

Sample Django application for tsuru.
Python
33
star
16

pantera

Pantera is a tool to test the resilience of cloud applications.
Python
33
star
17

tsuru-deb

Source for all tsuru PPAs.
Roff
33
star
18

tsuru-autoscale

auto scale as a service
Go
32
star
19

healthcheck-as-a-service

tsuru service API for on demand web application monitoring.
Python
31
star
20

nginx-operator

Nginx Operator manages nginx instances inside a Kubernetes cluster.
Go
29
star
21

terraform-provider-tsuru

Terraform provider for tsuru
Go
20
star
22

kubernetes-router

Tsuru router API implementation that manages k8s loadbalancers/ingress
Go
20
star
23

monsterqueue

A Go (golang) library for enqueuing and processing tasks backed by MongoDB
Go
18
star
24

postgres-api

A PostgreSQL API for tsuru PaaS
Python
17
star
25

archive-server

HTTP server to generate and serve git archives.
Go
17
star
26

commandmocker

Go mock framework for executables in the command line.
Go
14
star
27

mysqlapi

MySQL service API for tsuru PaaS.
Python
14
star
28

redisapi

Redis service API for tsuru PaaS.
Python
13
star
29

prometheus-conntrack

Expose conntrack metrics to prometheus
Go
13
star
30

custom-cloudstack-ccm

A customizable cloudstack cloud controller manager for kubernetes
Go
13
star
31

puppet-tsuru

Tsuru Puppet Module
Ruby
12
star
32

deploy-agent

Agent responsible for running deployment in application containers.
Go
11
star
33

prometheus-as-a-service

Prometheus as a service repo
Python
11
star
34

mongoapi

MongoDB service API for tsuru.
Go
11
star
35

diaats

Docker image as a tsuru service.
Go
11
star
36

tsuru-admin

[DEPRECATED] tsuru-admin commands were moved to tsuru client
Go
11
star
37

bs

Big siblings watch their siblings and report to big tsuru parent.
Go
10
star
38

dockerized-setup

dockerized setup for tsuru deployment
Shell
10
star
39

eviaas

environment variables injector as a service
Python
9
star
40

tsuru-autoscale-dashboard

Python
9
star
41

homebrew-tsuru

Homebrew taps for tsuru clients (tsuru, crane and tsuru-admin).
Ruby
9
star
42

remesher

Kubernetes controller to manage custom node to node bgp calico mesh
Go
9
star
43

tsuru-installer

[DEPRECATED] this project has moved
Go
9
star
44

crane

[DEPRECATED] crane commands were moved to tsuru client
Go
9
star
45

go-tsuruclient

Tsuru go client generated from the swagger spec
Go
8
star
46

admtools

A tsuru plugin with some hacks to help debug containers, nodes, services, etc
Shell
8
star
47

rabbitmqapi

RabbitMQ service API for tsuru PaaS
Python
7
star
48

base-platform

Common base Docker image for tsuru platforms.
Shell
7
star
49

python-tsuruclient

Python client library for tsuru API
Python
7
star
50

varnishapi

Varnish service API for tsuru PaaS.
Python
6
star
51

tsuru-circus

circus extensions for tsuru PaaS.
Python
6
star
52

hm

host manager python library for making it easier to create new services
Python
6
star
53

go-gandalfclient

Gandalf client for Go
Go
6
star
54

try

subscription page for the try.tsuru.io
Python
6
star
55

push-to-docker

Bash script to push versioned images to docker hub
Shell
6
star
56

hostcert

Add root CAs to docker nodes
Shell
6
star
57

riakapi

Riak api Tsuru service
Go
6
star
58

pool-recycle

Tsuru plugin for recycle all nodes on a pool based on IaaS templates
Python
5
star
59

caffeine

a simple router responsible to wake up sleeping units
Go
5
star
60

tsuru-unit-agent

[DEPRECATED] Agent responsible for managing the processes in tsuru units.
Python
5
star
61

gnuflag

Mirror of launchpad.net/gnuflag
Go
5
star
62

tsuru-ruby-sample

Ruby
4
star
63

tsuru-java-sample

Sample Java application for tsuru.
Java
4
star
64

cst

A middleware for intermediate container security scans against many security engines.
Go
4
star
65

charts

Tsuru Helm Charts and Repository
Smarty
4
star
66

cadvisor-events-exporter

Prometheus exporter for cadvisor events API
Go
4
star
67

docs

Release repository for tsuru documentation
Dockerfile
4
star
68

tsuru-integration-tests

integration tests for tsuru
Python
3
star
69

morfeu

a worker responsible to put units without access "to sleep"
Python
3
star
70

fakeapi

Fake service API for tsuru.
Python
3
star
71

alpine-platforms

Shell
3
star
72

healthcheck-exporter

healthcheck as a service prometheus exporter
Go
3
star
73

networkapi-ingress-controller

Go
3
star
74

tsuru-service-cassandra

Cassandra service API for tsuru PaaS.
Python
3
star
75

tsuru-api-docs

a tool to extract docs from handler comments
Go
3
star
76

tsuru-cloudformation

[DEPRECATED] Tsuru AWS Cloud Formation
Ruby
3
star
77

integration_gce

Tsuru integration tests on Google Compute Engine
Shell
3
star
78

alpine-base-platform

Common base Docker image for tsuru platforms
Shell
3
star
79

prometheus-cloudstack-discovery

CloudStack service discovery for Prometheus
Go
3
star
80

tsuru-packer

packer template to create basic tsuru image.
Shell
2
star
81

tsuru.github.io

Tsuru blog | Open Source cloud application platform
CSS
2
star
82

integration_ec2

Integration tests on AWS EC2
Shell
2
star
83

tsuru-dashboard-tests

end to end tests for tsuru-dashboard
Python
2
star
84

tsuru-team-metrics

Go
2
star
85

pythonbr-example

Código para demonstração de deploy para a Python Brasil 2022
Python
2
star
86

tsuru-usage

Resource usage exporter for tsuru
Go
2
star
87

tsuru-prometheus-api

Simple API to manage multiple prometheus configs across many tsuru clusters
Go
2
star
88

tablecli

CLI library for rendering responsive tables
Go
2
star
89

ngx-location-name-module

A module to expose the matched location name as a variable
C
2
star
90

bs-base

Base image for bs.
1
star
91

tsuru-sphinx

Sphinx extensions used by tsuru documentation
Python
1
star
92

rpaas-slo-controller

Integrate slo-generator with rpaasinstances
Go
1
star
93

terraform-provider-hcaas

Terraform provider for healthcheck as a service
Go
1
star
94

custom-node-local-dns

Custom build of k8s.io/dns node-cache image
Shell
1
star
95

go-globodnsclient

Go client for GloboDNS
Go
1
star
96

terraform-provider-rpaas

Terraform Provider for RPaaS
Go
1
star
97

acl-operator

Control network access in high abstractions by Tsuru Applications
Go
1
star
98

acl-api

API that stores rules of network to be consumed by acl-operator
Go
1
star
99

push-to-packagecloud

Basic script to create packages and push them to Package Cloud
Shell
1
star
100

globomap-integration

Tsuru integration with globomap
Go
1
star