drivers

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package drivers implements common interfaces and utilities for Apoxy service drivers

Index

Constants

View Source
const (
	// APIServerStdoutLogFile is the name of the apiserver stdout log file
	APIServerStdoutLogFile = "apiserver.stdout.log"
	// APIServerStderrLogFile is the name of the apiserver stderr log file
	APIServerStderrLogFile = "apiserver.stderr.log"
	// APIServerProcessName is used to identify the apiserver process
	APIServerProcessName = "apiserver"
)
View Source
const (
	// DefaultLogsDir is the default directory for logs
	DefaultLogsDir = "/var/log/apoxy"
	// BackplaneStdoutLogFile is the name of the backplane stdout log file
	BackplaneStdoutLogFile = "backplane.stdout.log"
	// BackplaneStderrLogFile is the name of the backplane stderr log file
	BackplaneStderrLogFile = "backplane.stderr.log"
	// BackplaneProcessName is used to identify the backplane process
	BackplaneProcessName = "backplane"
)
View Source
const (
	// BackplaneService represents the backplane service.
	BackplaneService ServiceType = "backplane"
	// APIServerService represents the apiserver service.
	APIServerService ServiceType = "apiserver"
	// TunnelProxyService represents the tunnel proxy service.
	TunnelProxyService ServiceType = "tunnelproxy"
	// WorkerdManagerService represents the workerd-manager service (APO-796): the
	// privileged/runsc data-plane sidecar that runs the shared resident workerd.
	WorkerdManagerService ServiceType = "workerd-manager"

	// DockerMode represents the docker driver mode.
	DockerMode DriverMode = "docker"
	// SupervisorMode represents the supervisor driver mode.
	SupervisorMode DriverMode = "supervisor"
)
View Source
const (
	// DefaultTunnelProxyLogsDir is the default directory for logs
	DefaultTunnelProxyLogsDir = "/var/log/apoxy"
	// TunnelProxyStdoutLogFile is the name of the tunnelproxy stdout log file
	TunnelProxyStdoutLogFile = "tunnelproxy.stdout.log"
	// TunnelProxyStderrLogFile is the name of the tunnelproxy stderr log file
	TunnelProxyStderrLogFile = "tunnelproxy.stderr.log"
	// TunnelProxyProcessName is used to identify the tunnelproxy process
	TunnelProxyProcessName = "tunnelproxy"
)

Variables

This section is empty.

Functions

func ForwardTCP

func ForwardTCP(
	stopCh <-chan struct{},
	cname string,
	localPort, remotePort int,
) error

ForwardTCP forwards localPort on host to a remotePort on a container cname.

func WithLogsDir

func WithLogsDir(logsDir string) func(*BackplaneSupervisorDriver)

WithLogsDir sets the logs directory for the supervisor driver.

func WithTunnelProxyLogsDir

func WithTunnelProxyLogsDir(logsDir string) func(*TunnelProxySupervisorDriver)

WithTunnelProxyLogsDir sets the logs directory for the supervisor driver.

Types

type APIServerDockerDriver

type APIServerDockerDriver struct {
	// contains filtered or unexported fields
}

APIServerDockerDriver implements the Driver interface for Docker.

func NewAPIServerDockerDriver

func NewAPIServerDockerDriver() *APIServerDockerDriver

NewAPIServerDockerDriver creates a new Docker driver for apiserver.

func (*APIServerDockerDriver) GetAddr

func (d *APIServerDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*APIServerDockerDriver) ImageRef

func (db *APIServerDockerDriver) ImageRef(repo string) string

func (*APIServerDockerDriver) Init

func (db *APIServerDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*APIServerDockerDriver) PullPolicy

func (db *APIServerDockerDriver) PullPolicy() string

func (*APIServerDockerDriver) Start

func (d *APIServerDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	serviceName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*APIServerDockerDriver) Stop

func (d *APIServerDockerDriver) Stop(orgID uuid.UUID, serviceName string)

Stop implements the Driver interface.

type APIServerSupervisorDriver

type APIServerSupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

APIServerSupervisorDriver implements the Driver interface for process supervision.

func NewAPIServerSupervisorDriver

func NewAPIServerSupervisorDriver() *APIServerSupervisorDriver

NewAPIServerSupervisorDriver creates a new Supervisor driver with default configuration.

func (*APIServerSupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*APIServerSupervisorDriver) Start

func (d *APIServerSupervisorDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	serviceName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*APIServerSupervisorDriver) Stop

func (d *APIServerSupervisorDriver) Stop(orgID uuid.UUID, serviceName string)

Stop implements the Driver interface.

type BackplaneDockerDriver

type BackplaneDockerDriver struct {
	// contains filtered or unexported fields
}

BackplaneDockerDriver implements the Driver interface for Docker.

func NewBackplaneDockerDriver

func NewBackplaneDockerDriver() *BackplaneDockerDriver

NewBackplaneDockerDriver creates a new Docker driver for backplane.

func (*BackplaneDockerDriver) GetAddr

func (d *BackplaneDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*BackplaneDockerDriver) ImageRef

func (db *BackplaneDockerDriver) ImageRef(repo string) string

func (*BackplaneDockerDriver) Init

func (db *BackplaneDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*BackplaneDockerDriver) PullPolicy

func (db *BackplaneDockerDriver) PullPolicy() string

func (*BackplaneDockerDriver) Start

func (d *BackplaneDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*BackplaneDockerDriver) Stop

func (d *BackplaneDockerDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type BackplaneSupervisorDriver

type BackplaneSupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

BackplaneSupervisorDriver implements the Driver interface for process supervision.

func NewBackplaneSupervisorDriver

func NewBackplaneSupervisorDriver() *BackplaneSupervisorDriver

NewBackplaneSupervisorDriver creates a new Supervisor driver with default configuration.

func (*BackplaneSupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*BackplaneSupervisorDriver) Start

func (d *BackplaneSupervisorDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*BackplaneSupervisorDriver) Stop

func (d *BackplaneSupervisorDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type Driver

type Driver interface {
	// Start deploys and starts the service.
	Start(ctx context.Context, orgID uuid.UUID, serviceName string, opts ...Option) (string, error)
	// Stop stops the service.
	Stop(orgID uuid.UUID, serviceName string)
	// GetAddr returns the address of the service.
	GetAddr(ctx context.Context) (string, error)
}

Driver is the interface that all service drivers must implement.

func GetAPIServerDriver

func GetAPIServerDriver(driver DriverMode) (Driver, error)

GetAPIServerDriver returns an apiserver driver by name.

func GetBackplaneDriver

func GetBackplaneDriver(driver DriverMode) (Driver, error)

GetBackplaneDriver returns a backplane driver by name.

func GetDriver

func GetDriver(driverType DriverMode, serviceType ServiceType) (Driver, error)

GetDriver returns a driver by name for the specified service type.

func GetTunnelProxyDriver

func GetTunnelProxyDriver(driver DriverMode) (Driver, error)

GetTunnelProxyDriver returns a tunnel proxy driver by name.

func GetWorkerdManagerDriver

func GetWorkerdManagerDriver(driver DriverMode) (Driver, error)

GetWorkerdManagerDriver returns a workerd-manager driver by mode. Only DockerMode is supported: the manager needs a privileged gVisor-capable container, which the subprocess/supervisor path cannot provide.

type DriverMode

type DriverMode string

DriverMode represents the mode in which the driver is running.

type Option

type Option func(*Options)

Option is a function that configures driver options.

func WithAPIServerAddr

func WithAPIServerAddr(addr string) Option

WithAPIServerAddr sets the apiserver address.

func WithArgs

func WithArgs(args ...string) Option

WithArgs sets the arguments for the driver.

func WithNetworkContainer

func WithNetworkContainer(name string) Option

WithNetworkContainer joins another container's network namespace.

func WithWorkerdSocketVolume

func WithWorkerdSocketVolume(name string) Option

WithWorkerdSocketVolume mounts the shared resident-socket volume.

type Options

type Options struct {
	Args          []string
	APIServerAddr string
	// NetworkContainer, when set, joins the container's network namespace
	// (`docker run --network container:<name>`) instead of the apoxy bridge. The
	// workerd-manager uses this to share the co-located BACKPLANE's netns (1:1
	// backplane↔resident coupling); it reaches the apiserver (kube-API + the
	// routing publish channel) over the docker network by name.
	NetworkContainer string
	// WorkerdSocketVolume, when set, is a Docker volume mounted at
	// /run/workerd-manager in both the backplane and the workerd-manager, so the
	// backplane's Envoy can dial the resident workerd's host UDS the manager
	// surfaces there.
	WorkerdSocketVolume string
}

Options contains common options for all drivers.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns the default options.

type ServiceType

type ServiceType string

ServiceType represents the type of service being managed by a driver.

type TunnelProxyDockerDriver

type TunnelProxyDockerDriver struct {
	// contains filtered or unexported fields
}

TunnelProxyDockerDriver implements the Driver interface for Docker.

func NewTunnelProxyDockerDriver

func NewTunnelProxyDockerDriver() *TunnelProxyDockerDriver

NewTunnelProxyDockerDriver creates a new Docker driver for tunnelproxy.

func (*TunnelProxyDockerDriver) GetAddr

func (d *TunnelProxyDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*TunnelProxyDockerDriver) ImageRef

func (db *TunnelProxyDockerDriver) ImageRef(repo string) string

func (*TunnelProxyDockerDriver) Init

func (db *TunnelProxyDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*TunnelProxyDockerDriver) PullPolicy

func (db *TunnelProxyDockerDriver) PullPolicy() string

func (*TunnelProxyDockerDriver) Start

func (d *TunnelProxyDockerDriver) Start(
	ctx context.Context,
	projectID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*TunnelProxyDockerDriver) Stop

func (d *TunnelProxyDockerDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type TunnelProxySupervisorDriver

type TunnelProxySupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

TunnelProxySupervisorDriver implements the Driver interface for process supervision.

func NewTunnelProxySupervisorDriver

func NewTunnelProxySupervisorDriver() *TunnelProxySupervisorDriver

NewTunnelProxySupervisorDriver creates a new Supervisor driver with default configuration.

func (*TunnelProxySupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*TunnelProxySupervisorDriver) Start

func (d *TunnelProxySupervisorDriver) Start(
	ctx context.Context,
	projectID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*TunnelProxySupervisorDriver) Stop

func (d *TunnelProxySupervisorDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type WorkerdManagerDockerDriver

type WorkerdManagerDockerDriver struct {
	// contains filtered or unexported fields
}

WorkerdManagerDockerDriver runs the APO-796 workerd-manager: a privileged, gVisor-capable sidecar that hosts the dev project's resident workerd (the single-project degenerate case of the per-tenant manager). It joins the apiserver's network namespace (so its kube-API and routing-publish traffic reach the apiserver over loopback, with no relaxation of the publish channel's loopback-only guard) and shares a volume with the backplane carrying the resident's host UDS.

func NewWorkerdManagerDockerDriver

func NewWorkerdManagerDockerDriver() *WorkerdManagerDockerDriver

NewWorkerdManagerDockerDriver creates a new Docker driver for workerd-manager.

func (*WorkerdManagerDockerDriver) GetAddr

GetAddr implements the Driver interface.

func (*WorkerdManagerDockerDriver) ImageRef

func (db *WorkerdManagerDockerDriver) ImageRef(repo string) string

func (*WorkerdManagerDockerDriver) Init

func (db *WorkerdManagerDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*WorkerdManagerDockerDriver) PullPolicy

func (db *WorkerdManagerDockerDriver) PullPolicy() string

func (*WorkerdManagerDockerDriver) Start

func (d *WorkerdManagerDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	serviceName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*WorkerdManagerDockerDriver) Stop

func (d *WorkerdManagerDockerDriver) Stop(orgID uuid.UUID, serviceName string)

Stop implements the Driver interface.

Jump to

Keyboard shortcuts

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