controllers

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShellBinary = "/bin/sh"
)

Variables

View Source
var (
	//DefaultWaitGroupTimeout is the timeout value for DrainGroup
	DefaultWaitGroupTimeout = time.Second * 5

	//LaunchTemplate latest string
	LaunchTemplateVersionLatest = "$Latest"
)

Functions

func CalculateMaxUnavailable

func CalculateMaxUnavailable(batchSize intstr.IntOrString, totalNodes int) int

Types

type DiscoveredState

type DiscoveredState struct {
	*RollingUpgradeAuthenticator
	logr.Logger
	ClusterNodes        []*corev1.Node
	LaunchTemplates     []*ec2.LaunchTemplate
	ScalingGroups       []*autoscaling.Group
	InProgressInstances []string
}

func NewDiscoveredState

func NewDiscoveredState(auth *RollingUpgradeAuthenticator, logger logr.Logger) *DiscoveredState

func (*DiscoveredState) Discover

func (d *DiscoveredState) Discover() error

type DrainManager

type DrainManager struct {
	DrainErrors chan error      `json:"-"`
	DrainGroup  *sync.WaitGroup `json:"-"`
}

DrainManager holds the information to perform drain operation in parallel.

type RollingUpgradeAuthenticator

type RollingUpgradeAuthenticator struct {
	*awsprovider.AmazonClientSet
	*kubeprovider.KubernetesClientSet
}

RollingUpgradeAuthenticator has the clients for providers

type RollingUpgradeContext

type RollingUpgradeContext struct {
	logr.Logger
	ScriptRunner   ScriptRunner
	Auth           *RollingUpgradeAuthenticator
	Cloud          *DiscoveredState
	RollingUpgrade *v1alpha1.RollingUpgrade
	DrainManager   *DrainManager

	DrainTimeout        int
	IgnoreDrainFailures bool
	ReplacementNodesMap *sync.Map
	MaxReplacementNodes int
	AllowReplacements   bool
	EarlyCordonNodes    bool
	// contains filtered or unexported fields
}

func (*RollingUpgradeContext) AddNodeStepDuration

func (s *RollingUpgradeContext) AddNodeStepDuration(nsd v1alpha1.NodeStepDuration)

Add one step duration

func (*RollingUpgradeContext) ClusterBallooning

func (r *RollingUpgradeContext) ClusterBallooning(batchSize int) (bool, int)

Checks for how many replacement nodes exists across all the IGs in the cluster

func (*RollingUpgradeContext) CordonUncordonAllNodes added in v1.0.9

func (r *RollingUpgradeContext) CordonUncordonAllNodes(cordonNode bool) (bool, error)

func (*RollingUpgradeContext) DesiredNodesReady

func (r *RollingUpgradeContext) DesiredNodesReady() bool

func (*RollingUpgradeContext) DoNodeStep

func (s *RollingUpgradeContext) DoNodeStep(InProcessingNodes map[string]*v1alpha1.NodeInProcessing,
	nodeSteps map[string][]v1alpha1.NodeStepDuration, groupName, nodeName string, stepName v1alpha1.RollingUpgradeStep, endTime metav1.Time)

func (*RollingUpgradeContext) IsInstanceDrifted

func (r *RollingUpgradeContext) IsInstanceDrifted(instance *autoscaling.Instance) bool

func (*RollingUpgradeContext) IsScalingGroupDrifted

func (r *RollingUpgradeContext) IsScalingGroupDrifted() bool

func (*RollingUpgradeContext) NodeStep

func (s *RollingUpgradeContext) NodeStep(InProcessingNodes map[string]*v1alpha1.NodeInProcessing,
	nodeSteps map[string][]v1alpha1.NodeStepDuration, groupName, nodeName string, stepName v1alpha1.RollingUpgradeStep)

Node turns onto step

func (*RollingUpgradeContext) ReplaceNodeBatch

func (r *RollingUpgradeContext) ReplaceNodeBatch(batch []*autoscaling.Instance) (bool, error)

func (*RollingUpgradeContext) RotateNodes

func (r *RollingUpgradeContext) RotateNodes() error

func (*RollingUpgradeContext) SelectTargets

func (r *RollingUpgradeContext) SelectTargets(scalingGroup *autoscaling.Group, excludedInstances []string) []*autoscaling.Instance

func (*RollingUpgradeContext) SetBatchStandBy

func (r *RollingUpgradeContext) SetBatchStandBy(instanceIDs []string) error

AWS API call for setting an instance to StandBy has a limit of 19. Hence we have to call the API in batches.

func (*RollingUpgradeContext) SetProgress

func (r *RollingUpgradeContext) SetProgress(nodesProcessed int, totalNodes int)

func (*RollingUpgradeContext) ToStepDuration

func (s *RollingUpgradeContext) ToStepDuration(groupName, nodeName string, stepName v1alpha1.RollingUpgradeStep, duration time.Duration) v1alpha1.NodeStepDuration

Add one step duration

func (*RollingUpgradeContext) UpdateLastBatchNodes

func (s *RollingUpgradeContext) UpdateLastBatchNodes(batchNodes map[string]*v1alpha1.NodeInProcessing)

Update last batch nodes

func (*RollingUpgradeContext) UpdateMetricsStatus

func (s *RollingUpgradeContext) UpdateMetricsStatus(batchNodes map[string]*v1alpha1.NodeInProcessing, nodeSteps map[string][]v1alpha1.NodeStepDuration)

Update metrics status UpdateMetricsStatus

func (*RollingUpgradeContext) UpdateStatistics

func (s *RollingUpgradeContext) UpdateStatistics(nodeSteps map[string][]v1alpha1.NodeStepDuration)

Update Node Statistics

type RollingUpgradeReconciler

type RollingUpgradeReconciler struct {
	client.Client
	logr.Logger
	Scheme       *runtime.Scheme
	AdmissionMap sync.Map
	CacheConfig  *cache.Config
	EventWriter  *kubeprovider.EventWriter

	ScriptRunner        ScriptRunner
	Auth                *RollingUpgradeAuthenticator
	DrainGroupMapper    *sync.Map
	DrainErrorMapper    *sync.Map
	ClusterNodesMap     *sync.Map
	ReconcileMap        *sync.Map
	DrainTimeout        int
	IgnoreDrainFailures bool
	ReplacementNodesMap *sync.Map
	MaxReplacementNodes int
	EarlyCordonNodes    bool
	// contains filtered or unexported fields
}

RollingUpgradeReconciler reconciles a RollingUpgrade object

func (*RollingUpgradeReconciler) NodeEventsHandler

func (r *RollingUpgradeReconciler) NodeEventsHandler() predicate.Predicate

NodesEventHandler will fetch us the nodes on corresponding events, an alternative to doing explicit API calls.

func (*RollingUpgradeReconciler) Reconcile

reconcile reads that state of the cluster for a RollingUpgrade object and makes changes based on the state read and the details in the RollingUpgrade.Spec

func (*RollingUpgradeReconciler) SetMaxParallel

func (r *RollingUpgradeReconciler) SetMaxParallel(n int)

number of reconciles the upgrade-manager should handle in parallel

func (*RollingUpgradeReconciler) SetMaxReplacementNodes

func (r *RollingUpgradeReconciler) SetMaxReplacementNodes(n int)

max number of replacement nodes allowed in a cluster. This will ensure we avoid cluster ballooning.

func (*RollingUpgradeReconciler) SetupWithManager

func (r *RollingUpgradeReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*RollingUpgradeReconciler) Update

func (r *RollingUpgradeReconciler) Update(rollingUpgrade *v1alpha1.RollingUpgrade)

at the end of every reconcile, update the RollingUpgrade object

type ScriptRunner

type ScriptRunner struct {
	logr.Logger
}

func NewScriptRunner

func NewScriptRunner(logger logr.Logger) ScriptRunner

func (*ScriptRunner) PostDrain

func (r *ScriptRunner) PostDrain(target ScriptTarget) error

func (*ScriptRunner) PostTerminate

func (r *ScriptRunner) PostTerminate(target ScriptTarget) error

func (*ScriptRunner) PostWait

func (r *ScriptRunner) PostWait(target ScriptTarget) error

func (*ScriptRunner) PreDrain

func (r *ScriptRunner) PreDrain(target ScriptTarget) error

type ScriptTarget

type ScriptTarget struct {
	InstanceID    string
	NodeName      string
	UpgradeObject *v1alpha1.RollingUpgrade
}

Directories

Path Synopsis
log
providers
aws

Jump to

Keyboard shortcuts

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