package lifecycle
import "k8s.io/kubernetes/pkg/kubelet/lifecycle"
Package lifecycle contains handlers for pod lifecycle events and interfaces to integrate with kubelet admission, synchronization, and eviction of pods.
Index ¶
- Constants
- func NewHandlerRunner(httpDoer kubetypes.HTTPDoer, commandRunner kubecontainer.CommandRunner, containerManager podStatusProvider, eventRecorder record.EventRecorder) kubecontainer.HandlerRunner
- type AdmissionFailureHandler
- type AdmissionFailureHandlerStub
- func NewAdmissionFailureHandlerStub() *AdmissionFailureHandlerStub
- func (n *AdmissionFailureHandlerStub) HandleAdmissionFailure(admitPod *v1.Pod, failureReasons []PredicateFailureReason) ([]PredicateFailureReason, error)
- type InsufficientResourceError
- func (e *InsufficientResourceError) Error() string
- func (e *InsufficientResourceError) GetInsufficientAmount() int64
- func (e *InsufficientResourceError) GetReason() string
- type PodAdmitAttributes
- type PodAdmitHandler
- func NewAppArmorAdmitHandler(validator apparmor.Validator) PodAdmitHandler
- func NewPredicateAdmitHandler(getNodeAnyWayFunc getNodeAnyWayFuncType, admissionFailureHandler AdmissionFailureHandler, pluginResourceUpdateFunc pluginResourceUpdateFuncType) PodAdmitHandler
- type PodAdmitHandlers
- type PodAdmitResult
- type PodAdmitTarget
- type PodLifecycleTarget
- type PodSyncHandler
- type PodSyncHandlers
- type PodSyncLoopHandler
- type PodSyncLoopHandlers
- type PodSyncLoopTarget
- type PodSyncTarget
- type PredicateFailureError
- type PredicateFailureReason
- type ShouldEvictResponse
Constants ¶
const ( // PodOSSelectorNodeLabelDoesNotMatch is used to denote that the pod was // rejected admission to the node because the pod's node selector // corresponding to kubernetes.io/os label didn't match the node label. PodOSSelectorNodeLabelDoesNotMatch = "PodOSSelectorNodeLabelDoesNotMatch" // PodOSNotSupported is used to denote that the pod was rejected admission // to the node because the pod's OS field didn't match the node OS. PodOSNotSupported = "PodOSNotSupported" // InvalidNodeInfo is used to denote that the pod was rejected admission // to the node because the kubelet was unable to retrieve the node info. InvalidNodeInfo = "InvalidNodeInfo" // InitContainerRestartPolicyForbidden is used to denote that the pod was // rejected admission to the node because it uses a restart policy other // than Always for some of its init containers. InitContainerRestartPolicyForbidden = "InitContainerRestartPolicyForbidden" // SupplementalGroupsPolicyNotSupported is used to denote that the pod was // rejected admission to the node because the node does not support // the pod's SupplementalGroupsPolicy. SupplementalGroupsPolicyNotSupported = "SupplementalGroupsPolicyNotSupported" // UnexpectedAdmissionError is used to denote that the pod was rejected // admission to the node because of an error during admission that could not // be categorized. UnexpectedAdmissionError = "UnexpectedAdmissionError" // UnknownReason is used to denote that the pod was rejected admission to // the node because a predicate failed for a reason that could not be // determined. UnknownReason = "UnknownReason" // UnexpectedPredicateFailureType is used to denote that the pod was // rejected admission to the node because a predicate returned a reason // object that was not an InsufficientResourceError or a PredicateFailureError. UnexpectedPredicateFailureType = "UnexpectedPredicateFailureType" // Prefix for admission reason when kubelet rejects a pod due to insufficient // resources available. InsufficientResourcePrefix = "OutOf" // These reasons are used to denote that the pod has reject admission // to the node because there's not enough resources to run the pod. OutOfCPU = "OutOfcpu" OutOfMemory = "OutOfmemory" OutOfEphemeralStorage = "OutOfephemeral-storage" OutOfPods = "OutOfpods" )
const (
AppArmorNotAdmittedReason = "AppArmor"
)
Functions ¶
func NewHandlerRunner ¶
func NewHandlerRunner(httpDoer kubetypes.HTTPDoer, commandRunner kubecontainer.CommandRunner, containerManager podStatusProvider, eventRecorder record.EventRecorder) kubecontainer.HandlerRunner
NewHandlerRunner returns a configured lifecycle handler for a container.
Types ¶
type AdmissionFailureHandler ¶
type AdmissionFailureHandler interface { HandleAdmissionFailure(admitPod *v1.Pod, failureReasons []PredicateFailureReason) ([]PredicateFailureReason, error) }
AdmissionFailureHandler is an interface which defines how to deal with a failure to admit a pod. This allows for the graceful handling of pod admission failure.
type AdmissionFailureHandlerStub ¶
type AdmissionFailureHandlerStub struct{}
AdmissionFailureHandlerStub is an AdmissionFailureHandler that does not perform any handling of admission failure. It simply passes the failure on.
func NewAdmissionFailureHandlerStub ¶
func NewAdmissionFailureHandlerStub() *AdmissionFailureHandlerStub
NewAdmissionFailureHandlerStub returns an instance of AdmissionFailureHandlerStub.
func (*AdmissionFailureHandlerStub) HandleAdmissionFailure ¶
func (n *AdmissionFailureHandlerStub) HandleAdmissionFailure(admitPod *v1.Pod, failureReasons []PredicateFailureReason) ([]PredicateFailureReason, error)
HandleAdmissionFailure simply passes admission rejection on, with no special handling.
type InsufficientResourceError ¶
type InsufficientResourceError struct { ResourceName v1.ResourceName Requested int64 Used int64 Capacity int64 }
InsufficientResourceError is an error type that indicates what kind of resource limit is hit and caused the unfitting failure.
func (*InsufficientResourceError) Error ¶
func (e *InsufficientResourceError) Error() string
func (*InsufficientResourceError) GetInsufficientAmount ¶
func (e *InsufficientResourceError) GetInsufficientAmount() int64
GetInsufficientAmount returns the amount of the insufficient resource of the error.
func (*InsufficientResourceError) GetReason ¶
func (e *InsufficientResourceError) GetReason() string
GetReason returns the reason of the InsufficientResourceError.
type PodAdmitAttributes ¶
type PodAdmitAttributes struct { // the pod to evaluate for admission Pod *v1.Pod // all pods bound to the kubelet excluding the pod being evaluated OtherPods []*v1.Pod }
PodAdmitAttributes is the context for a pod admission decision. The member fields of this struct should never be mutated.
type PodAdmitHandler ¶
type PodAdmitHandler interface { // Admit evaluates if a pod can be admitted. Admit(attrs *PodAdmitAttributes) PodAdmitResult }
PodAdmitHandler is notified during pod admission.
func NewAppArmorAdmitHandler ¶
func NewAppArmorAdmitHandler(validator apparmor.Validator) PodAdmitHandler
NewAppArmorAdmitHandler returns a PodAdmitHandler which is used to evaluate if a pod can be admitted from the perspective of AppArmor.
func NewPredicateAdmitHandler ¶
func NewPredicateAdmitHandler(getNodeAnyWayFunc getNodeAnyWayFuncType, admissionFailureHandler AdmissionFailureHandler, pluginResourceUpdateFunc pluginResourceUpdateFuncType) PodAdmitHandler
NewPredicateAdmitHandler returns a PodAdmitHandler which is used to evaluates if a pod can be admitted from the perspective of predicates.
type PodAdmitHandlers ¶
type PodAdmitHandlers []PodAdmitHandler
PodAdmitHandlers maintains a list of handlers to pod admission.
func (*PodAdmitHandlers) AddPodAdmitHandler ¶
func (handlers *PodAdmitHandlers) AddPodAdmitHandler(a PodAdmitHandler)
AddPodAdmitHandler adds the specified observer.
type PodAdmitResult ¶
type PodAdmitResult struct { // if true, the pod should be admitted. Admit bool // a brief single-word reason why the pod could not be admitted. Reason string // a brief message explaining why the pod could not be admitted. Message string }
PodAdmitResult provides the result of a pod admission decision.
type PodAdmitTarget ¶
type PodAdmitTarget interface { // AddPodAdmitHandler adds the specified handler. AddPodAdmitHandler(a PodAdmitHandler) }
PodAdmitTarget maintains a list of handlers to invoke.
type PodLifecycleTarget ¶
type PodLifecycleTarget interface { PodAdmitTarget PodSyncLoopTarget PodSyncTarget }
PodLifecycleTarget groups a set of lifecycle interfaces for convenience.
type PodSyncHandler ¶
type PodSyncHandler interface { // ShouldEvict is invoked during each sync pod operation to determine // if the pod should be evicted from the kubelet. If so, the pod status // is updated to mark its phase as failed with the provided reason and message, // and the pod is immediately killed. // This operation must return immediately as its called for each sync pod. // The provided pod should never be modified. ShouldEvict(pod *v1.Pod) ShouldEvictResponse }
PodSyncHandler is invoked during each sync pod operation.
type PodSyncHandlers ¶
type PodSyncHandlers []PodSyncHandler
PodSyncHandlers maintains a list of handlers to pod sync.
func (*PodSyncHandlers) AddPodSyncHandler ¶
func (handlers *PodSyncHandlers) AddPodSyncHandler(a PodSyncHandler)
AddPodSyncHandler adds the specified handler.
type PodSyncLoopHandler ¶
type PodSyncLoopHandler interface { // ShouldSync returns true if the pod needs to be synced. // This operation must return immediately as its called for each pod. // The provided pod should never be modified. ShouldSync(pod *v1.Pod) bool }
PodSyncLoopHandler is invoked during each sync loop iteration.
type PodSyncLoopHandlers ¶
type PodSyncLoopHandlers []PodSyncLoopHandler
PodSyncLoopHandlers maintains a list of handlers to pod sync loop.
func (*PodSyncLoopHandlers) AddPodSyncLoopHandler ¶
func (handlers *PodSyncLoopHandlers) AddPodSyncLoopHandler(a PodSyncLoopHandler)
AddPodSyncLoopHandler adds the specified observer.
type PodSyncLoopTarget ¶
type PodSyncLoopTarget interface { // AddPodSyncLoopHandler adds the specified handler. AddPodSyncLoopHandler(a PodSyncLoopHandler) }
PodSyncLoopTarget maintains a list of handlers to pod sync loop.
type PodSyncTarget ¶
type PodSyncTarget interface { // AddPodSyncHandler adds the specified handler AddPodSyncHandler(a PodSyncHandler) }
PodSyncTarget maintains a list of handlers to pod sync.
type PredicateFailureError ¶
PredicateFailureError describes a failure error of predicate.
func (*PredicateFailureError) Error ¶
func (e *PredicateFailureError) Error() string
func (*PredicateFailureError) GetReason ¶
func (e *PredicateFailureError) GetReason() string
GetReason returns the reason of the PredicateFailureError.
type PredicateFailureReason ¶
type PredicateFailureReason interface { GetReason() string }
PredicateFailureReason interface represents the failure reason of a predicate.
type ShouldEvictResponse ¶
type ShouldEvictResponse struct { // if true, the pod should be evicted. Evict bool // a brief CamelCase reason why the pod should be evicted. Reason string // a brief message why the pod should be evicted. Message string }
ShouldEvictResponse provides the result of a should evict request.
Source Files ¶
admission_failure_handler_stub.go doc.go handlers.go interfaces.go predicate.go
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 30 packages
- Last checked
- 3 hours ago –
Tools for package owners.