podintent

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package podintent resolves and validates the bounded set of safe PodSpec mutations performed by Kubernetes admission and scheduling.

Index

Constants

View Source
const (
	// SnapshotVersion identifies the mutation rules implemented by this package.
	SnapshotVersion = "v1"
)

Variables

This section is empty.

Functions

func DigestTemplate

func DigestTemplate(template *corev1.PodTemplateSpec) (string, error)

DigestTemplate returns the canonical pre-admission identity bound into a snapshot. It applies Kubernetes API defaults and omits only the self-referential snapshot-digest annotation plus the four exact Job identity labels generated by the API server. The webhook validates those labels separately against the current Job name and UID.

func Resolve

func Resolve(
	ctx context.Context,
	reader client.Reader,
	namespace string,
	template *corev1.PodTemplateSpec,
	options Options,
) (*operatorv1alpha1.PodAdmissionSnapshot, error)

Resolve reads only credential-free Kubernetes resources and returns the immutable mutation envelope for template. It never reads Secret objects.

func ValidateActiveJob

func ValidateActiveJob(job *batchv1.Job) error

ValidateActiveJob checks the one-shot execution envelope used at Pod admission. A Job already marked for cleanup cannot start a new publication.

func ValidateGeneratedPodName

func ValidateGeneratedPodName(pod *corev1.Pod, jobName string) error

ValidateGeneratedPodName verifies the API-server name-generation chain for a Pod created by the Kubernetes Job controller. Kubernetes preserves at most 58 bytes of generateName before appending its five-byte random suffix.

func ValidatePodSpec

func ValidatePodSpec(
	actualSpec *corev1.PodSpec,
	template *corev1.PodTemplateSpec,
	snapshot *operatorv1alpha1.PodAdmissionSnapshot,
) error

ValidatePodSpec accepts only the snapshotted built-in admission mutations and scheduler-owned node assignment. Every other PodSpec field remains an exact match for the immutable Job template.

func ValidateSnapshot

func ValidateSnapshot(snapshot *operatorv1alpha1.PodAdmissionSnapshot) error

ValidateSnapshot verifies the canonical digest and structural bounds of a persisted admission snapshot without consulting current cluster resources.

func ValidateStoredPod

func ValidateStoredPod(
	pod *corev1.Pod,
	job *batchv1.Job,
	snapshot *operatorv1alpha1.PodAdmissionSnapshot,
) error

ValidateStoredPod holds a Pod to the persisted admission snapshot and exact owning Job. Controllers and result delivery use the same readback contract.

Types

type Options

type Options struct {
	DefaultTolerationsEnabled           bool
	DefaultNotReadyTolerationSeconds    int64
	DefaultUnreachableTolerationSeconds int64
	ExtendedResourceTolerationEnabled   bool
	AlwaysPullImagesEnabled             bool
}

Options binds cluster-configurable built-in admission behavior. Values must match the kube-apiserver DefaultTolerationSeconds configuration.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the upstream kube-apiserver defaults.

func (Options) Validate

func (o Options) Validate() error

Validate ensures configured admission values fit the public status bounds.

type ValidationHandler

type ValidationHandler struct {
	Reader  client.Reader
	Decoder cradmission.Decoder
}

ValidationHandler rejects an operator Pod before it can be scheduled when its final, post-mutation PodSpec falls outside the persisted admission snapshot. It reads only credential-free admission objects, Jobs, and PtahSchema status. Credential checks read Secret metadata, never Secret data.

func (*ValidationHandler) Handle

Handle implements controller-runtime admission.Handler.

Jump to

Keyboard shortcuts

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