edgerouter

module
v0.0.0-...-af2531a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2024 License: Apache-2.0

README

⬆️ For table of contents, click the above icon

Build status Docker pulls GoDoc

Easy clustering-native, multi-tenancy aware loadbalancer for Docker services, AWS Lambda functions and S3 static websites.

Architecture drawing

Features

  • Prometheus metrics
  • Clustering-native
    • All state that is required to exist on all loadbalancer nodes come from an event bus (which is durable and has exact-once msg semantics), so each nodes easily reach the same config.
  • Dynamically discovers Docker services (Swarm and standalone containers supported).
    • Kubernetes is not currently supported.
  • Serves as a research platform for new technologies:
    • CertBus integration for always up-to-date TLS.
    • Turbocharger implementation for lightning-fast static file delivery and cacheability.
    • Supports MicroWebApp-style apps (TODO: publish spec) certificates
  • Emulates AWS API Gateway for calling Lambda functions
  • S3 static website support
    • Why use LB in front of S3? Deploys to plain S3 are not atomic. That means users can see broken, in-progress, updates or worse yet - canceled deploy can end up in unknown state. We support atomic deploys on top of S3 with great caching characteristics.
    • This also makes it possible to overlay dynamic stuff "on top of" a static website. Think / mounted to S3 but /api mounted as a Lambda function.
  • Manually defined applications (this hostname should be proxied to this IP..)
  • Authorization support
    • For simple websites like (static websites) or backoffice interactive HTTP services that you don't have control of (likes of Prometheus, Grafana), it's derirable for loadbalancer to enforce backend-wide authentication.
    • For any advanced use, it's of course preferred to do in-app authentication so you can have advanced control of things like different auth for interactive vs. API users etc.
  • Opinionated
    • Not meant to support everyone's use cases. Do the few things we do, really well.

TODO features: look at issues.

Documentation

TODO: more documentation

Application configuration

Edgerouter consumes these EventHorizon streams for realtime updates:

  • /t-1/certbus
    • TLS certificate updates happen here
  • /t-1/loadbalancer
    • Static application definitions are updated here. "Static" doesn't mean the applications don't evolve - it means that they-re semi permanent. The static definition is updated each time a S3 static website is deployed. Lambda definitions rarely change.

Services/containers discovered from Docker are mostly Traefik-notation compliant, so labels like traefik.frontend.rule, traefik.port etc are parsed into an app config. See test cases for supported directives.

"Static" application configs can be published via EventHorizon and all Edgerouter nodes in the cluster will pick up the same changes.

All application configs, whether they're dynamically created from Docker or retrieved via EventHorizon follow this structure:

{
  "id": "example.com",
  "frontends": [
    {
      "kind": "hostname",
      "hostname": "example.com",
      "path_prefix": "/"
    }
  ],
  "backend": {
    "kind": "s3_static_website",
    "s3_static_website_opts": {
      "bucket_name": "mycompany-staticwebsites",
      "region_id": "eu-central-1",
      "deployed_version": "v1"
    }
  }
}

An application always has an ID, at least one frontend (= hostname or hostname pattern), and a single backend (one backend can have multiple replicas for loadbalancing/high availability though).

Here's an example of a Docker-discovered service with 2 replicas (remember, this config is autogenerated):

{
  "id": "app.example.com",
  "frontends": [
    {
      "kind": "hostname",
      "hostname": "app.example.com",
      "path_prefix": "/"
    }
  ],
  "backend": {
    "kind": "peer_set",
    "peer_set_opts": {
      "addrs": [
        "http://192.168.1.2"
        "http://192.168.1.3"
      ]
    }
  }
}

Directories

Path Synopsis
cmd
edgerouter
Main entrypoint for all things Edgerouter
Main entrypoint for all things Edgerouter
pkg
erbackend/authssobackend
function61 Single Sign-On authentication (github.com/function61/id)
function61 Single Sign-On authentication (github.com/function61/id)
erbackend/authv0backend
Static bearer token (+ basic auth) -based authentication
Static bearer token (+ basic auth) -based authentication
erbackend/edgerouteradminbackend
Admin panel for Edgerouter
Admin panel for Edgerouter
erbackend/lambdabackend
Calls Lambda function with HTTP semantics (impersonates API Gateway)
Calls Lambda function with HTTP semantics (impersonates API Gateway)
erbackend/redirectbackend
Redirects to somewhere else
Redirects to somewhere else
erbackend/reverseproxybackend
Reverse proxies traffic to a set of origins.
Reverse proxies traffic to a set of origins.
erbackend/statics3websitebackend
Serves an atomically deployed website from S3.
Serves an atomically deployed website from S3.
erbackend/turbochargerbackend
An entire static website directly hosted in Turbocharger.
An entire static website directly hosted in Turbocharger.
erbackend/turbochargerbackend/turbochargererdeploy
Deploys Turbocharger static site to Edgerouter
Deploys Turbocharger static site to Edgerouter
erconfig
Application configuration data structures
Application configuration data structures
erdiscovery
Application discovery - finding backends and frotends to route traffic to
Application discovery - finding backends and frotends to route traffic to
erdiscovery/defaultdiscovery
"Meta" package - builds instance of the default discovery.
"Meta" package - builds instance of the default discovery.
erdiscovery/dockerdiscovery
Discovers applications from Docker and/or Docker Swarm cluster
Discovers applications from Docker and/or Docker Swarm cluster
erdiscovery/ehdiscovery
EventHorizon-based discovery
EventHorizon-based discovery
erdiscovery/s3discovery
Discover application from S3 bucket (EventHorizon-based discovery is highly recommended instead)
Discover application from S3 bucket (EventHorizon-based discovery is highly recommended instead)
erdomain
Structure of data for all state changes
Structure of data for all state changes
erlambdacli
CLI for managing Lambda application backends
CLI for managing Lambda application backends
ers3cli
CLI for managing static websites in S3
CLI for managing static websites in S3
erserver
Actual server implementation of Edgerouter
Actual server implementation of Edgerouter
erservercli
Embeddable CLI for Edgerouter server library.
Embeddable CLI for Edgerouter server library.
syncutil
TODO: move to gokit
TODO: move to gokit
turbocharger/turbochargerapp
Code required to bring turbocharger support to concrete applications
Code required to bring turbocharger support to concrete applications

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL