ingress

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ingress reconciles the local Caddy ingress to match desired state.

The agent is the only thing that talks to Caddy: it pushes the full runtime config (per-Egg routes and the on-demand TLS policy) through Caddy's admin API, and it serves the "ask" endpoint that Caddy calls before issuing a certificate for any hostname. The ask endpoint says yes only for hostnames currently in the desired state, so a certificate is never minted for a domain that is not ours to serve. Nothing configures Caddy by rewriting files and nothing reaches in from the control plane; this mirrors the pull-based model of the rest of the agent.

Locally Caddy uses its INTERNAL CA (its own issuer), so certificates are real TLS but need no Let's Encrypt, which cannot issue for these test hostnames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reconciler

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

Reconciler owns the connection to Caddy's admin API and the ask allow-list.

func New

func New(adminURL, upstreamHost, askEndpoint string, localTLS bool, log *slog.Logger) *Reconciler

New builds a Reconciler. adminURL is the Caddy admin API base; upstreamHost is how Caddy dials Egg containers; askEndpoint is the URL (reachable from Caddy) of this agent's ask handler; localTLS selects the internal CA for local dev instead of Let's Encrypt.

func (*Reconciler) Allowed

func (r *Reconciler) Allowed(host string) bool

Allowed reports whether a hostname is currently permitted a certificate.

func (*Reconciler) AskHandler

func (r *Reconciler) AskHandler() http.HandlerFunc

AskHandler answers Caddy's on-demand TLS ask: 200 for an allowed hostname, 403 otherwise. Caddy passes the hostname as ?domain=.

func (*Reconciler) Health added in v0.1.39

Health probes the local Caddy for a heartbeat report: whether the admin API is reachable, whether the public HTTPS port is listening, and each served hostname's certificate state. Best-effort: every probe degrades to a negative/pending result on failure rather than erroring, so a heartbeat is never blocked by ingress health.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, routes []Route, limits *contract.IngressConfig) error

Reconcile pushes the config for the given routes to Caddy if it has changed, and updates the ask allow-list. A no-change reconcile is a cheap hash compare.

type Route

type Route struct {
	Hostnames     []string
	UpstreamPorts []int
}

Route is one Egg's ingress: the hostnames it serves and the host ports its replicas are published on. Caddy load-balances across all of an Egg's live replica ports (round-robin by default), so a multi-replica Egg spreads traffic and survives a single replica dying. The upstream host (how Caddy reaches those ports) is configured on the Reconciler.

Jump to

Keyboard shortcuts

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