Documentation
¶
Overview ¶
Package podintent resolves and validates the bounded set of safe PodSpec mutations performed by Kubernetes admission and scheduling.
Index ¶
- Constants
- func DigestTemplate(template *corev1.PodTemplateSpec) (string, error)
- func Resolve(ctx context.Context, reader client.Reader, namespace string, ...) (*operatorv1alpha1.PodAdmissionSnapshot, error)
- func ValidateActiveJob(job *batchv1.Job) error
- func ValidateGeneratedPodName(pod *corev1.Pod, jobName string) error
- func ValidatePodSpec(actualSpec *corev1.PodSpec, template *corev1.PodTemplateSpec, ...) error
- func ValidateSnapshot(snapshot *operatorv1alpha1.PodAdmissionSnapshot) error
- func ValidateStoredPod(pod *corev1.Pod, job *batchv1.Job, ...) error
- type Options
- type ValidationHandler
Constants ¶
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 ¶
ValidateActiveJob checks the one-shot execution envelope used at Pod admission. A Job already marked for cleanup cannot start a new publication.
func ValidateGeneratedPodName ¶
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.
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 ¶
func (h *ValidationHandler) Handle(ctx context.Context, req cradmission.Request) cradmission.Response
Handle implements controller-runtime admission.Handler.