router

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package router describes mutti's machine-wide reverse proxy: one Traefik container that owns the HTTP(S) ports on loopback and routes hostnames to instances. Traefik reads its routes from files mutti renders; it gets no access to the Docker socket.

Index

Constants

View Source
const (
	Role         = "router"
	LabelVersion = "mutti.router.version"
)

Labels and roles of the router container.

View Source
const ConfigFile = "/etc/mutti/dynamic/mutti.yml"

ConfigFile is where mutti puts the routes inside the router container. mutti copies it in through the Docker API, so it needs no path on the host: that works the same from inside a container, with Docker Desktop and on any OS.

View Source
const Image = "traefik:v3.6.25@sha256:31267173a15b4944e797a76ffd9c419707c8d8b32fe5b610f80cd0cfa05f372d"

Image is the Traefik release the router runs, pinned by digest.

View Source
const ReadyHost = "mutti-ready.internal"

ReadyHost is the host the router answers ReadyPath on. No instance route matches it: on an instance's own host, a catch-all route (a single-page app answering every path) would answer the probe while the router still runs the previous configuration.

Variables

This section is empty.

Functions

func ReadyPath

func ReadyPath(token string) string

ReadyPath is the path under which the router answers on ReadyHost once it loaded the configuration with the given token.

func Render

func Render(instances []Instance) (config []byte, token string)

Render returns the Traefik dynamic configuration of all routed instances, certificates inline, and its token: a hash of the content, which the configuration also serves under ReadyPath on ReadyHost. Seeing that path answer proves Traefik loaded exactly this version. JSON is valid YAML, which Traefik's file provider reads; encoding/json keeps it deterministic and correctly quoted.

func Spec

Spec returns the container spec of the router. Its version label changes whenever anything in the spec changes, which is the only reason mutti ever replaces a running router.

Types

type Instance

type Instance struct {
	Name     string
	MainHost string
	Routes   []Route
	CertPEM  []byte // certificate for MainHost and *.MainHost
	KeyPEM   []byte
}

Instance is everything the router needs to serve one instance.

func (Instance) Hosts

func (in Instance) Hosts() []string

Hosts returns every hostname an instance serves, sorted: the names the router answers to on the instance's ingress network and the names its certificate needs.

type Route

type Route struct {
	Service   string
	Hosts     []string
	Paths     []string
	Port      uint16
	Upstreams []string // container names, reachable on the instance's ingress network
}

Route sends hosts (and path prefixes on the main host) to a service's containers.

type Settings

type Settings struct {
	Name      string // container name
	HTTPPort  uint16 // host port for HTTP on loopback
	HTTPSPort uint16 // host port for HTTPS on loopback
	IPv6      bool   // also listen on [::1]
}

Settings configure the router container.

Jump to

Keyboard shortcuts

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