xlb-poc

command module
v0.0.0-...-ea7e872 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

XLB Proof of concept

Proof of concept for load-balancer implementation

Requirements

General

Implement a basic TCP load balancer. Load balancers are used to distribute network load across multiple hosts (or upstreams).

Technical
  • A reusable library implementing the functionality of the load balancer.
  • A server that exposes the library functionality while providing secure communication to clients and an authorization layer.

Goals

Assemble full prototype of required components to route authenticated LB pass-through traffic

This project should serve as a base source of connected components for the XLB project.

Scopes
  • Only forwarding balancer method in this POC is Round-Robin strategy
  • Unit testing limited for POC, only available for Round-Robin validation
  • Database layer implemented with Badger to optimize testing of behaviors between optimizations
  • Certificate keys limited to RSA to reduce the research time

Prerequisites

General TLS
make tls
Client TLS

Can be achieved by series of commands (imitation of real customer)

Create Client with ID
curl -k --location 'https://localhost:8083/api/v1/client' \
--header 'Content-Type: application/json' \
--data '{"name": "testuser"}' | jq

{
  "uuid": "adcfce79-7048-48ac-a55e-269f3745e6f0",
  "key": "dc9bea78b73818aead83bea41d362b84b230a61cc21c8b342112f0176ac78e25",
  "name": "testuser",
  "createdAt": {
    "seconds": 1712087318,
    "nanos": 563993000
  }
}
Create Client Key
curl -k --location --request POST 'https://localhost:8083/api/v1/client/auth' \
--header 'Authorization: Basic YWRjZmNlNzktNzA0OC00OGFjLWE1NWUtMjY5ZjM3NDVlNmYwOmRjOWJlYTc4YjczODE4YWVhZDgzYmVhNDFkMzYyYjg0YjIzMGE2MWNjMjFjOGIzNDIxMTJmMDE3NmFjNzhlMjU='
| jq

{
  "Token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjM2MDAsImZvbyI6MiwiaXNzIjoieGxiLWF1dGhvcml0eSIsInN1YiI6ImFkY2ZjZTc5LTcwNDgtNDhhY.fvXV8zrQS_WjxBaH6HVv-5QwnkKmyfw-05N5wlXEhfuMOLCePBaY6eyxY7tibdVY1b3nEuy_zm6SyLrqu-mSbnjyQl4mBCVUgxmnpR5XWuZCPIddpR4NCJuhxm8YMDPFiVaTUC-kGEVYC--vUQ9_4FenRJ31sq-GpYage5muxI1ZGLH-FwCuwzVgnHEkDHJ01oAOaE9G2tc2lVbjDd3OO-TgjeuIHkRjC7wZ2C5w82PbVf8IZOQnEjgvTJba5MkWt8HfYsplYqtsvMhAmKRvfJ67W24aTNel4y6X0VuL2Gsfd6JItKIzyMil_-hvAPR6QmItYa_v9dwoLu42b5OBE1JvQkEPKe9Z8gwP8NhApQ5UFbaoeYBYnGtT-lSlnNrgHXq3LMemv2ELg6coIIEdw_4sobbtQHVg8BnwUwlWKn22yjiiL-qRQqzYzMGk6Z0kGQ9trI-ON3yxTe1BNqj1eDrsc0eu4EpNivqh3tAM8J1LK4PdqCRmxABRYSpJumpm"
}
Create Frontend For the applicaiton
curl -k --location 'https://localhost:8083/api/v1/client/frontend' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTIwOTM3MDAsImZvbyI6MiwiaXNzIjoieGxiLWF1dGhvcml0eSIsInN1YiI6ImFkY2ZjZTc5LTcwNDgtNDhh.PRepRH8pwzlP0gGP9LJuw5Sw_FrKTuCfuGZiwVNnVdCYhJ6i7jFfWLThNqKEX4A3chBXkj90W3eucCj_SrdGDbdGEPnX9lKKLuaTWcLPIDODTFAZManVFj7Fma-xDbYEBrUvZ4EGnvJpz8WKE_2fqE_doJ7nXWHR3Vmh9MPKCw4zcsUvxB5yRMqLnVC4ZrP28Jbj0Nou4L2m_Oh_8qFMXJWXXsoanFFhpwxqyHcR1eAUaQ5vw5z3USEVid86a6oNCLDy_AlBKoyvaXP0m0hSc27qoktMOl3WN5HMGpDrz_U0S8QXjJl6c_Dak0TLhto-x9CF21Ku5kKofE92KD1u_J6IvKOcXDctATlXs-OjOlgyOCd5k6X-i57AgQ5vEpKU4MB_Kv8eAGAAtdHfDftAxWt1eEe5dCsCgZU7sO_m8tDnLwRS1c-OF89Hh9M5b-oAjSlPE0fOwvU118wjqIchjwbKrfw_VNjyVnQfyDQnfANZ6hsPddVO11iyDvlts361' \
--data '{
    "active": true,
    "strategy": 0,
    "routeTimeoutSec": 30,
    "routes": [
        {
            "dest": "142.250.189.174:80",
            "capacity": 10
        }
    ]
}'

{
    "uuid": "1a916327-b70e-423d-8ff6-664dc4d98cde",
    "active": true,
    "routeTimeoutSec": 30,
    "clientId": "adcfce79-7048-48ac-a55e-269f3745e6f0",
    "accessKey": "1074dfb781ecc4917ff6fc714db3b92607498fe648b033427a2605d12be8356a",
    "routes": [
        {
            "dest": "142.250.189.174:80",
            "capacity": 10
        }
    ]
}
Create Client Access Keys
curl -k --location 'https://localhost:8083/api/v1/client/frontend/1a916327-b70e-423d-8ff6-664dc4d98cde/tls' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTIwOTM3MDAsImZvbyI6MiwiaXNzIjoieGxiLWF1dGhvcml0eSIsInN1YiI6ImFkY2ZjZTc5LTcwNDgtND.PRepRH8pwzlP0gGP9LJuw5Sw_FrKTuCfuGZiwVNnVdCYhJ6i7jFfWLThNqKEX4A3chBXkj90W3eucCj_SrdGDbdGEPnX9lKKLuaTWcLPIDODTFAZManVFj7Fma-xDbYEBrUvZ4EGnvJpz8WKE_2fqE_doJ7nXWHR3Vmh9MPKCw4zcsUvxB5yRMqLnVC4ZrP28Jbj0Nou4L2m_Oh_8qFMXJWXXsoanFFhpwxqyHcR1eAUaQ5vw5z3USEVid86a6oNCLDy_AlBKoyvaXP0m0hSc27qoktMOl3WN5HMGpDrz_U0S8QXjJl6c_Dak0TLhto-x9CF21Ku5kKofE92KD1u_J6IvKOcXDctATlXs-OjOlgyOCd5k6X-i57AgQ5vEpKU4MB_Kv8eAGAAtdHfDftAxWt1eEe5dCsCgZU7sO_m8tDnLwRS1c-OF89Hh9M5b-oAjSlPE0fOwvU118w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klDQVRFLS0tLS0K"
}
Add Credentials to the test client

Testing Client Path As:

  • cert.pem
  • key.pem
Launch server and client

Server

go run main.go

Client

cd testing/balancer-client
go run client.go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
testing

Jump to

Keyboard shortcuts

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