Documentation
¶
Index ¶
- Constants
- Variables
- func CordonNode(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, ...) error
- func DefaultBackoff() wait.Backoff
- func DeletePod(ctx context.Context, options metav1.DeleteOptions, pod v1.Pod, ...) error
- func EvictPod(ctx context.Context, pod v1.Pod, podEvictRetryDelay time.Duration, ...) error
- func GetDrainTimeout(action *castai.ClusterAction) time.Duration
- func GetNodeByIDs(ctx context.Context, clientSet corev1client.NodeInterface, ...) (*v1.Node, error)
- func HasWildcardToleration(p *v1.Pod) bool
- func IsControlledBy(p *v1.Pod, kind string) bool
- func IsDaemonSetPod(p *v1.Pod) bool
- func IsNodeIDProviderIDValid(node *v1.Node, nodeID, providerID string) error
- func IsNonEvictible(p *v1.Pod) bool
- func IsStaticPod(p *v1.Pod) bool
- func PatchNode(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, ...) error
- func PatchNodeStatus(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, ...) error
- type Client
- type PartitionResult
- type PodActionFailure
- type PodFailedActionError
Constants ¶
const (
DefaultMaxRetriesK8SOperation = 5
)
Variables ¶
var ( ErrAction = errors.New("not valid action") ErrNodeNotFound = errors.New("node not found") ErrNodeDoesNotMatch = fmt.Errorf("node does not match") ErrProviderIDMismatch = errors.New("provider ID mismatch") ErrNodeWatcherClosed = fmt.Errorf("node watcher closed, no more events will be received") )
Functions ¶
func CordonNode ¶
func CordonNode(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, node *v1.Node) error
func DefaultBackoff ¶
func DeletePod ¶
func DeletePod(ctx context.Context, options metav1.DeleteOptions, pod v1.Pod, podDeleteRetries int, podDeleteRetryDelay time.Duration, clientset kubernetes.Interface, log logrus.FieldLogger) error
DeletePod deletes a pod from the cluster.
func EvictPod ¶
func EvictPod(ctx context.Context, pod v1.Pod, podEvictRetryDelay time.Duration, clientset kubernetes.Interface, log logrus.FieldLogger, version schema.GroupVersion) error
EvictPod evicts a pod from a k8s node.
func GetDrainTimeout ¶
func GetDrainTimeout(action *castai.ClusterAction) time.Duration
GetDrainTimeout returns drain timeout adjusted to action creation time. the result is clamped between 0s and the requested timeout.
func GetNodeByIDs ¶
func GetNodeByIDs(ctx context.Context, clientSet corev1client.NodeInterface, nodeName, nodeID, providerID string, log logrus.FieldLogger) (*v1.Node, error)
GetNodeByIDs retrieves a node by name and validates its ID and provider ID.
func HasWildcardToleration ¶ added in v0.62.1
HasWildcardToleration returns true if the pod has a toleration that matches all taints (i.e. key is empty and operator is Exists). Such pods would be rescheduled back onto a cordoned node since they tolerate the node.kubernetes.io/unschedulable taint.
func IsDaemonSetPod ¶
func IsNodeIDProviderIDValid ¶
IsNodeIDProviderIDValid checks if the node's ID and provider ID match the requested ones.
func IsNonEvictible ¶
func IsStaticPod ¶
func PatchNode ¶
func PatchNode(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, node *v1.Node, changeFn func(*v1.Node)) error
PatchNode patches a node with the given change function.
func PatchNodeStatus ¶
func PatchNodeStatus(ctx context.Context, log logrus.FieldLogger, clientset kubernetes.Interface, name string, patch []byte) error
PatchNodeStatus patches the status of a node.
Types ¶
type Client ¶
type Client interface {
PatchNode(ctx context.Context, node *v1.Node, changeFn func(*v1.Node)) error
PatchNodeStatus(ctx context.Context, name string, patch []byte) error
EvictPod(ctx context.Context, pod v1.Pod, podEvictRetryDelay time.Duration, version schema.GroupVersion) error
CordonNode(ctx context.Context, node *v1.Node) error
GetNodeByIDs(ctx context.Context, nodeName, nodeID, providerID string) (*v1.Node, error)
ExecuteBatchPodActions(
ctx context.Context,
pods []*v1.Pod,
action func(context.Context, v1.Pod) error,
actionName string,
) ([]*v1.Pod, []PodActionFailure)
DeletePod(ctx context.Context, options metav1.DeleteOptions, pod v1.Pod, podDeleteRetries int, podDeleteRetryDelay time.Duration) error
Clientset() kubernetes.Interface
Log() logrus.FieldLogger
}
func NewClient ¶
func NewClient(clientset kubernetes.Interface, log logrus.FieldLogger) Client
NewClient creates a new K8s client with the given dependencies.
type PartitionResult ¶
func PartitionPodsForEviction ¶
func PartitionPodsForEviction(pods []*v1.Pod, castNamespace string, skipDeletedTimeoutSeconds int) *PartitionResult
type PodActionFailure ¶
type PodFailedActionError ¶
type PodFailedActionError struct {
// Action holds context what was the code trying to do.
Action string
// Errors should hold an entry per pod, for which the action failed.
Errors []error
}
func (*PodFailedActionError) Error ¶
func (p *PodFailedActionError) Error() string
func (*PodFailedActionError) Unwrap ¶
func (p *PodFailedActionError) Unwrap() []error