rotator

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Index

Constants

View Source
const (
	EvictionKind        = "Eviction"
	EvictionSubresource = "pods/eviction"
)

Variables

This section is empty.

Functions

func Cordon

func Cordon(client typedcorev1.NodeInterface, node *corev1.Node) error

Cordon marks a node "Unschedulable". This method is idempotent.

func DeleteOrEvictPods

func DeleteOrEvictPods(client kubernetes.Interface, node *corev1.Node, options *DrainOptions, waitBetweenPodEvictions int) error

DeleteOrEvictPods deletes or (where supported) evicts pods from the target node and waits until the deletion/eviction completes, Timeout elapses, or an error occurs.

func DeletePod

func DeletePod(client typedcorev1.CoreV1Interface, pod corev1.Pod) error

DeletePod will delete the given pod, or return an error if it couldn't

func Drain

func Drain(client kubernetes.Interface, nodes []*corev1.Node, options *DrainOptions, waitBetweenPodEvictions int) error

func FinalCheck

func FinalCheck(autoscalingGroup *AutoscalingGroup, clientset *kubernetes.Clientset, logger *logrus.Entry) error

FinalCheck checks that rotation is complete.

func MasterNodeRotation

func MasterNodeRotation(cluster *model.Cluster, autoscalingGroup *AutoscalingGroup, clientset *kubernetes.Clientset, logger *logrus.Entry) error

MasterNodeRotation handles rotation of master nodes.

func SupportEviction

func SupportEviction(clientset kubernetes.Interface) (string, error)

SupportEviction uses Discovery API to find out if the server supports the eviction subresource. If supported, it will return its groupVersion; otherwise it will return an empty string.

func Uncordon

func Uncordon(client typedcorev1.NodeInterface, node *corev1.Node) error

Uncordon marks a node "Schedulable". This method is idempotent.

func WorkerNodeRotation

func WorkerNodeRotation(cluster *model.Cluster, autoscalingGroup *AutoscalingGroup, clientset *kubernetes.Clientset, logger *logrus.Entry) error

WorkerNodeRotation handles rotation of worker nodes.

Types

type AutoscalingGroup

type AutoscalingGroup struct {
	Name            string
	DesiredCapacity int
	Nodes           []string
}

AutoscalingGroup creates a autoscaling group object.

func (*AutoscalingGroup) DrainNodes

func (autoscalingGroup *AutoscalingGroup) DrainNodes(nodesToDrain []string, attempts, gracePeriod, wait, waitBetweenPodEvictions int, clientset *kubernetes.Clientset, logger *logrus.Entry, nodeType string) error

DrainNodes covers all node drain actions.

func (*AutoscalingGroup) SetObject

func (autoscalingGroup *AutoscalingGroup) SetObject(asg *autoscaling.Group) error

SetObject sets each AutoscalingGroup object.

type DaemonSetFilterOptions

type DaemonSetFilterOptions struct {
	// contains filtered or unexported fields
}

type DrainOptions

type DrainOptions struct {
	// Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet.
	Force bool

	// Ignore DaemonSet-managed pods.
	IgnoreDaemonsets bool

	// Period of time in seconds given to each pod to terminate
	// gracefully.  If negative, the default value specified in the pod
	// will be used.
	GracePeriodSeconds int

	// The length of time to wait before giving up on deletion or
	// eviction.  Zero means infinite.
	Timeout time.Duration

	// Continue even if there are pods using emptyDir (local data that
	// will be deleted when the node is drained).
	DeleteLocalData bool

	// Namespace to filter pods on the node.
	Namespace string

	// Label selector to filter pods on the node.
	Selector labels.Selector

	// OnPodDeletedOrEvicted is called when a pod is evicted/deleted; for printing progress output
	OnPodDeletedOrEvicted func(pod *corev1.Pod, usingEviction 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
}

type RotatorMetadata

type RotatorMetadata struct {
	MasterGroups []AutoscalingGroup `json:"MasterGroups,omitempty"`
	WorkerGroups []AutoscalingGroup `json:"WorkerGroups,omitempty"`
}

RotatorMetadata is a container struct for any metadata related to cluster rotator.

func InitRotateCluster

func InitRotateCluster(cluster *model.Cluster, rotatorMetadata *RotatorMetadata, logger *logrus.Entry) (*RotatorMetadata, error)

InitRotateCluster is used to call the RotateCluster function.

func RotateCluster

func RotateCluster(cluster *model.Cluster, logger *logrus.Entry, rotatorMetadata *RotatorMetadata) (*RotatorMetadata, error)

RotateCluster is used to rotate the Cluster nodes.

func (*RotatorMetadata) GetSetAutoscalingGroups

func (metadata *RotatorMetadata) GetSetAutoscalingGroups(cluster *model.Cluster) error

GetSetAutoscalingGroups separates master from worker Autoscaling Groups and prepares the respective objects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL