Documentation
¶
Overview ¶
Package timeline reconstructs an application's history from the cluster.
kubeside writes nothing to disk, so it records no history of its own. It does not need to: Kubernetes already retains substantial history in ReplicaSets, ControllerRevisions, Helm release secrets, pod termination states, and events. Nobody assembles it, which is the actual gap this package closes.
Two rules govern everything here. Each source degrades independently: a forbidden Helm secret is a normal answer for a read-only prod role, so the timeline renders from the others and names what is missing. And where reconstruction runs out, it says why. Silence before a horizon means "not known", never "nothing happened", because rendering an empty axis as a quiet period misleads exactly the person under the most pressure.
Index ¶
- Constants
- func FromControllerRevisions(revs []appsv1.ControllerRevision, owner types.UID) ([]Entry, *Horizon)
- func FromEvents(events []corev1.Event, keep func(corev1.Event) bool) ([]Entry, *Horizon)
- func FromReplicaSets(sets []appsv1.ReplicaSet, owner types.UID) ([]Entry, *Horizon)
- type Actor
- type Entry
- type Gap
- type Horizon
- type Target
- type Timeline
Constants ¶
const ( KindDeploy = "deploy" KindRelease = "release" KindRestart = "restart" KindScale = "scale" KindWarning = "warning" // KindHealth is a live transition kubeside watched happen, rather than // something reconstructed from the cluster's own records. KindHealth = "health" // KindExec records somebody opening a shell in a container. A shell in // production is an event, not a page view. KindExec = "exec" // KindBreakGlass records somebody arming an environment for writes. // Arming production is an event, not a setting. KindBreakGlass = "break-glass" // KindReveal records that somebody read a secret value through kubeside. // Reading a production credential should leave a trace in the same place // every other change does. KindReveal = "reveal" KindRun = "run" KindSession = "session" )
Entry kinds.
const ( ActorUnknown = "" ActorKubectl = "kubectl" ActorHelm = "helm" ActorArgoCD = "argocd" ActorHPA = "hpa" )
Actor kinds. Attribution comes from managedFields where it is derivable.
const ActorAutoscaler = "autoscaler"
ActorAutoscaler is an autoscaler, whose changes are expected rather than out-of-band.
const ActorController = "controller"
ActorController is a Kubernetes controller acting on its own, which is not somebody to ask about the change.
const AttributionWindow = time.Minute
AttributionWindow is how close a manager's write must be to a rollout to be called its cause. A rollout follows its trigger within seconds.
Variables ¶
This section is empty.
Functions ¶
func FromControllerRevisions ¶
FromControllerRevisions does the same for StatefulSets and DaemonSets, which keep their history as ControllerRevisions rather than ReplicaSets.
func FromEvents ¶
FromEvents keeps the warnings still inside the apiserver's TTL.
Normal events are dropped: a timeline of image pulls buries the probe failure that explains the incident.
keep selects this app's events, but the horizon is computed over all of them. The oldest event in the namespace is where the apiserver's retention actually ends; the oldest event for one app is just when that app last had something to say, and dating the horizon there would claim a cut that is not real.
func FromReplicaSets ¶
FromReplicaSets turns a Deployment's ReplicaSets into rollout history.
Every ReplicaSet the cluster still holds is one revision that shipped, with the image it shipped. The horizon is the oldest survivor: everything before it was pruned by revisionHistoryLimit and is genuinely unknowable.
Types ¶
type Actor ¶
type Actor struct {
// Kind is the normalized label: kubectl, helm, argocd, hpa, or empty.
Kind string `json:"kind,omitempty"`
// Name is the raw field manager, kept because an unrecognized manager is
// still information: it names the controller that did this.
Name string `json:"name,omitempty"`
}
Actor is who made a change, when the cluster can tell us.
type Entry ¶
type Entry struct {
At time.Time `json:"at"`
Kind string `json:"kind"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
// Source names where this was reconstructed from, so a developer can tell
// an assembled fact from a live one.
Source string `json:"source"`
Revision string `json:"revision,omitempty"`
Image string `json:"image,omitempty"`
Pod string `json:"pod,omitempty"`
Actor Actor `json:"actor,omitzero"`
}
Entry is one thing that happened.
func Attribute ¶
func Attribute(entries []Entry, fields []metav1.ManagedFieldsEntry) []Entry
Attribute assigns an actor to the entries a manager can be matched to.
Matching is by time: a rollout that happened when a manager wrote is that manager's doing. An entry outside the window keeps no actor, because a wrong name on a prod change is worse than no name.
func FromHelmSecrets ¶
FromHelmSecrets reads release history from the secrets Helm writes.
The labels carry everything the axis needs, so the gzipped release payload is never decoded: less to go wrong, and nothing sensitive is touched.
type Horizon ¶
type Horizon struct {
At time.Time `json:"at"`
Source string `json:"source"`
Reason string `json:"reason"`
// Pruned is false when the source still holds the beginning of the app's
// history, so the UI marks a start rather than a cut.
Pruned bool `json:"pruned"`
}
Horizon is where one source ran out, and why.
type Target ¶
type Target struct {
Namespace string
Name string
// Kind selects which rollout source applies: Deployments keep history in
// ReplicaSets, StatefulSets and DaemonSets in ControllerRevisions.
Kind string
// UID is the workload's own UID, which is how history is attributed to
// this app rather than to a same-named one that was deleted and recreated.
UID types.UID
// Pods are the pods currently backing the workload, from the grouping
// engine.
Pods []string
}
Target is the workload to reconstruct.
type Timeline ¶
type Timeline struct {
Entries []Entry `json:"entries"`
Horizons []Horizon `json:"horizons,omitempty"`
Gaps []Gap `json:"gaps,omitempty"`
}
Timeline is the assembled history.
func Reconstruct ¶
Reconstruct assembles a target's history from what the cluster still holds.
Every source is read independently and a failure in one is recorded as a gap rather than returned as an error. A read-only prod role that cannot read secrets still gets rollouts, crashes, and warnings, with one line explaining what Helm history would have added.
func (*Timeline) AddHorizon ¶
AddHorizon records where a source ran out.