kubeadm

package
v0.1.0-c02.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 20 Imported by: ? 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 kubeadm validates and renders provider-neutral upstream Kubernetes control-plane bootstrap, sequential HA expansion, and runtime acceptance contracts. Its planners and verifiers do not mutate a cluster.

Index

Constants

View Source
const (
	// HAWaveSchemaVersion is the versioned, provider-neutral evidence contract
	// for one-member-at-a-time kubeadm control-plane expansion.
	HAWaveSchemaVersion = "cloudring.kubeadm.ha-wave/v2"
	// HAWaveInventorySchemaVersion is the identity-bound captured topology
	// receipt consumed by VerifyHAWave.
	HAWaveInventorySchemaVersion = "cloudring.kubeadm.ha-wave-inventory/v2"

	HAWavePhaseOneToTwo   = "one-to-two"
	HAWavePhaseTwoToThree = "two-to-three"
)

Variables

View Source
var (
	// ErrInvalidBootstrapSpec marks an invalid or incomplete bootstrap input.
	ErrInvalidBootstrapSpec = errors.New("kubeadm bootstrap spec invalid")
	// ErrStandBlocked marks captured stand state which failed acceptance.
	ErrStandBlocked = errors.New("upstream stand readiness blocked")
)

Functions

func HAWaveInventoryReceiptSHA256

func HAWaveInventoryReceiptSHA256(receipt HAWaveInventoryReceipt) string

HAWaveInventoryReceiptSHA256 returns the canonical self-digest for a sanitized inventory receipt with ReceiptSHA256 excluded.

func HAWaveMemberSetSHA256

func HAWaveMemberSetSHA256(memberUIDSHA256 []string) string

HAWaveMemberSetSHA256 returns a deterministic, order-independent digest for one privacy-safe set of unique member UID hashes. Malformed or duplicate identities are rejected with an empty digest.

func HasIPv4AndIPv6Addresses

func HasIPv4AndIPv6Addresses(ipv4, ipv6 string) bool

HasIPv4AndIPv6Addresses reports whether the two inputs are respectively a valid IPv4 address and a valid IPv6 address.

func HasIPv4AndIPv6CIDRs

func HasIPv4AndIPv6CIDRs(values []string) bool

HasIPv4AndIPv6CIDRs reports whether values contain valid CIDRs from both address families.

Types

type Blocker

type Blocker struct {
	ID       string `json:"id"`
	Category string `json:"category"`
	Message  string `json:"message"`
}

Blocker identifies one failed acceptance condition.

type BootstrapBundle

type BootstrapBundle struct {
	InitYAML                    string                      `json:"initYAML"`
	ControlPlaneJoinYAML        []JoinDocument              `json:"controlPlaneJoinYAML"`
	SurviveUnavailableServers   int                         `json:"surviveUnavailableServers"`
	Actions                     []NodeAction                `json:"actions"`
	Cilium                      CiliumReadiness             `json:"cilium"`
	ServingCertificateLifecycle ServingCertificateLifecycle `json:"servingCertificateLifecycle"`
	CoreDNS                     CoreDNSExpectation          `json:"coreDNS"`
	PodDisruptionBudgets        []string                    `json:"podDisruptionBudgets"`
}

BootstrapBundle contains rendered documents and non-executing operation metadata.

func RenderStackedEtcdDualStackConfig

func RenderStackedEtcdDualStackConfig(spec BootstrapSpec) (BootstrapBundle, error)

RenderStackedEtcdDualStackConfig validates spec and returns deterministic, source-safe kubeadm documents plus an operation plan. It performs no live mutation.

type BootstrapSpec

type BootstrapSpec struct {
	ClusterName                 string                      `json:"clusterName"`
	KubernetesVersion           string                      `json:"kubernetesVersion"`
	ControlPlaneEndpoint        string                      `json:"controlPlaneEndpoint"`
	StableAPIIPv4               string                      `json:"stableAPIIPv4"`
	StableAPIIPv6               string                      `json:"stableAPIIPv6"`
	APIServingCertificateSANs   []string                    `json:"apiServingCertificateSANs"`
	ControlPlaneReplicas        int                         `json:"controlPlaneReplicas"`
	EtcdTopology                string                      `json:"etcdTopology"`
	PodCIDRs                    []string                    `json:"podCIDRs"`
	ServiceCIDRs                []string                    `json:"serviceCIDRs"`
	SurviveUnavailableServers   int                         `json:"surviveUnavailableServers"`
	CiliumVersionRef            string                      `json:"ciliumVersionRef"`
	CiliumDualStackMode         string                      `json:"ciliumDualStackMode"`
	CiliumAPIEndpoint           string                      `json:"ciliumAPIEndpoint"`
	ControlPlaneTransportDevice string                      `json:"controlPlaneTransportDevice"`
	CiliumDevices               []string                    `json:"ciliumDevices"`
	ServingCertificateLifecycle ServingCertificateLifecycle `json:"servingCertificateLifecycle"`
	ContainerRuntimeSocket      string                      `json:"containerRuntimeSocket"`
	CoreDNSMinReplicas          int                         `json:"coreDNSMinReplicas"`
	CoreDNSTopologyKey          string                      `json:"coreDNSTopologyKey"`
	RequiredPodDisruptionNames  []string                    `json:"requiredPodDisruptionNames"`
	Nodes                       []NodeSpec                  `json:"nodes"`
}

BootstrapSpec is the provider-resolved input to the deterministic renderer.

type CiliumReadiness

type CiliumReadiness struct {
	DualStack                   bool     `json:"dualStack"`
	VersionRef                  string   `json:"versionRef"`
	Mode                        string   `json:"mode"`
	APIEndpoint                 string   `json:"apiEndpoint"`
	ControlPlaneTransportDevice string   `json:"controlPlaneTransportDevice"`
	Devices                     []string `json:"devices"`
	Checks                      []string `json:"checks"`
}

CiliumReadiness captures the required API endpoint, device set, and checks.

type CoreDNSExpectation

type CoreDNSExpectation struct {
	MinReplicas int    `json:"minReplicas"`
	TopologyKey string `json:"topologyKey"`
}

CoreDNSExpectation describes the minimum replicated DNS topology.

type EvidenceInventory

type EvidenceInventory struct {
	Summary string   `json:"summary"`
	Items   []string `json:"items"`
}

EvidenceInventory records source-safe evidence identifiers and a summary.

type HAWaveBackupValidator

type HAWaveBackupValidator func(path, installationID string, now time.Time) (generatedAt time.Time, artifactSHA256 string, err error)

HAWaveBackupValidator validates a deployment-owned off-cell backup and restore barrier. It returns its generation time and exact artifact SHA-256. The public planner independently enforces freshness and wave ordering.

type HAWaveCheck

type HAWaveCheck struct {
	ID       string `json:"id"`
	Status   string `json:"status"`
	Artifact string `json:"artifact,omitempty"`
	SHA256   string `json:"sha256,omitempty"`
	Detail   string `json:"detail"`
}

HAWaveCheck is a source-safe evidence summary. Artifact contains only a basename; private paths and evidence payloads are never copied into reports.

type HAWaveCounts

type HAWaveCounts struct {
	ControlPlane int `json:"controlPlane"`
	Etcd         int `json:"etcd"`
	APIServer    int `json:"apiServer"`
}

HAWaveCounts is the sanitized healthy-member topology used by the wave planner and verifier.

func ValidateHAWaveInventoryReceipt

func ValidateHAWaveInventoryReceipt(receipt *HAWaveInventoryReceipt, now time.Time) (HAWaveCounts, error)

ValidateHAWaveInventoryReceipt validates one sanitized preflight receipt and derives healthy control-plane, etcd, and API-server counts from its bound member identity sets.

type HAWaveInventoryLoader

type HAWaveInventoryLoader func(path string, now time.Time) (receipt *HAWaveInventoryReceipt, artifactSHA256 string, err error)

HAWaveInventoryLoader loads one protected, sanitized preflight receipt. BuildHAWavePlan and VerifyHAWave independently validate its self-digest, identities, runtime policy, freshness, and installation binding.

type HAWaveInventoryReceipt

type HAWaveInventoryReceipt struct {
	SchemaVersion               string                      `json:"schemaVersion"`
	CapturedAt                  string                      `json:"capturedAt"`
	InstallationID              string                      `json:"installationId"`
	Distribution                string                      `json:"distribution"`
	Bootstrap                   string                      `json:"bootstrap"`
	ServerVersion               string                      `json:"serverVersion"`
	NodeUIDHashAlgorithm        string                      `json:"nodeUidHashAlgorithm"`
	Members                     []HAWaveMemberIdentity      `json:"members"`
	APIServerNodeUIDSHA256      []string                    `json:"apiServerNodeUidSha256"`
	OneServerLossReceiptBinding OneServerLossReceiptBinding `json:"oneServerLossReceiptBinding"`
	ReceiptSHA256               string                      `json:"receiptSha256"`
}

HAWaveInventoryReceipt is a sanitized, identity-bound preflight receipt. Counts are derived from its Ready node identities and API-server identity set; callers cannot supply counts separately to VerifyHAWave. Every Node UID hash must use kubeidentity.NodeUIDSHA256 and declare its algorithm identifier.

type HAWaveMemberIdentity

type HAWaveMemberIdentity struct {
	UIDSHA256    string `json:"uidSha256"`
	Ready        bool   `json:"ready"`
	ControlPlane bool   `json:"controlPlane"`
	EtcdMember   bool   `json:"etcdMember"`
}

HAWaveMemberIdentity carries only the hashed identity and healthy roles needed to derive wave topology. It intentionally omits names and addresses.

type HAWaveOneServerLossLoader

type HAWaveOneServerLossLoader func(path string, now time.Time) (receipt *oneserverloss.Receipt, artifactSHA256 string, err error)

HAWaveOneServerLossLoader loads a protected public one-server-loss receipt without exposing its private path or contents in the verification report. VerifyHAWave independently validates the receipt, topology, and freshness.

type HAWavePlan

type HAWavePlan struct {
	SchemaVersion                   string        `json:"schemaVersion"`
	GeneratedAt                     string        `json:"generatedAt"`
	Status                          string        `json:"status"`
	Phase                           string        `json:"phase,omitempty"`
	InstallationID                  string        `json:"installationId"`
	From                            HAWaveCounts  `json:"from"`
	Target                          HAWaveCounts  `json:"target"`
	PreflightInventoryReceiptSHA256 string        `json:"preflightInventoryReceiptSha256"`
	PreflightCapturedAt             string        `json:"preflightCapturedAt"`
	NodeUIDHashAlgorithm            string        `json:"nodeUidHashAlgorithm"`
	StartingMemberUIDSHA256         []string      `json:"startingMemberUidSha256"`
	StartingMemberSetSHA256         string        `json:"startingMemberSetSha256"`
	BackupGeneratedAt               string        `json:"backupGeneratedAt,omitempty"`
	Checks                          []HAWaveCheck `json:"checks"`
	Blockers                        []string      `json:"blockers"`
	Steps                           []string      `json:"steps,omitempty"`
	Rollback                        []string      `json:"rollback,omitempty"`
	MutationAllowed                 bool          `json:"mutationAllowed"`
	NonClaim                        string        `json:"nonClaim"`
}

HAWavePlan is a read-only, one-member expansion plan. MutationAllowed is always false; deployment-specific code owns any separately approved apply.

func BuildHAWavePlan

func BuildHAWavePlan(opts HAWavePlanOptions) HAWavePlan

BuildHAWavePlan builds a read-only 1->2 or 2->3 kubeadm HA expansion plan. A fresh preflight inventory and off-cell backup are required for every wave; 2->3 additionally requires a ready 1->2 verification, a backup newer than its completion, and a preflight captured strictly after both.

func ReadHAWavePlan

func ReadHAWavePlan(path string) (HAWavePlan, string, error)

ReadHAWavePlan strictly reads and validates one ready, read-only plan.

type HAWavePlanOptions

type HAWavePlanOptions struct {
	InstallationID string
	// Current is retained for caller compatibility and, when non-zero, must
	// match the topology derived from PreflightInventoryPath.
	Current                HAWaveCounts
	PreflightInventoryPath string
	LoadPreflightInventory HAWaveInventoryLoader
	BackupBarrierPath      string
	PreviousWavePath       string
	Now                    func() time.Time
	ValidateBackup         HAWaveBackupValidator
}

type HAWaveVerification

type HAWaveVerification struct {
	SchemaVersion                   string        `json:"schemaVersion"`
	GeneratedAt                     string        `json:"generatedAt"`
	CompletedAt                     string        `json:"completedAt"`
	Status                          string        `json:"status"`
	Phase                           string        `json:"phase,omitempty"`
	InstallationID                  string        `json:"installationId,omitempty"`
	PlanSHA256                      string        `json:"planSha256,omitempty"`
	InventoryReceiptSHA256          string        `json:"inventoryReceiptSha256,omitempty"`
	OneServerLossReceiptSHA256      string        `json:"oneServerLossReceiptSha256,omitempty"`
	PreflightInventoryReceiptSHA256 string        `json:"preflightInventoryReceiptSha256,omitempty"`
	NodeUIDHashAlgorithm            string        `json:"nodeUidHashAlgorithm,omitempty"`
	StartingMemberUIDSHA256         []string      `json:"startingMemberUidSha256"`
	StartingMemberSetSHA256         string        `json:"startingMemberSetSha256,omitempty"`
	FinalMemberUIDSHA256            []string      `json:"finalMemberUidSha256"`
	FinalMemberSetSHA256            string        `json:"finalMemberSetSha256,omitempty"`
	IntroducedMemberUIDSHA256       string        `json:"introducedMemberUidSha256,omitempty"`
	Observed                        HAWaveCounts  `json:"observed"`
	FreshBackupVerified             bool          `json:"freshBackupVerified"`
	PreviousWaveVerified            bool          `json:"previousWaveVerified"`
	FinalOneServerLossVerified      bool          `json:"finalOneServerLossVerified"`
	Checks                          []HAWaveCheck `json:"checks"`
	Blockers                        []string      `json:"blockers"`
	MutationAttempted               bool          `json:"mutationAttempted"`
	NonClaim                        string        `json:"nonClaim"`
}

HAWaveVerification is the sanitized read-only result for one completed expansion phase.

func ReadHAWaveVerification

func ReadHAWaveVerification(path string) (HAWaveVerification, string, error)

ReadHAWaveVerification strictly reads and validates one ready, read-only wave verification.

func VerifyHAWave

func VerifyHAWave(opts HAWaveVerifyOptions) HAWaveVerification

VerifyHAWave reopens one exact plan and backup barrier, then derives healthy member counts from an identity-bound inventory receipt. It never performs or authorizes a mutation. Final one-server-loss evidence is forbidden at two members and mandatory after the three-member target is observed.

type HAWaveVerifyOptions

type HAWaveVerifyOptions struct {
	PlanPath                 string
	BackupBarrierPath        string
	ValidateBackup           HAWaveBackupValidator
	InventoryPath            string
	LoadInventory            HAWaveInventoryLoader
	FinalOneServerLossPath   string
	Now                      func() time.Time
	LoadOneServerLossReceipt HAWaveOneServerLossLoader
}

type JoinDocument

type JoinDocument struct {
	NodeName string `json:"nodeName"`
	YAML     string `json:"yaml"`
}

JoinDocument binds one node name to its source-safe join configuration.

type NodeAction

type NodeAction struct {
	Name                   string   `json:"name"`
	Description            string   `json:"description"`
	Operation              string   `json:"operation"`
	Nodes                  []string `json:"nodes"`
	ReadOnlyPlanned        bool     `json:"readOnlyPlanned"`
	Evidence               string   `json:"evidence"`
	ReconfigurationPlanRef string   `json:"reconfigurationPlanRef,omitempty"`
	RollbackPlanRef        string   `json:"rollbackPlanRef,omitempty"`
	AcceptancePlanRef      string   `json:"acceptancePlanRef,omitempty"`
}

NodeAction describes an ordered operation without executing it.

type NodeInventory

type NodeInventory struct {
	Name         string `json:"name"`
	UIDSHA256    string `json:"uidSha256"`
	Ready        bool   `json:"ready"`
	ControlPlane bool   `json:"controlPlane"`
	EtcdMember   bool   `json:"etcdMember"`
	NodeIPv4     string `json:"nodeIPv4"`
	NodeIPv6     string `json:"nodeIPv6"`
}

NodeInventory is sanitized observed state for one control-plane node.

type NodeSpec

type NodeSpec struct {
	Name          string            `json:"name"`
	AdvertiseIPv4 string            `json:"advertiseIPv4"`
	AdvertiseIPv6 string            `json:"advertiseIPv6"`
	Roles         []string          `json:"roles,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
	Taints        []string          `json:"taints,omitempty"`
}

NodeSpec describes one control-plane node without credentials.

type OneServerLossReceiptBinding

type OneServerLossReceiptBinding struct {
	ReceiptSHA256               string `json:"receiptSha256"`
	RunNonceSHA256              string `json:"runNonceSha256"`
	TargetNodeUIDSHA256         string `json:"targetNodeUidSha256"`
	KubectlExecutableSHA256     string `json:"kubectlExecutableSha256"`
	ProbeAdapterSHA256          string `json:"probeAdapterSha256"`
	NodeUIDHashAlgorithm        string `json:"nodeUidHashAlgorithm,omitempty"`
	ControlPlaneMemberSetSHA256 string `json:"controlPlaneMemberSetSha256,omitempty"`
}

OneServerLossReceiptBinding binds the stand inventory to one exact, independently validated resilience receipt and, when supplied, its complete privacy-safe control-plane member set without embedding the receipt in the sanitized stand report.

type ServingCertificateLifecycle

type ServingCertificateLifecycle struct {
	RolloutStrategy            string `json:"rolloutStrategy"`
	ReconfigurationPlanRef     string `json:"reconfigurationPlanRef"`
	RollbackPlanRef            string `json:"rollbackPlanRef"`
	OneServerLossAcceptanceRef string `json:"oneServerLossAcceptanceRef"`
}

ServingCertificateLifecycle binds sequential certificate maintenance to rollback and one-server-loss acceptance workflows.

type StandInventory

type StandInventory struct {
	Distribution              string   `json:"distribution"`
	Bootstrap                 string   `json:"bootstrap"`
	ServerVersion             string   `json:"serverVersion"`
	ControlPlaneEndpoint      string   `json:"controlPlaneEndpoint"`
	StableAPIIPv4             string   `json:"stableAPIIPv4"`
	StableAPIIPv6             string   `json:"stableAPIIPv6"`
	APIServingCertificateSANs []string `json:"apiServingCertificateSANs"`
	ControlPlaneReplicas      int      `json:"controlPlaneReplicas"`
	EtcdTopology              string   `json:"etcdTopology"`
	PodCIDRs                  []string `json:"podCIDRs"`
	ServiceCIDRs              []string `json:"serviceCIDRs"`
	// SurviveUnavailableServers is a deprecated input-only compatibility field.
	// VerifyUpstreamStand ignores it and strips it from Observed; only
	// VerifiedSurviveUnavailableServers carries verified evidence.
	SurviveUnavailableServers              int                         `json:"surviveUnavailableServers,omitempty"`
	OneServerLossReceipt                   OneServerLossReceiptBinding `json:"oneServerLossReceipt"`
	CiliumDualStackReady                   bool                        `json:"ciliumDualStackReady"`
	CiliumAPIEndpoint                      string                      `json:"ciliumAPIEndpoint"`
	ControlPlaneTransportDevice            string                      `json:"controlPlaneTransportDevice"`
	CiliumDevices                          []string                    `json:"ciliumDevices"`
	ServingCertificateRolloutStrategy      string                      `json:"servingCertificateRolloutStrategy"`
	ServingCertificateReconfigurationReady bool                        `json:"servingCertificateReconfigurationReady"`
	ServingCertificateRollbackReady        bool                        `json:"servingCertificateRollbackReady"`
	ControlPlaneAPIFailoverReady           bool                        `json:"controlPlaneAPIFailoverReady"`
	CoreDNSMinReplicas                     int                         `json:"coreDNSMinReplicas"`
	CoreDNSSpreadReady                     bool                        `json:"coreDNSSpreadReady"`
	PodDisruptionBudgetsReady              bool                        `json:"podDisruptionBudgetsReady"`
	Nodes                                  []NodeInventory             `json:"nodes"`
	WorkflowContinuity                     EvidenceInventory           `json:"workflowContinuity"`
	DataDurability                         EvidenceInventory           `json:"dataDurability"`
	SinglePointOfFailure                   EvidenceInventory           `json:"singlePointOfFailure"`
}

StandInventory is sanitized observed state consumed by the independent verifier.

type StandReport

type StandReport struct {
	Status                            string            `json:"status"`
	VerifiedSurviveUnavailableServers int               `json:"verifiedSurviveUnavailableServers"`
	Blockers                          []Blocker         `json:"blockers,omitempty"`
	WorkflowContinuity                EvidenceInventory `json:"workflowContinuity"`
	DataDurability                    EvidenceInventory `json:"dataDurability"`
	SinglePointOfFailure              EvidenceInventory `json:"singlePointOfFailure"`
	Observed                          StandInventory    `json:"observed"`
}

StandReport is the fail-closed verification result.

func VerifyUpstreamStand

func VerifyUpstreamStand(inventory StandInventory, receipts ...*oneserverloss.Receipt) (StandReport, error)

VerifyUpstreamStand independently evaluates sanitized observed state against the upstream Kubernetes HA contract.

Jump to

Keyboard shortcuts

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