config

package
v1.0.0-rc.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 11 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 config reads the configuration of `beekeeper serve`: a YAML file with the installation, the listeners, the OIDC issuer, the organizations and their principals, the host-access check, the leases, placement's policy and retention. Unset values take their defaults, and Load refuses a file that is invalid or has unknown fields.

Index

Constants

View Source
const (
	DefaultAPIAddress       = ":8080"
	DefaultMetricsAddress   = ":9090"
	DefaultUsernameClaim    = "email"
	DefaultGroupsClaim      = "groups"
	DefaultLease            = 30 * time.Second
	DefaultTaskRetention    = 7 * 24 * time.Hour
	DefaultSessionRetention = 30 * 24 * time.Hour
	DefaultLeaderElection   = "beekeeper"
	// MinHeartbeat is the shortest heartbeat lease: runners send a heartbeat
	// every third of it.
	MinHeartbeat = 3 * time.Second
)

The defaults.

Variables

View Source
var DefaultHostAccess = HostAccess{Group: v1alpha1.GroupVersion.Group, Resource: "runners", Verb: "get"}

DefaultHostAccess asks whether a person may get runners in the organization's namespace.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Installation is the installation runners register on.
	Installation string `json:"installation"`
	// Listen are the addresses Beekeeper serves on.
	Listen Listen `json:"listen"`
	// OIDC is the issuer every caller's token comes from.
	OIDC OIDC `json:"oidc"`
	// Organizations are the only source of the namespace, organization and
	// principal map.
	Organizations []Organization `json:"organizations"`
	// HostAccess is the SubjectAccessReview that says a person may use an
	// organization's namespace.
	HostAccess HostAccess `json:"hostAccess"`
	// Leases are the heartbeat, offer-answer and placement-failure windows.
	Leases Leases `json:"leases"`
	// Placement is placement's policy.
	Placement Placement `json:"placement"`
	// Retention is how long ended tasks and sessions are kept.
	Retention Retention `json:"retention"`
	// LeaderElection is the Lease that elects the coordinator.
	LeaderElection LeaderElection `json:"leaderElection"`
}

Config is the configuration of `beekeeper serve`.

func Load

func Load(path string) (*Config, error)

Load reads, defaults and validates the configuration file at path.

func Parse

func Parse(data []byte) (*Config, error)

Parse defaults and validates a configuration.

func (*Config) Default

func (c *Config) Default()

Default sets every unset value to its default.

func (*Config) Namespaces

func (c *Config) Namespaces() []string

Namespaces are the organizations' namespaces.

func (*Config) Organization

func (c *Config) Organization(namespace string) (Organization, bool)

Organization returns the organization of a namespace.

func (*Config) OrganizationNamed

func (c *Config) OrganizationNamed(name string) (Organization, bool)

OrganizationNamed returns the organization of a name.

func (*Config) Policy

func (c *Config) Policy() placement.Policy

Policy is placement's policy: the configured values over placement.DefaultPolicy.

func (*Config) Validate

func (c *Config) Validate() error

Validate reports every invalid value.

type HostAccess

type HostAccess struct {
	Group    string `json:"group"`
	Resource string `json:"resource"`
	Verb     string `json:"verb"`
}

HostAccess is the resource attributes of the SubjectAccessReview that says a person may use an organization's namespace.

type LeaderElection

type LeaderElection struct {
	// Namespace holds the Lease. Empty is the namespace Beekeeper runs in.
	Namespace string `json:"namespace"`
	// Name is the Lease's name.
	Name string `json:"name"`
}

LeaderElection is the Lease that elects the coordinator.

type Leases

type Leases struct {
	// Heartbeat is how long a started session may go without a heartbeat
	// before its task is lost. Runners send one every third of it.
	Heartbeat metav1.Duration `json:"heartbeat"`
	// OfferAnswer is how long a runner has to answer an offer. No answer
	// counts as a decline.
	OfferAnswer metav1.Duration `json:"offerAnswer"`
	// PlacementFailure is how soon after its start a failed session counts
	// as a placement failure, which places the task again.
	PlacementFailure metav1.Duration `json:"placementFailure"`
}

Leases are the coordinator's windows.

type Listen

type Listen struct {
	// API serves the runner API, the MCP endpoint and the health probes.
	API string `json:"api"`
	// Metrics serves Prometheus metrics.
	Metrics string `json:"metrics"`
}

Listen are the addresses Beekeeper serves on.

type OIDC

type OIDC struct {
	// IssuerURL is the issuer, such as Dex. Its keys come from discovery.
	IssuerURL string `json:"issuerURL"`
	// CAFile is a PEM bundle trusted for the issuer besides the system's
	// roots, such as a lab issuer's own CA.
	CAFile string `json:"caFile,omitempty"`
	// Audience is Beekeeper's client ID: every token's aud must contain it.
	Audience string `json:"audience"`
	// UsernameClaim is the claim that holds a person's username.
	UsernameClaim string `json:"usernameClaim"`
	// UsernamePrefix is prepended to the username.
	UsernamePrefix string `json:"usernamePrefix"`
	// GroupsClaim is the claim that holds a person's groups.
	GroupsClaim string `json:"groupsClaim"`
	// GroupsPrefix is prepended to every group.
	GroupsPrefix string `json:"groupsPrefix"`
}

OIDC is the issuer of every caller's token and how a person's token maps to a Kubernetes username and groups, the way the kube-apiserver maps it.

type Organization

type Organization struct {
	// Name is the organization's name, a DNS label.
	Name string `json:"name"`
	// Namespace holds the organization's runners, tasks, sessions and
	// subscriptions.
	Namespace string `json:"namespace"`
	// Principal is the organization's own identity, as which its workflows
	// offer and cancel tasks.
	Principal Principal `json:"principal"`
}

Organization is an organization, its namespace and its principal.

type Pace

type Pace struct {
	WeekLength        *metav1.Duration `json:"weekLength,omitempty"`
	ShortWindowStop   *float64         `json:"shortWindowStop,omitempty"`
	Headroom          *float64         `json:"headroom,omitempty"`
	StaleAfter        *metav1.Duration `json:"staleAfter,omitempty"`
	ReservePerSession *v1alpha1.Usage  `json:"reservePerSession,omitempty"`
}

Pace are the default pace rules.

type Placement

type Placement struct {
	// AffinityWait is how long a task waits for its preferred runner.
	AffinityWait metav1.Duration `json:"affinityWait"`
	// DeclineBackoff is how long a runner that declined a task isn't
	// offered it again.
	DeclineBackoff metav1.Duration `json:"declineBackoff"`
	// Limits are the default pressure bounds for runners that set none.
	Limits v1alpha1.PressureLimits `json:"limits"`
	// Pace are the default pace rules for subscriptions that set none.
	Pace Pace `json:"pace"`
}

Placement is placement's policy. Unset values take placement.DefaultPolicy's.

type Principal

type Principal struct {
	// ClientID is the principal's client at the issuer.
	ClientID string `json:"clientID"`
}

Principal is an organization's own identity.

type Retention

type Retention struct {
	Tasks    metav1.Duration `json:"tasks"`
	Sessions metav1.Duration `json:"sessions"`
}

Retention is how long ended tasks and sessions are kept.

Jump to

Keyboard shortcuts

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