Documentation ¶
Index ¶
- Constants
- func CheckEvictionSupport(clientset kubernetes.Interface) (string, error)
- func DrainNode(ctx context.Context, kubeClient kubernetes.Interface, ...) error
- func IsNodeUnreachable(node *corev1.Node) bool
- func RunCordonOrUncordon(ctx context.Context, client kubernetes.Interface, node *corev1.Node, ...) error
- func RunNodeDrain(ctx context.Context, drainer *Helper, nodeName string) error
- func UncordonNode(ctx context.Context, client kubernetes.Interface, nodeName string) error
- type CordonHelper
- type Helper
- func (d *Helper) DeleteOrEvictPods(ctx context.Context, pods []corev1.Pod) error
- func (d *Helper) DeletePod(ctx context.Context, pod corev1.Pod) error
- func (d *Helper) EvictPod(ctx context.Context, pod corev1.Pod, policyGroupVersion string) error
- func (d *Helper) GetPodsForDeletion(ctx context.Context, nodeName string) (*podDeleteList, []error)
Constants ¶
const ( // EvictionKind represents the kind of evictions object EvictionKind = "Eviction" // EvictionSubresource represents the kind of evictions object as pod's subresource EvictionSubresource = "pods/eviction" )
Variables ¶
This section is empty.
Functions ¶
func CheckEvictionSupport ¶
func CheckEvictionSupport(clientset kubernetes.Interface) (string, error)
CheckEvictionSupport uses Discovery API to find out if the server support eviction subresource If support, it will return its groupVersion; Otherwise, it will return an empty string
func DrainNode ¶
func DrainNode(ctx context.Context, kubeClient kubernetes.Interface, req apistructs.DrainNodeRequest) error
func IsNodeUnreachable ¶
IsNodeUnreachable returns true if a node is unreachable. Node is considered unreachable when its ready status is "Unknown".
func RunCordonOrUncordon ¶
func RunCordonOrUncordon(ctx context.Context, client kubernetes.Interface, node *corev1.Node, desired bool) error
RunCordonOrUncordon demonstrates the canonical way to cordon or uncordon a Node
func RunNodeDrain ¶
You should first cordon the node, e.g. using RunCordonOrUncordon
func UncordonNode ¶
Types ¶
type CordonHelper ¶
type CordonHelper struct {
// contains filtered or unexported fields
}
CordonHelper wraps functionality to cordon/uncordon nodes
func NewCordonHelper ¶
func NewCordonHelper(node *corev1.Node) *CordonHelper
NewCordonHelper returns a new CordonHelper
func (*CordonHelper) PatchOrReplace ¶
func (c *CordonHelper) PatchOrReplace(ctx context.Context, clientset kubernetes.Interface) (error, error)
PatchOrReplace uses given clientset to update the node status, either by patching or updating the given node object; it may return error if the object cannot be encoded as JSON, or if either patch or update calls fail; it will also return a second error whenever creating a patch has failed.
func (*CordonHelper) UpdateIfRequired ¶
func (c *CordonHelper) UpdateIfRequired(desired bool) bool
UpdateIfRequired returns true if c.node.Spec.Unschedulable isn't already set, or false when no change is needed.
type Helper ¶
type Helper struct { Ctx context.Context Client kubernetes.Interface Force bool GracePeriodSeconds int IgnoreAllDaemonSets bool Timeout time.Duration DeleteLocalData bool Selector string PodSelector string // DisableEviction forces drain to use delete rather than evict DisableEviction bool // SkipWaitForDeleteTimeoutSeconds ignores pods that have a // DeletionTimeStamp > N seconds. It's up to the user to decide when this // option is appropriate; examples include the Node is unready and the pods // won't drain otherwise SkipWaitForDeleteTimeoutSeconds int Out io.Writer ErrOut io.Writer DryRun bool // OnPodDeletedOrEvicted is called when a pod is evicted/deleted; for printing progress output OnPodDeletedOrEvicted func(pod *corev1.Pod, usingEviction bool) }
Helper contains the parameters to control the behaviour of drainer
func (*Helper) DeleteOrEvictPods ¶
DeleteOrEvictPods deletes or evicts the pods on the api server
func (*Helper) GetPodsForDeletion ¶
GetPodsForDeletion receives resource info for a node, and returns those pods as PodDeleteList, or error if it cannot list pods. All pods that are ready to be deleted can be obtained with .Pods(), and string with all warning can be obtained with .Warnings(), and .Errors() for all errors that occurred during deletion.