Documentation
¶
Overview ¶
Package app wires the backend together. Both the upstream main and downstream mains use it; downstreams pass extension options.
Index ¶
- Constants
- func ApplyMemoryLimit() int64
- func CoreCapabilities(snap *cache.Snapshot, d Diagnostics, collected collect.Snapshot) []api.Capability
- func Run(ctx context.Context, kubeconfig string, o Options, opts ...extension.Option) error
- func RunWith(ctx context.Context, kubeconfig string, o Options, reg *extension.Registry) error
- type App
- type Clients
- type Diagnostics
- type Options
Constants ¶
const ( ModeLocal = "local" ModeSecure = "secure" )
Auth modes. Local serves only through loopback; secure expects an identity gate.
const MemoryLimitEnv = "SNELLIUS_MEMORY_LIMIT"
MemoryLimitEnv holds the pod's memory limit in bytes; the chart sets it from limits.memory.
Variables ¶
This section is empty.
Functions ¶
func ApplyMemoryLimit ¶
func ApplyMemoryLimit() int64
ApplyMemoryLimit sets the Go memory target to 90 % of the limit in MemoryLimitEnv (D-025). An explicit GOMEMLIMIT wins; a missing, zero or unparsable limit is ignored and logged. It returns the target set, or zero. Run calls it first; repeated calls are harmless.
func CoreCapabilities ¶
func CoreCapabilities(snap *cache.Snapshot, d Diagnostics, collected collect.Snapshot) []api.Capability
CoreCapabilities returns the core inputs' states for /api/v1/meta; a syncing or unstarted watch, and proxy stats before their first round, have none.
Types ¶
type App ¶
type App struct {
Engine *engine.Engine
Handler http.Handler
// Metrics is served on the probe listener.
Metrics *obs.Registry
// Audit writes the audit records.
Audit *audit.Logger
// contains filtered or unexported fields
}
App is a built, not yet started, backend.
func Build ¶
Build resolves the served kinds and constructs every component. Both intervals must be positive and the delegation edge cap not negative.
func (*App) Start ¶
Start runs the cache, the pack and extension collectors, the model loop and the served-kinds monitor until ctx is done. PollInterval is the loop's safety timer. The controller metrics collector starts as soon as the first install is discovered over a settled cache, so the first metrics do not wait for a tick.
type Clients ¶
type Clients struct {
Dynamic dynamic.Interface
Kube kubernetes.Interface
Discovery kinds.DiscoveryClient
// Metadata reads CRD metadata; nil means no CRD watch.
Metadata metadata.Interface
// InCluster selects direct pod-IP metric scraping; otherwise pods/proxy is used.
InCluster bool
// Scraper overrides the metrics scraper InCluster selects; nil keeps it.
Scraper ctrlmetrics.Scraper
// SAR sends SubjectAccessReviews without a client-side rate limit, so the
// authoriser's own limit is the only one; nil means Kube.
SAR kubernetes.Interface
}
Clients are the Kubernetes clients the app uses.
type Diagnostics ¶
type Diagnostics struct {
NoEvents, NoCRDs, NoProxyStats, NoEndpoints bool
ControllerLogs bool
// ControllerLogsNamespaces are the install namespaces whose controller logs are read.
ControllerLogsNamespaces []string
}
Diagnostics toggles the optional inputs (design §18.1): No* turns off a default-on input, ControllerLogs turns on a default-off one.
type Options ¶
type Options struct {
// Listen is the HTTP address; empty means 127.0.0.1:8080, or :8080 in-cluster in secure mode.
Listen string
// AuthMode is "local" (default: loopback only, Host-guarded) or "secure".
AuthMode string
// OIDC configures sign-in in secure mode; local mode ignores it.
OIDC oidc.Config
// CookieInsecure drops the Secure attribute from sign-in cookies, for plain-HTTP testing only.
CookieInsecure bool
// SessionIdle and SessionAbsolute bound a secure-mode session; zero means 30 min and 8 h.
SessionIdle, SessionAbsolute time.Duration
// SessionMax is the most sessions held at once; zero means 1,000.
SessionMax int
// AuthzCacheTTL bounds every cached allowed permission check in secure mode; zero means 60 s.
AuthzCacheTTL time.Duration
// AuthzNamedGetScan adds a named get to secure-mode list checks the list denies (D-100).
AuthzNamedGetScan bool
// AuthzMaxInFlight, AuthzRate and AuthzBurst bound the secure-mode SARs
// across viewers: at once, per second, and at once above the rate (D-100). Zero means the sar default.
AuthzMaxInFlight, AuthzRate, AuthzBurst int
// TrustedProxyCIDRs are the peers whose X-Request-Id and X-Forwarded-For are trusted.
TrustedProxyCIDRs []netip.Prefix
// AllowedHosts are extra Host names local mode serves, besides loopback.
AllowedHosts []string
// AuditLevels is the comma list of audit levels to write; empty means audit.DefaultLevels.
AuditLevels string
// AuditOut receives the audit JSON lines; nil means stdout.
AuditOut io.Writer
// ProbeListen is the health-probe address; empty means :8081 in-cluster and 127.0.0.1:8081 locally.
ProbeListen string
// Pinned restricts the UI to one install: its ID, or namespace/name (D-016).
Pinned string
// PollInterval is the maximum time between model recomputes: the safety
// timer. Object, access, metrics and served-kind changes recompute sooner (D-019).
PollInterval time.Duration
// MetricsInterval is the controller metrics scrape interval.
MetricsInterval time.Duration
// DelegationEdgeCap caps the selected delegation edges per install (rules
// §5.7); zero means computed.DefaultBounds.Edges. A higher cap needs more
// memory (D-025).
DelegationEdgeCap int
// KindsInterval is how often served kinds are re-resolved; zero means 60 s.
KindsInterval time.Duration
// UI is the single-page application served at /.
UI fs.FS
// ConfirmEvery is the engine's confirm tick interval; zero means
// engine.ConfirmEvery. Tests only.
ConfirmEvery time.Duration
// OnLoop receives the engine's loop transitions. Tests only.
OnLoop func(engine.LoopEvent)
// Clock drives the engine and stamps snapshots and collected values; nil
// means the real clock. Tests only.
Clock clock.WithTicker
// Diagnostics toggles the optional inputs; the zero value keeps the defaults.
Diagnostics Diagnostics
// ClassOnlyInstalls adds an install per GatewayClass controllerName that no
// detector claims, known from Gateway API status alone.
ClassOnlyInstalls bool
}
Options are the runtime settings.