apps

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 4 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 apps turns a set of Kubernetes resources into applications.

This is the core abstraction of kubeside: developers think in services, not in ReplicaSets. Grouping is a pure function so it can be tested exhaustively against fixture clusters without an apiserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Key    Key
	Kind   string // primary workload kind, by kindRank
	Origin Origin

	// Component is app.kubernetes.io/name when present. Identity uses the
	// instance so two releases of one chart stay separate, while Component
	// carries the stable name that cross-environment matching needs later.
	Component string

	// ManagedBy names the controller kind that owns this app when the owner
	// walk terminated at a kind kubeside does not model, typically a custom
	// resource. It is infrastructure the developer did not deploy and cannot
	// act on, so the UI de-emphasises it. The row is never hidden: hiding
	// conflicts with disable-never-hide, and a CRD-backed workload that is
	// genuinely someone's app must stay visible.
	ManagedBy string

	Workloads []Object
}

App is a logical service: one or more top-level workloads that belong together, plus everything reachable from them.

func Group

func Group(objects []Object) []App

Group turns a set of Kubernetes objects into applications.

It is a pure function: no I/O, no clock, no randomness. The same input always produces the same output in the same order, which is what makes the engine testable against fixture clusters and what makes the kill criterion in issue #5 a fair judgement.

The precedence chain is documented in docs/03-product-spec.md. Each object resolves to a top-level workload by following controller owner references, then that workload's identity is derived by the first rule that matches.

func (App) Name

func (a App) Name() string

Name is the app's display name.

type Assessment

type Assessment struct {
	Health Health
	Reason string // short machine-ish token: CrashLoopBackOff, BelowDesired
	Detail string // one sentence naming the condition, probe, or count
}

Assessment is a health verdict plus why it was reached.

Reason and Detail exist because "degraded" on its own is not actionable. The UI shows Detail when the badge is clicked, and it must name the condition or probe rather than restating the state.

func Assess

func Assess(a App) Assessment

Assess derives an app's health from its workloads.

Evaluation order is first-match-wins, worst first, so a single crash-looping pod is never masked by five healthy siblings.

type Condition

type Condition struct {
	Type    string // Available, Progressing, ReplicaFailure
	Status  string // True, False, Unknown
	Reason  string
	Message string
}

Condition mirrors a Kubernetes status condition.

type Health

type Health int

Health is an app's derived state.

The derivation is specified in docs/03-product-spec.md rather than left to whatever the first implementation happened to compute, because the app list sorts on this and the promotion matrix colours cells by it.

const (
	// HealthUnknown: not enough was readable to say. Never rendered as healthy.
	HealthUnknown Health = iota
	// HealthHealthy: ready equals desired, rollout complete, no recent restarts.
	HealthHealthy
	// HealthProgressing: a rollout is in flight inside its deadline.
	HealthProgressing
	// HealthDegraded: below desired outside a rollout, or restarting.
	HealthDegraded
	// HealthFailed: crash looping, unpullable image, or deadline exceeded.
	HealthFailed
)

func (Health) Attention

func (h Health) Attention() int

Attention orders apps for the list: worst first, so the two things that need a human float above the forty that do not.

func (Health) String

func (h Health) String() string

type Key

type Key struct {
	Namespace string
	Name      string
}

Key identifies an application inside one cluster. Namespace is part of the identity: two teams may each ship an "api", and merging them would present unrelated services as one row.

type Object

type Object struct {
	Kind        string
	Name        string
	Namespace   string
	UID         string
	Labels      map[string]string
	Annotations map[string]string
	Owners      []Owner
	// Created is the object's creation time, which is how a pod's age is
	// rendered without a second read.
	Created time.Time

	// Status carries the fields health derivation needs. Kept as plain data
	// rather than client-go types so the engine stays pure and testable
	// without an apiserver. Nil when the object was read metadata-only.
	Status *Status
}

Object is the minimal shape the grouping engine needs from a Kubernetes resource. Adapters build these from typed or unstructured objects, which keeps the engine a pure function and testable without an apiserver.

type Origin

type Origin int

Origin records which rule in the precedence chain produced the app name. It is surfaced in the UI so grouping is explainable rather than magic, and it is the first thing to look at when grouping surprises someone.

const (
	// OriginRecommendedLabels: app.kubernetes.io/instance or /name.
	OriginRecommendedLabels Origin = iota
	// OriginHelm: meta.helm.sh/release-name annotation.
	OriginHelm
	// OriginArgo: argocd.argoproj.io/instance label.
	OriginArgo
	// OriginOwnerChain: walked up to a top-level controller.
	OriginOwnerChain
	// OriginWorkloadName: nothing else applied, the workload's own name.
	OriginWorkloadName
)

func (Origin) String

func (o Origin) String() string

type Owner

type Owner struct {
	Kind       string
	Name       string
	UID        string
	Controller bool
}

Owner is a controller reference. Only controller owners are followed; a plain owner reference does not imply the composition we care about.

type Status

type Status struct {
	// Workload-level. Zero values mean "not applicable to this kind".
	DesiredReplicas    int32
	ReadyReplicas      int32
	UpdatedReplicas    int32
	AvailableReplicas  int32
	Generation         int64
	ObservedGeneration int64
	Conditions         []Condition

	// Image is the primary container's image as written in the spec, which is
	// where the tag lives. ImageID is what the tag resolved to on this node,
	// which is where the digest lives: the two disagree when a mutable tag has
	// been repushed, and that disagreement is the point of the promotion view.
	Image   string
	ImageID string

	// Pod-level.
	Phase            string // Running, Pending, Succeeded, Failed
	Ready            bool
	RestartCount     int32
	WaitingReason    string // CrashLoopBackOff, ImagePullBackOff, ErrImagePull
	TerminatedReason string // OOMKilled, Error
	ProbeFailure     string // readiness or liveness message, when known

	// CronJob-level.
	Suspended        bool
	LastScheduleTime *time.Time
	LastSuccessTime  *time.Time
	ActiveJobs       int32
	LastJobFailed    bool
}

Status is the subset of a resource's status that health derivation reads.

func (*Status) Find

func (s *Status) Find(condType string) (Condition, bool)

Find returns the named condition.

Jump to

Keyboard shortcuts

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