ingress

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ingress renders ingress configuration and validates domains. The per-host Caddy controller (added later) consumes this package; nothing here talks to podman or the network, so it is pure and unit-testable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderCaddyfile

func RenderCaddyfile(acmeEmail string, routes []Route) (string, error)

RenderCaddyfile produces a deterministic Caddyfile for routes. A non-empty acmeEmail sets the global ACME contact. Routes are emitted sorted by domain so identical inputs yield byte-identical output — a stable file means a `caddy reload` is a no-op when nothing actually changed.

func ValidateDomains

func ValidateDomains(domains []string) error

ValidateDomains checks that each domain is a syntactically valid lowercase FQDN and that the slice has no intra-slice duplicates. A nil/empty slice is valid (a non-web instance). Host-wide uniqueness across instances is enforced later, at route derivation.

Types

type CaddyController

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

CaddyController is the production Controller. It drives a per-host Caddy pod over the existing podman socket.

func NewCaddyController

func NewCaddyController(client podman.Client, st Store, cfg Config) *CaddyController

NewCaddyController builds a controller. st serves both spec storage and template lookups, so ingress declarations are always read fresh from the store (no stale boot-time template snapshot).

func (*CaddyController) Reconcile

func (c *CaddyController) Reconcile(ctx context.Context, host string) error

Reconcile makes host's Caddy proxy match the store-derived routes. It is serialized per host and safe to call repeatedly.

type Config

type Config struct {
	Network    string // shared ingress network name (e.g. "podman-api-ingress")
	CaddyImage string // e.g. "docker.io/library/caddy:2"
	ACMEEmail  string // ACME account email for the global Caddyfile block
}

Config holds the operator-set knobs for the Caddy controller.

type Controller

type Controller interface {
	// Reconcile makes the host's Caddy proxy match the routes derived from the
	// store: ensures the network + Caddy pod exist, renders the Caddyfile, and
	// applies it (zero-downtime reload). Safe to call repeatedly; serialized
	// per host.
	Reconcile(ctx context.Context, host string) error
}

Controller reconciles a host's ingress (Caddy) state with the store.

type Disabled

type Disabled struct{}

Disabled is the no-op Controller used when ingress is turned off. Reconcile does nothing so the rest of the system can call it unconditionally.

func (Disabled) Reconcile

func (Disabled) Reconcile(context.Context, string) error

type Route

type Route struct {
	Domain  string
	Backend string
}

Route maps a public domain to the backend address the host's Caddy reverse-proxies to. Backend is resolved on the shared ingress network (e.g. "web-app1:8080").

type Store

type Store interface {
	store.Store
	GetTemplate(ctx context.Context, id string) (store.Template, error)
}

Store is the controller's view of the durable state. It is the spec store plus template lookups: templates are mutable (created/edited at runtime), so the controller resolves each instance's ingress declaration from the store at reconcile time rather than caching a boot-time snapshot. *store.DB satisfies this; so does *store.Memory.

Jump to

Keyboard shortcuts

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