Documentation
¶
Overview ¶
Package haproxy implements proxy.Driver with HAProxy running as an Armada-managed system container. Structural changes are rendered to a config file, validated with `haproxy -c`, and applied with a graceful reload; server changes go through the Runtime API without a reload.
Index ¶
Constants ¶
const Image = "haproxy:3.2-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b"
Image is the HAProxy image, pinned by digest (3.2 LTS, Alpine). Update it through a reviewed PR; never use a mutable tag.
const MetricsPort = 8404
MetricsPort is the HAProxy stats/metrics port on the node's private IP.
const WakeSocketFile = "wake.sock"
WakeSocketFile is the agent's wake socket in the proxy's run directory, the only place HAProxy and the agent share.
Variables ¶
This section is empty.
Functions ¶
func WakeSocket ¶
WakeSocket returns the host path of the wake socket for a proxy directory.
Types ¶
type API ¶
type API interface {
Command(ctx context.Context, cmd string) (string, error)
// Payload sends a command followed by a multi-line payload.
Payload(ctx context.Context, cmd, payload string) (string, error)
}
API is the subset of the HAProxy Runtime API the driver uses.
type Config ¶
type Config struct {
// Dir is the host directory holding etc/ (config, certs) and run/
// (Runtime API socket). It is created with mode 0700.
Dir string
PrivateIP string
// InternalIP is the container bridge gateway for the internal frontend;
// empty disables internal ingress on this node.
InternalIP string
// Subnet is the node's container subnet in the cluster network, where
// its replicas have their own addresses (ADR 0025); empty otherwise.
Subnet string
Engine Engine
// API defaults to the Runtime API socket under Dir.
API API
// Listeners returns the TCP sockets listening on the node; it defaults
// to reading /proc/net (ADR 0039).
Listeners func() ([]netip.AddrPort, error)
Logger *slog.Logger
}
Config configures a Driver.
type ContainerEngine ¶
type ContainerEngine struct {
Runtime runtime.Driver
System runtime.SystemRunner
// Dir is the same host directory given to the Driver.
Dir string
Image string
// StartWait is how long Start waits to confirm HAProxy stays up.
StartWait time.Duration
}
ContainerEngine runs HAProxy as a host-network system container.
func (*ContainerEngine) Reload ¶
func (e *ContainerEngine) Reload(ctx context.Context) error
Reload sends SIGUSR2 to the HAProxy master process.
func (*ContainerEngine) Running ¶
func (e *ContainerEngine) Running(ctx context.Context) (bool, error)
Running reports whether the HAProxy container is up with the pinned image and this engine's directory.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the HAProxy proxy.Driver.
func (*Driver) Load ¶
Load implements proxy.LoadReader from the Runtime API's "show stat": each slot's current sessions plus its queue, and its total sessions, mapped back to the replica in that slot. Totals keep growing across reloads.
func (*Driver) SetClients ¶
SetClients implements proxy.ClientSetter: it maps the addresses of this node's containers to their apps for the internal frontend's checks (ADR 0026). The map file is replaced for the next start or reload, and a running HAProxy gets the new map at once, atomically, through the Runtime API.
type Engine ¶
type Engine interface {
Running(ctx context.Context) (bool, error)
// Start (re)creates the HAProxy container from the current config file.
Start(ctx context.Context) error
// Validate runs `haproxy -c` against a config file (container path).
Validate(ctx context.Context, file string) error
// Reload gracefully reloads the configuration (master-worker SIGUSR2).
Reload(ctx context.Context) error
}
Engine controls the HAProxy process.
type Layout ¶
Layout assigns replicas to fixed server slots per HAProxy backend. Slots let the Runtime API change servers without a reload; an empty string marks a free slot.