kube

package
v0.167.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 26 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 kube is the Kubernetes store of `beekeeper serve`: the shared state of the Giant Swarm installations as custom resources of beekeeper.giantswarm.io instead of one document under a file lock.

Each record kind of the state document is a kind of its own: the grants and the release time of an installation are its Environment, a lane's merges its MergeLane, a hold a Hold, a note a Note in the filer's team namespace, an agent a RosterEntry in its team's namespace, the last note number handed out the note counter, a ConfigMap of serve's own namespace. Concurrency is per object: an update writes the one object it changes, or the Notes it changes one by one, under the resourceVersion it read, so updates of different installations never contend, and a lost race reruns the update on what won it.

The rest of the document (the supervisor, timers, records, the merge gate's processes, side files) belongs to the machine and has no home here: an update that changes it is refused, never kept somewhere else.

Index

Constants

View Source
const DefaultNamespace = "beekeeper"

DefaultNamespace is the namespace of the store's own objects unless InNamespace names another: the chart's.

Variables

View Source
var ErrLocal = errors.New("the Kubernetes store keeps the shared state only; this stays on the machine")

ErrLocal is the refusal of what belongs to the machine, not to the shared state: side files, events of no object.

Functions

func APIParty added in v0.75.0

func APIParty(p state.Party) v1alpha1.Party

APIParty is p as the resources' party.

func EnvironmentObject added in v0.75.0

func EnvironmentObject(name string) client.Object

EnvironmentObject is the Environment name.

func EventLabels added in v0.76.0

func EventLabels() map[string]string

EventLabels are the labels of every Event beekeeper records.

func FeedEvent added in v0.78.0

func FeedEvent(ev *corev1.Event) (feed.Event, error)

FeedEvent is a beekeeper Event in the feed's schema.

func HoldObject added in v0.75.0

func HoldObject(target string) client.Object

HoldObject is the Hold of target. It and the other *Object functions name a record of the state document for Audit.

func LaneObject added in v0.75.0

func LaneObject(name string) client.Object

LaneObject is the MergeLane name.

func NoteObject added in v0.75.0

func NoteObject(team string, id int) client.Object

NoteObject is note id of team's namespace.

func PartyOf added in v0.75.0

func PartyOf(p v1alpha1.Party) state.Party

PartyOf is p as the state document's party.

func RosterObject added in v0.75.0

func RosterObject(p state.Party) client.Object

RosterObject is p's roster entry.

func Scheme

func Scheme() (*runtime.Scheme, error)

Scheme returns a scheme with the core kinds (Events, Namespaces) and beekeeper's.

func TeamNamespace added in v0.75.0

func TeamNamespace(team string) string

TeamNamespace is a team's namespace, beekeeper-<team>.

Types

type HeldError

type HeldError struct {
	Environment string
	Holder      v1alpha1.Holder
}

HeldError is a claim's refusal: the Environment is held by someone else.

func (*HeldError) Error

func (e *HeldError) Error() string

type Store

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

Store is the state.Store over the beekeeper.giantswarm.io resources.

Update may run its function more than once: when another writer changed the object in between, it rereads and reruns. The function must change nothing but the state it is given.

func New

func New(c client.Client) *Store

New returns the store over c, whose scheme knows beekeeper's kinds.

func NewForConfig

func NewForConfig(cfg *rest.Config) (*Store, error)

NewForConfig returns the store over the API server cfg names.

func (*Store) Audit added in v0.75.0

func (s *Store) Audit(obj client.Object, team string, e state.Event) error

Audit records e as a Kubernetes Event on obj (its kind, namespace and name; the rest is read), or, without obj or once obj is gone, on the namespace of team: a call that changed nothing still leaves its Event.

func (*Store) Claim

func (s *Store) Claim(name string, h v1alpha1.Holder) error

Claim makes h the holder of the Environment. Of two concurrent claims one wins; the other gets a HeldError naming the winner. A claim by the holder itself renews nothing and succeeds.

func (*Store) Dir

func (s *Store) Dir() string

Dir is empty: the store has no directory; side files stay on the machine.

func (*Store) Environments added in v0.75.0

func (s *Store) Environments() ([]v1alpha1.Environment, error)

Environments returns every Environment, by name.

func (*Store) Events

func (s *Store) Events(n int, keep func(state.Event) bool) ([]state.Event, error)

Events returns the last n Kubernetes Events beekeeper recorded that keep accepts, oldest first.

func (*Store) Exclusive added in v0.145.2

func (s *Store) Exclusive(fn func() error) error

Exclusive runs fn: the Kubernetes store has no lock a process holds.

func (*Store) Feed added in v0.76.0

func (s *Store) Feed(n int) ([]feed.Event, error)

Feed returns the last n events of the shared state in the feed's schema, oldest first: the changes, not the audit of the calls that changed nothing (serve.*).

func (*Store) Follow added in v0.107.0

func (s *Store) Follow(_ string, keep func(state.Event) bool) ([]state.Event, error)

Follow lists the events as Events(0, keep) does: the API server keeps no place of a reader's.

func (*Store) Free added in v0.75.0

func (s *Store) Free(name string, holder, by state.Party, now time.Time) error

Free frees the Environment while holder holds it, recorded as by's: the holder's own release, or another's (the owning team's supervisor) as a forced one. Another holder than holder is refused with the holder named.

func (*Store) Holder

func (s *Store) Holder(name string) (*v1alpha1.Holder, error)

Holder returns who holds the Environment, nil while it is free.

func (*Store) InNamespace added in v0.164.0

func (s *Store) InNamespace(ns string) *Store

InNamespace keeps the store's own objects (the note counter) in ns, serve's namespace; an empty ns keeps DefaultNamespace.

func (*Store) Lanes added in v0.75.0

func (s *Store) Lanes() ([]v1alpha1.MergeLane, error)

Lanes returns every MergeLane, by name.

func (*Store) Log

func (s *Store) Log(events ...state.Event) error

Log refuses: an event of no object stays in the machine's log.

func (*Store) Peek

func (s *Store) Peek() (*state.State, error)

Peek is Read: no writer is waited on.

func (*Store) Read

func (s *Store) Read() (*state.State, error)

Read returns the shared state.

func (*Store) ReadFile

func (s *Store) ReadFile(name string, _ any) (bool, error)

ReadFile refuses: side files stay on the machine.

func (*Store) Record added in v0.104.0

func (s *Store) Record(events ...state.Event) error

Record refuses as Log does.

func (*Store) RecordWithin added in v0.145.3

func (s *Store) RecordWithin(_ time.Duration, events ...state.Event) error

RecordWithin refuses as Log does.

func (*Store) Release

func (s *Store) Release(name string, p state.Party, now time.Time) error

Release frees the Environment held by p and records the release time; a release by anyone else is refused with the holder named.

func (*Store) Update

func (s *Store) Update(fn func(*state.State) ([]state.Event, error)) error

Update runs fn on the shared state and writes the one object it changed, or each of the Notes it changed, under the resourceVersion read, with fn's events as Kubernetes Events on the object each names (a note's #id), else on the first. A lost race reruns fn on the winner's state, the Notes written before it included. An update that changes more than one object other than Notes, or anything without a home in the resources, is refused with nothing written.

A note number above the last one handed out (State.NextNote) advances the note counter first, under the resourceVersion read: of two concurrent note adds one reruns and takes the next number, and a closed note's number, any team's, is never handed out again.

func (*Store) UpdateWithin added in v0.145.2

func (s *Store) UpdateWithin(_ time.Duration, fn func(*state.State) ([]state.Event, error)) error

UpdateWithin is Update: the Kubernetes store takes no lock to wait for.

func (*Store) WriteFile

func (s *Store) WriteFile(name string, _ any) error

WriteFile refuses: side files stay on the machine.

Jump to

Keyboard shortcuts

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