Skip to content

Latest commit

 

History

History
 
 

README.md

Data plane

Rust-powered message forwarder for inter-process communication.

Build

Local binary

Set the build profile you prefer. Available options:

  • debug
  • release
PROFILE=release
# PROFILE=debug

task data-plane:build PROFILE=${PROFILE}

This will build a local binary of SLIM.

Container image

To run a multiarch image of SLIM (linux/arm64 & linux/amd64):

REPO_ROOT="$(git rev-parse --show-toplevel)"
docker build -t slim -f "${REPO_ROOT}/data-plane/Dockerfile" --platform linux/amd64,linux/arm64 "${REPO_ROOT}"

Or alternatively, with docker buildx bake:

pushd $(git rev-parse --show-toplevel) && IMAGE_REPO=slim IMAGE_TAG=latest docker buildx bake slim && popd

Container Image on Windows

The container image build process was tested on:

  • Windows 10 + Hyper-V
  • windows 11 + WSL 2

The instructions below assume Powershell 7 environment.

Set environment variable

$env:REPO_ROOT = "<path-to-repo>"

Example:

$env:REPO_ROOT = "C:\Users\<dummy>\slim"

Convert Line endings

To convert line endings in VSCode from CRLF (Windows-style) to LF (Unix-style), follow these steps:

  1. Open the Dockerfile (or any file you want to convert) in VSCode.
  2. Look at the bottom-right corner of the VSCode window.
  3. You should see something like CRLF (Carriage Return + Line Feed).
  4. Click on CRLF, and a small menu will appear.
  5. Select LF (Line Feed) from the menu.
  6. Save the file (Ctrl + S or Cmd + S on Mac).

Build Container

Notice that there is no arm64 on the command below, otherwise it will fail even if using buildx.

docker buildx build `
    -t slim `
    -f "$env:REPO_ROOT\data-plane\Dockerfile" `
    --platform linux/amd64 `
    "$env:REPO_ROOT"

If everything goes well you should see an output similar to:

...
 => => naming to docker.io/library/slim:latest                                                             0.0s
 => => unpacking to docker.io/library/slim:latest

Run SLIM

SLIM can be run in 2 main ways:

  • directly as binary (preferred way when deployed as workload in k8s)
  • via the bindings APIs

SLIM can run in server mode, in client mode or both (i.e. spawning a server and connecting to another SLIM instance at the same time).

Server

To run SLIM binary as server, a configuration file is needed to setup the basic runtime options. Some basic examples are provided in the config folder:

  • reference is a reference configuration, with comments explaining all the available options.
  • base is a base configuration for a server without encryption and authentication.
  • tls is a configuration for a server with encryption enabled, with no authentication.
  • basic-auth is a configuration for a server with encryption and basic auth enabled.
  • mtls is a configuration for a server expecting clients to authenticate with a trusted certificate.

To run SLIM as server:

MODE=base
# MODE=tls
# MODE=basic-auth; export PASSWORD=12345  # Unix/Linux/macOS
# MODE=basic-auth; $env:PASSWORD = "12345"  # Windows PowerShell
# MODE=mtls

cargo run --bin slim -- --config ./config/${MODE}/server-config.yaml

Or, using the container image (assuming the image name is slim):

docker run -it \
    -e PASSWORD=${PASSWORD} \
    -v ./config/base/server-config.yaml:/config.yaml \
    slim /slim --config /config.yaml

Client

To run the SLIM binary as client, you will need to configure it to start one (or more) clients at startup, and you will need to provide the address of a remote SLIM server. As usually, some configuration examples are available in the config folder:

  • reference is a reference configuration, with comments explaining all the available options.
  • base is a base configuration for a client without encryption and authentication.
  • tls is a configuration for a client with encryption enabled, with no authentication.
  • basic-auth is a configuration for a client with encryption and basic auth enabled.
  • mtls is a configuration for a client connecting to a server with a trusted certificate.

To run SLIM as client:

MODE=base
# MODE=tls
# MODE=basic-auth; export PASSWORD=12345  # Unix/Linux/macOS
# MODE=basic-auth; $env:PASSWORD = "12345"  # Windows PowerShell
# MODE=mtls

cargo run --bin slim -- --config ./config/${MODE}/client-config.yaml

Or, using the container image (assuming the image name is slim):

docker run -it \
    -e PASSWORD=${PASSWORD} \
    -v ./config/base/client-config.yaml:/config.yaml \
    slim /slim --config /config.yaml

Testing

Run Tests

Run the core Rust tests:

task data-plane:test

Linting

Run the linter for Rust code:

task data-plane:lint

This will run linting on both the Rust workspace and language bindings.