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
- Variables
- func APIParty(p state.Party) v1alpha1.Party
- func EnvironmentObject(name string) client.Object
- func EventLabels() map[string]string
- func FeedEvent(ev *corev1.Event) (feed.Event, error)
- func HoldObject(target string) client.Object
- func LaneObject(name string) client.Object
- func NoteObject(team string, id int) client.Object
- func PartyOf(p v1alpha1.Party) state.Party
- func RosterObject(p state.Party) client.Object
- func Scheme() (*runtime.Scheme, error)
- func TeamNamespace(team string) string
- type HeldError
- type Store
- func (s *Store) Audit(obj client.Object, team string, e state.Event) error
- func (s *Store) Claim(name string, h v1alpha1.Holder) error
- func (s *Store) Dir() string
- func (s *Store) Environments() ([]v1alpha1.Environment, error)
- func (s *Store) Events(n int, keep func(state.Event) bool) ([]state.Event, error)
- func (s *Store) Exclusive(fn func() error) error
- func (s *Store) Feed(n int) ([]feed.Event, error)
- func (s *Store) Follow(_ string, keep func(state.Event) bool) ([]state.Event, error)
- func (s *Store) Free(name string, holder, by state.Party, now time.Time) error
- func (s *Store) Holder(name string) (*v1alpha1.Holder, error)
- func (s *Store) InNamespace(ns string) *Store
- func (s *Store) Lanes() ([]v1alpha1.MergeLane, error)
- func (s *Store) Log(events ...state.Event) error
- func (s *Store) Peek() (*state.State, error)
- func (s *Store) Read() (*state.State, error)
- func (s *Store) ReadFile(name string, _ any) (bool, error)
- func (s *Store) Record(events ...state.Event) error
- func (s *Store) RecordWithin(_ time.Duration, events ...state.Event) error
- func (s *Store) Release(name string, p state.Party, now time.Time) error
- func (s *Store) Update(fn func(*state.State) ([]state.Event, error)) error
- func (s *Store) UpdateWithin(_ time.Duration, fn func(*state.State) ([]state.Event, error)) error
- func (s *Store) WriteFile(name string, _ any) error
Constants ¶
const DefaultNamespace = "beekeeper"
DefaultNamespace is the namespace of the store's own objects unless InNamespace names another: the chart's.
Variables ¶
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 EnvironmentObject ¶ added in v0.75.0
EnvironmentObject is the Environment name.
func EventLabels ¶ added in v0.76.0
EventLabels are the labels of every Event beekeeper records.
func HoldObject ¶ added in v0.75.0
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
LaneObject is the MergeLane name.
func NoteObject ¶ added in v0.75.0
NoteObject is note id of team's namespace.
func RosterObject ¶ added in v0.75.0
RosterObject is p's roster entry.
func TeamNamespace ¶ added in v0.75.0
TeamNamespace is a team's namespace, beekeeper-<team>.
Types ¶
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 NewForConfig ¶
NewForConfig returns the store over the API server cfg names.
func (*Store) Audit ¶ added in v0.75.0
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 ¶
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) Environments ¶ added in v0.75.0
func (s *Store) Environments() ([]v1alpha1.Environment, error)
Environments returns every Environment, by name.
func (*Store) Events ¶
Events returns the last n Kubernetes Events beekeeper recorded that keep accepts, oldest first.
func (*Store) Exclusive ¶ added in v0.145.2
Exclusive runs fn: the Kubernetes store has no lock a process holds.
func (*Store) Feed ¶ added in v0.76.0
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
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
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) InNamespace ¶ added in v0.164.0
InNamespace keeps the store's own objects (the note counter) in ns, serve's namespace; an empty ns keeps DefaultNamespace.
func (*Store) RecordWithin ¶ added in v0.145.3
RecordWithin refuses as Log does.
func (*Store) Release ¶
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 ¶
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
UpdateWithin is Update: the Kubernetes store takes no lock to wait for.