Documentation
¶
Overview ¶
Package kb loads and indexes the three upgrade-readiness datasets: generated API lifecycle data, the add-on EOL registry, and the hardcoded Kubernetes version-skew policy.
Index ¶
- func ChangelogURL(v inventory.Version) string
- func Horizon() (inventory.Version, error)
- func PreGA(version string) bool
- func VolumePluginNames() []string
- func VolumePluginProvisioners() map[string]string
- type APILifecycleEntry
- type BuiltinGroup
- type GVK
- type Index
- func (i Index) LaterReplacement(e APILifecycleEntry, target inventory.Version) (GVK, inventory.Version, bool)
- func (i Index) Lookup(group, version, kind string) (APILifecycleEntry, bool)
- func (i Index) ResolveReplacement(e APILifecycleEntry, target inventory.Version) (GVK, bool)
- func (i Index) ServedAlternative(e APILifecycleEntry, target inventory.Version) (GVK, bool)
- func (i Index) ServedSuccessor(e APILifecycleEntry, target inventory.Version) (APILifecycleEntry, bool)
- type KB
- type Migration
- type SkewPolicy
- type UpgradeStep
- type VolumePlugin
- type VolumePluginClass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangelogURL ¶ added in v0.2.0
ChangelogURL is the Kubernetes changelog of the minor v, where a release announces the APIs it introduces.
func Horizon ¶ added in v0.2.0
Horizon returns the newest Kubernetes minor the embedded API lifecycle dataset covers, the same value as Load().MaxKnownK8s. It reads that one field, so a command that only names the horizon in its help text does not pay for loading the whole knowledge base.
func PreGA ¶ added in v0.2.0
PreGA reports whether an API version name is alpha or beta: off by default in kube-apiserver unless enabled with --runtime-config (and, for alphas, a feature gate), so "served" for it means "can be served".
func VolumePluginNames ¶ added in v0.2.0
func VolumePluginNames() []string
VolumePluginNames lists the plugins' field names, sorted: what the collectors look for in pod volumes and PersistentVolumes.
func VolumePluginProvisioners ¶ added in v0.2.0
VolumePluginProvisioners returns a copy of the in-tree StorageClass provisioners the dataset maps, each to its plugin: what the live collector looks for in StorageClasses (#362).
Types ¶
type APILifecycleEntry ¶
type APILifecycleEntry struct {
Group string `json:"group"` // "" for core
Version string `json:"version"`
Kind string `json:"kind"`
Introduced inventory.Version `json:"introduced"`
Deprecated *inventory.Version `json:"deprecated,omitempty"`
Removed *inventory.Version `json:"removed,omitempty"`
Replacement *GVK `json:"replacement,omitempty"`
// RemovedInferred marks an entry whose Removed is no upstream lifecycle
// tag: tools/gen-kb set it to the k8s.io/api minor a deleted type
// disappeared in (when untagged, or tagged for a later removal), to the
// earlier release kube-apiserver stopped serving it in (its
// removalFixes), or to the release the Kubernetes changelog states for a
// type upstream still registers but never tagged (its untaggedLifecycles).
RemovedInferred bool `json:"removedInferred,omitempty"`
// ReplacementDefaulted marks a Replacement upstream tags nowhere:
// tools/gen-kb set it to the kind's GA version, citing the migration
// guide (which stops at v1.32) and the successor's changelog
// (ReplacementCitation).
ReplacementDefaulted bool `json:"replacementDefaulted,omitempty"`
// Migration is a hand-written note on leaving this version (what to
// change besides the apiVersion, or where to go when there is no
// successor), merged from data/migrations.json by Load. It is never in
// apilifecycle.json, which gen-kb writes whole.
Migration *Migration `json:"migration,omitempty"`
}
APILifecycleEntry describes one versioned API kind's lifecycle, as extracted from k8s.io/api generated APILifecycle* methods by tools/gen-kb.
type BuiltinGroup ¶ added in v0.2.0
type BuiltinGroup struct {
Group string `json:"group"` // "" for core
Versions []string `json:"versions"`
}
BuiltinGroup is a built-in API group (one gen-kb's scheme registers), with its versions. The engine matches on the group alone; Versions is informational.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is an O(1) lookup over lifecycle entries by group/version/kind.
func NewIndex ¶
func NewIndex(entries []APILifecycleEntry) Index
func (Index) LaterReplacement ¶ added in v0.2.0
func (i Index) LaterReplacement(e APILifecycleEntry, target inventory.Version) (GVK, inventory.Version, bool)
LaterReplacement returns, when ResolveReplacement knows no replacement target serves, the replacement e's chain reaches that a later release serves, and the release that introduces it: certificates.k8s.io/v1 ClusterTrustBundle from 1.37 for v1beta1 at 1.36. It reports false otherwise.
func (Index) Lookup ¶
func (i Index) Lookup(group, version, kind string) (APILifecycleEntry, bool)
Lookup returns the entry for group/version/kind. Group is "" for core.
func (Index) ResolveReplacement ¶ added in v0.2.0
ResolveReplacement returns the API to migrate e to for an upgrade to target, only ever one the KB knows target serves: introduced at or before it, and not removed by it. It follows the replacement chain (flowcontrol v1beta1 → v1beta3 → v1) past every hop removed at or before target. A hop introduced after target is not served yet: the newest version of the hop's group and kind that target serves and that was introduced after e is recommended instead (storage.k8s.io/v1alpha1 VolumeAttributesClass names v1, served from 1.34; at 1.33 that is v1beta1), and none when there is no such version. A hop the KB has no entry for carries no lifecycle evidence and is returned as is (the dataset tests require every shipped replacement to be a known GVK). It never names a version less mature than e's (alpha < beta < GA, from the version name, #332): a source whose GA replacement is not served yet is not sent back to an alpha or beta (LaterReplacement names the GA one). It reports false when no served replacement is known: e has no replacement, the chain dead-ends at a removed API, loops, or reaches a hop not served yet with no served alternative (LaterReplacement then names it).
func (Index) ServedAlternative ¶ added in v0.2.0
ServedAlternative returns the newest version of e's group and kind that target serves (introduced at or before it, not removed by it), other than e's own: the API to write a manifest in when e itself is not served yet (resource.k8s.io/v1 DeviceClass at 1.33 is v1beta2, v1 is served from 1.34). Newest is the latest Introduced; the same release is broken by stability (GA, then beta, then alpha) and then by the version name, so the answer does not depend on entry order. Like every remediation it is never less mature than e (#332): a v1 manifest is not sent back to a v1alpha1 the target happens to serve. When only a less mature version is served, it reports false and the caller names the release that serves e. It reports false when the KB knows no such version.
func (Index) ServedSuccessor ¶ added in v0.2.0
func (i Index) ServedSuccessor(e APILifecycleEntry, target inventory.Version) (APILifecycleEntry, bool)
ServedSuccessor returns the newest version of e's group and kind that target serves and that was introduced after e: where to move a manifest of a deprecated or removed e when its replacement chain names nothing target serves (scheduling.k8s.io/v1alpha2 Workload, removed in 1.37, moves to v1beta1, served from 1.37; coordination.k8s.io/v1alpha1 LeaseCandidate, removed in 1.32, to v1alpha2, as v1beta1 is served only from 1.33). It is never less mature than e (#332). The successor may be pre-GA (PreGA), and may itself be removed later (its Removed says). Newest, and ties, as ServedAlternative. It reports false when the KB knows no such version.
type KB ¶
type KB struct {
// Version labels the dataset in reports, the CRD status and auditor
// exports. It is derived from the embedded data (see datasetVersion),
// e.g. "k8s.io/api v0.37.1; lifecycle 1a2b3c4d; registry 5e6f7a8b".
Version string
APILifecycle []APILifecycleEntry
// BuiltinGroups lists every built-in API group, those without an
// APILifecycle entry included: the engine reports an unknown-api info
// for an object of one the lifecycle data cannot place, and stays
// silent for any other group (CRDs, aggregated APIs). Empty for a
// dataset that predates it, whose built-in groups are then those of
// APILifecycle.
BuiltinGroups []BuiltinGroup
AddOns []registry.AddOn
// Providers are the managed Kubernetes providers' support calendars
// (EKS, GKE, AKS), one per registry.ProviderIDs.
Providers []registry.ProviderSupport
Skew SkewPolicy
MaxKnownK8s inventory.Version // newest minor the lifecycle data covers
// UpgradeSteps are control-plane upgrades allowed to skip minors;
// upgrade plans take them in place of the one-minor hops they span
// (engine.HopTargets). Upstream has none, since the control plane is
// upgraded one minor at a time, and Load adds none.
UpgradeSteps []UpgradeStep
// VolumePlugins are the in-tree volume plugins that stop working, or
// need a CSI driver, at a minor (data/volumeplugins.json, #351).
VolumePlugins []VolumePlugin
}
func Load ¶
Load builds the KB from the embedded API lifecycle dataset, the embedded add-on registry, and the default skew policy. It fails loudly on a corrupt or empty dataset — a silent empty KB would mean silent green scans.
func LoadWithRegistry ¶ added in v0.2.0
LoadWithRegistry is Load with operator-supplied registry entries applied to the embedded ones (registry.LoadExtra: a file or a directory of *.yaml, validated like the embedded entries; an entry with an embedded id replaces it). extra "" is Load. A bad extra entry fails the load, naming the path and the file. The extra entries are part of the version label, so a report says which registry judged it.
type Migration ¶ added in v0.2.0
Migration is a hand-written note on moving off an API version, with the pages it comes from. The engine appends Note to the generated hint of a finding for the entry, or uses it alone when there is none, and appends Citations to the finding's.
type SkewPolicy ¶
type SkewPolicy struct {
KubeletMaxBehind int // kubelet ≤ apiserver and ≥ apiserver−3
KubectlMaxSkew int // kubectl within ±1 of apiserver
APIServerHASpread int // HA apiservers within 1 minor of each other
KubeProxyMaxBehind int // kube-proxy ≤ apiserver and ≥ apiserver−3
CtrlMgrMaxBehind int // controller-manager/scheduler ≤ apiserver, ≥ apiserver−1
}
SkewPolicy encodes the upstream Kubernetes version-skew policy (https://kubernetes.io/releases/version-skew-policy/). All values are minor-version distances relative to kube-apiserver.
Extends the shared type contract with KubeProxyMaxBehind and CtrlMgrMaxBehind — both are upstream policy rules the engine evaluates.
func DefaultSkewPolicy ¶
func DefaultSkewPolicy() SkewPolicy
DefaultSkewPolicy returns the upstream policy as of Kubernetes 1.28+ (when kubelet skew widened from n−2 to n−3).
type UpgradeStep ¶ added in v0.2.0
UpgradeStep is one control-plane upgrade from From straight to To, skipping the minors between, such as a provider's long-term-support path. Citation links the provider documentation that allows it: a step is never added without one.
type VolumePlugin ¶ added in v0.2.0
type VolumePlugin struct {
Plugin string `json:"plugin"`
Classification VolumePluginClass `json:"classification"`
Deprecated *inventory.Version `json:"deprecated,omitempty"`
// Removed is the minor whose release stopped the plugin (removed),
// or from which it works only through CSIDriver (csi-migration).
Removed *inventory.Version `json:"removed,omitempty"`
CSIDriver string `json:"csiDriver,omitempty"`
// Provisioner is the in-tree provisioner a StorageClass names for the
// plugin ("kubernetes.io/rbd"), and ProvisionerCitation the upstream
// source that names it (#362). Empty for a plugin with no in-tree
// provisioner (cephfs, gitRepo, flexVolume).
Provisioner string `json:"provisioner,omitempty"`
ProvisionerCitation string `json:"provisionerCitation,omitempty"`
Note string `json:"note,omitempty"`
Replacement string `json:"replacement"`
// Citations are the release notes and pull requests every minor
// above is taken from; never empty.
Citations []string `json:"citations"`
}
VolumePlugin is one in-tree volume plugin of data/volumeplugins.json: Plugin is its field name in a pod's volumes[] (corev1.VolumeSource) and a PersistentVolume's spec (corev1.PersistentVolumeSource), as the JSON spells it ("awsElasticBlockStore").
func VolumePlugins ¶ added in v0.2.0
func VolumePlugins() []VolumePlugin
VolumePlugins returns a copy of the embedded in-tree volume plugin dataset, sorted by plugin.
type VolumePluginClass ¶ added in v0.2.0
type VolumePluginClass string
VolumePluginClass says what an in-tree volume plugin's end does to the workloads that still name it (#351).
const ( // VolumeRemoved: the plugin was removed with no migration path (or, // gitRepo, disabled): from Removed on, a pod that names it does not // start, whatever is installed. VolumeRemoved VolumePluginClass = "removed" // VolumeCSIMigration: the in-tree code is gone (or its CSI migration // can no longer be turned off) from Removed on, but the API field still // works: every operation is redirected to CSIDriver, which must be // installed. A cluster with the driver is fine. VolumeCSIMigration VolumePluginClass = "csi-migration" // VolumeDeprecated: deprecated only; nothing stops working yet. VolumeDeprecated VolumePluginClass = "deprecated" )