ingress

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ingress decides which Traefik replicas serve each project's public traffic (D22, Phase 23): by default the controller and edge pools, or the nodes a project chose as its load balancers. When a project's ingress changes, the previous one keeps serving each custom domain until that domain's DNS points at the new one.

Index

Constants

View Source
const MaxNodes = 16

MaxNodes is the most ingress nodes a project may have.

Variables

View Source
var DefaultTarget = Target{Default: true}

DefaultTarget is the controller and edge pools.

View Source
var ErrNoChange = errors.New("no change")

ErrNoChange means the project already has this ingress.

Functions

func SwapBase

func SwapBase(host, from, to string) string

SwapBase replaces a generated host's base domain ("" when it has another).

Types

type Manager

type Manager struct {

	// ControllerAddr is the controller's public IP (the default ingress).
	ControllerAddr func(ctx context.Context) string
	// Resolve looks a host up (nil: the system resolver).
	Resolve func(ctx context.Context, host string) ([]string, error)
	// OnChange runs after any project's ingress changed (routes, replicas
	// and firewalls follow).
	OnChange func()
	// NodeAddrs returns each node's public address by name (nil: their
	// WireGuard endpoints).
	NodeAddrs func(ctx context.Context) (map[string]string, error)
	// contains filtered or unexported fields
}

Manager keeps the projects' ingress settings in memory: routes ask for them every time Traefik polls.

func New

func New(st *store.Store, log *slog.Logger) *Manager

func (*Manager) Addr

func (m *Manager) Addr(node string) string

Addr is a node's public address ("" when unknown).

func (*Manager) Assigned

func (m *Manager) Assigned() map[string][]string

Assigned maps each ingress node to the projects it serves (currently, or as the previous ingress of a move).

func (*Manager) Base

func (m *Manager) Base(project, base string) string

Base is the base domain of a project's generated addresses: the cluster's, or the first ingress node's sslip.io name.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context) bool

Check moves the custom domains whose DNS has moved, and settles projects with none left. It reports whether anything changed.

func (*Manager) Current

func (m *Manager) Current(project string) Target

Current is who serves a project's generated addresses and public ports.

func (*Manager) CutOver

func (m *Manager) CutOver(ctx context.Context, projectID string) (store.Project, error)

CutOver ends a project's move now: the previous ingress stops serving it.

func (*Manager) Domain

func (m *Manager) Domain(project, host string) Target

Domain is who serves one of a project's custom domains: the current ingress, plus the previous one until the domain's DNS has moved.

func (*Manager) Expected

func (m *Manager) Expected(ctx context.Context, project string) []string

Expected are the addresses a project's custom domains must resolve to: every ingress node's, or the controller's.

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load reads every project's ingress and the nodes' public addresses.

func (*Manager) Move

func (m *Manager) Move(project string) *store.IngressMove

Move is a project's ingress change in progress (nil when settled).

func (*Manager) Nodes

func (m *Manager) Nodes(project string) []string

Nodes are a project's ingress nodes (empty = the default ingress).

func (*Manager) Pending

func (m *Manager) Pending(ctx context.Context, project string) []string

Pending lists a moving project's custom domains whose DNS has not moved.

func (*Manager) Ports

func (m *Manager) Ports(project string) Target

Ports is who opens a project's public ports: the current ingress, plus the previous one while it moves.

func (*Manager) Previous

func (m *Manager) Previous(project string) (Target, bool)

Previous is who served the project before its move (ok = moving).

func (*Manager) PreviousBase

func (m *Manager) PreviousBase(project, base string) (string, bool)

PreviousBase is the base the project's generated addresses had before its move (ok = moving).

func (*Manager) RemoveNode

func (m *Manager) RemoveNode(ctx context.Context, node string) error

RemoveNode takes a node out of every project's ingress, at once (it is leaving the cluster). A project left with none goes back to the default.

func (*Manager) RenameNode

func (m *Manager) RenameNode(ctx context.Context, from, to string) error

RenameNode follows a node's new name.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run reloads the settings and moves every custom domain whose DNS points at its project's new ingress, every minute.

func (*Manager) Set

func (m *Manager) Set(ctx context.Context, projectID string, nodes []string) (store.Project, error)

Set changes a project's ingress nodes (nil = the default ingress). The previous ingress keeps serving until DNS moves; going back to it cancels the move.

func (*Manager) Using

func (m *Manager) Using(node string) (all, last []string)

Using lists the projects whose ingress (current or previous) has node, and those for which it is the last ingress node.

type Target

type Target struct {
	Default bool     `json:"default"`
	Nodes   []string `json:"nodes"`
}

Target is who serves a route: the default ingress (controller and edge pools) and/or ingress nodes, by name.

func (Target) Served

func (t Target) Served(node string, platform bool) bool

Served reports whether a replica serves the target: the controller and edge-pool nodes serve the default; any node serves targets naming it.

func (Target) Union

func (t Target) Union(o Target) Target

Jump to

Keyboard shortcuts

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