package tainteviction
import "k8s.io/kubernetes/pkg/controller/tainteviction"
Package tainteviction contains the logic implementing taint-based eviction for Pods running on Nodes with NoExecute taints.
Index ¶
- Constants
- type Controller
- func New(ctx context.Context, c clientset.Interface, podInformer corev1informers.PodInformer, nodeInformer corev1informers.NodeInformer, controllerName string) (*Controller, error)
- func (tc *Controller) NodeUpdated(oldNode *v1.Node, newNode *v1.Node)
- func (tc *Controller) PodUpdated(oldPod *v1.Pod, newPod *v1.Pod)
- func (tc *Controller) Run(ctx context.Context)
- type GetPodsByNodeNameFunc
- type NamespacedObject
- type TimedWorker
- type TimedWorkerQueue
- func CreateWorkerQueue(f func(ctx context.Context, fireAt time.Time, args *WorkArgs) error) *TimedWorkerQueue
- func (q *TimedWorkerQueue) AddWork(ctx context.Context, args *WorkArgs, createdAt time.Time, fireAt time.Time)
- func (q *TimedWorkerQueue) CancelWork(logger klog.Logger, key string) bool
- func (q *TimedWorkerQueue) GetWorkerUnsafe(key string) *TimedWorker
- func (q *TimedWorkerQueue) UpdateWork(ctx context.Context, args *WorkArgs, createdAt time.Time, fireAt time.Time)
- type WorkArgs
Constants ¶
const ( // NodeUpdateChannelSize defines the size of channel for node update events. NodeUpdateChannelSize = 10 // UpdateWorkerSize defines the size of workers for node update or/and pod update. UpdateWorkerSize = 8 )
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller listens to Taint/Toleration changes and is responsible for removing Pods from Nodes tainted with NoExecute Taints.
func New ¶
func New(ctx context.Context, c clientset.Interface, podInformer corev1informers.PodInformer, nodeInformer corev1informers.NodeInformer, controllerName string) (*Controller, error)
New creates a new Controller that will use passed clientset to communicate with the API server.
func (*Controller) NodeUpdated ¶
func (tc *Controller) NodeUpdated(oldNode *v1.Node, newNode *v1.Node)
NodeUpdated is used to notify NoExecuteTaintManager about Node changes.
func (*Controller) PodUpdated ¶
func (tc *Controller) PodUpdated(oldPod *v1.Pod, newPod *v1.Pod)
PodUpdated is used to notify NoExecuteTaintManager about Pod changes.
func (*Controller) Run ¶
func (tc *Controller) Run(ctx context.Context)
Run starts the controller which will run in loop until `stopCh` is closed.
type GetPodsByNodeNameFunc ¶
GetPodsByNodeNameFunc returns the list of pods assigned to the specified node.
type NamespacedObject ¶
type NamespacedObject struct { types.NamespacedName UID types.UID }
NamespacedObject comprises a resource name with a mandatory namespace and optional UID. It gets rendered as "<namespace>/<name>[:<uid>]" (text output) or as an object (JSON output).
func (NamespacedObject) MarshalLog ¶
func (n NamespacedObject) MarshalLog() interface{}
MarshalLog emits a struct containing required key/value pair
func (NamespacedObject) String ¶
func (n NamespacedObject) String() string
String returns the general purpose string representation
type TimedWorker ¶
type TimedWorker struct { WorkItem *WorkArgs CreatedAt time.Time FireAt time.Time Timer clock.Timer }
TimedWorker is a responsible for executing a function no earlier than at FireAt time.
func (*TimedWorker) Cancel ¶
func (w *TimedWorker) Cancel()
Cancel cancels the execution of function by the `TimedWorker`
type TimedWorkerQueue ¶
TimedWorkerQueue keeps a set of TimedWorkers that are still wait for execution.
func CreateWorkerQueue ¶
func CreateWorkerQueue(f func(ctx context.Context, fireAt time.Time, args *WorkArgs) error) *TimedWorkerQueue
CreateWorkerQueue creates a new TimedWorkerQueue for workers that will execute given function `f`.
func (*TimedWorkerQueue) AddWork ¶
func (q *TimedWorkerQueue) AddWork(ctx context.Context, args *WorkArgs, createdAt time.Time, fireAt time.Time)
AddWork adds a work to the WorkerQueue which will be executed not earlier than `fireAt`. If replace is false, an existing work item will not get replaced, otherwise it gets canceled and the new one is added instead.
func (*TimedWorkerQueue) CancelWork ¶
func (q *TimedWorkerQueue) CancelWork(logger klog.Logger, key string) bool
CancelWork removes scheduled function execution from the queue. Returns true if work was cancelled. The key must be the same as the one returned by WorkArgs.KeyFromWorkArgs, i.e. the result of NamespacedName.String.
func (*TimedWorkerQueue) GetWorkerUnsafe ¶
func (q *TimedWorkerQueue) GetWorkerUnsafe(key string) *TimedWorker
GetWorkerUnsafe returns a TimedWorker corresponding to the given key. Unsafe method - workers have attached goroutines which can fire after this function is called.
func (*TimedWorkerQueue) UpdateWork ¶
func (q *TimedWorkerQueue) UpdateWork(ctx context.Context, args *WorkArgs, createdAt time.Time, fireAt time.Time)
UpdateWork adds or replaces a work item such that it will be executed not earlier than `fireAt`. This is a cheap no-op when the old and new fireAt are the same.
type WorkArgs ¶
type WorkArgs struct { // Object is the work item. The UID is only set if it was set when adding the work item. Object NamespacedObject }
WorkArgs keeps arguments that will be passed to the function executed by the worker.
func NewWorkArgs ¶
NewWorkArgs is a helper function to create new `WorkArgs` without a UID.
func (*WorkArgs) KeyFromWorkArgs ¶
KeyFromWorkArgs creates a key for the given `WorkArgs`.
The key is the same as the NamespacedName of the object in the work item, i.e. the UID is ignored. There cannot be two different work items with the same NamespacedName and different UIDs.
Source Files ¶
doc.go namespacedobject.go taint_eviction.go timed_workers.go
Directories ¶
Path | Synopsis |
---|---|
pkg/controller/tainteviction/metrics |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 3 hours ago –
Tools for package owners.