internal

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = klogr.New()

Log is the global logger for the internal package.

Functions

func ControlPlaneLabelsForCluster

func ControlPlaneLabelsForCluster(clusterName, controlPlaneName string) map[string]string

ControlPlaneLabelsForCluster returns a set of labels to add to a control plane machine for this specific cluster.

func ControlPlaneLabelsForClusterWithHash

func ControlPlaneLabelsForClusterWithHash(clusterName, controlPlaneName string, hash string) map[string]string

ControlPlaneLabelsForClusterWithHash returns a set of labels to add to a control plane machine for this specific cluster and configuration hash

func ControlPlaneSelectorForCluster

func ControlPlaneSelectorForCluster(clusterName, controlPlaneName string) *metav1.LabelSelector

ControlPlaneSelectorForCluster returns the label selector necessary to get control plane machines for a given cluster.

func PickFewest

func PickFewest(failureDomains clusterv1.FailureDomains, machines FilterableMachineCollection) *string

PickFewest returns the failure domain with the fewest number of machines.

func PickMost

func PickMost(c *ControlPlane, machines FilterableMachineCollection) *string

PickMost returns a failure domain that is in machines and has most control-plane machines on.

func PickNFewest added in v0.4.2

func PickNFewest(failureDomains clusterv1.FailureDomains, machines FilterableMachineCollection, n int) []*string

PickNFewest returns N failure domains with the fewest number of machines.

Types

type ClusterStatus

type ClusterStatus struct {
	// Nodes are a total count of nodes
	Nodes int32
	// ReadyNodes are the count of nodes that are reporting ready
	ReadyNodes int32
}

ClusterStatus holds stats information about the cluster.

type ControlPlane

type ControlPlane struct {
	CCP      *controlplanev1.CritControlPlane
	Cluster  *clusterv1.Cluster
	Machines FilterableMachineCollection
	Client   ctrlclient.Client
	// contains filtered or unexported fields
}

ControlPlane holds business logic around control planes. It should never need to connect to a service, that responsibility lies outside of this struct.

func NewControlPlane

func NewControlPlane(cluster *clusterv1.Cluster, ccp *controlplanev1.CritControlPlane, ownedMachines FilterableMachineCollection, ctx context.Context, client ctrlclient.Client) *ControlPlane

NewControlPlane returns an instantiated ControlPlane.

func (*ControlPlane) AsOwnerReference

func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference

AsOwnerReference returns an owner reference to the CritControlPlane.

func (*ControlPlane) EnsureOwnership

func (c *ControlPlane) EnsureOwnership() error

func (*ControlPlane) FailureDomainWithFewestMachines

func (c *ControlPlane) FailureDomainWithFewestMachines() *string

FailureDomainWithFewestMachines returns the failure domain with the fewest number of machines. Used when scaling up.

func (*ControlPlane) FailureDomainWithMostMachines

func (c *ControlPlane) FailureDomainWithMostMachines(machines FilterableMachineCollection) *string

FailureDomainWithMostMachines returns a fd which exists both in machines and control-plane machines and has the most control-plane machines on it.

func (*ControlPlane) FailureDomains

func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains

FailureDomains returns a slice of failure domain objects synced from the infrastructure provider into Cluster.Status.

func (*ControlPlane) GenerateCritConfig

func (c *ControlPlane) GenerateCritConfig(spec *bootstrapv1.CritConfigSpec) *bootstrapv1.CritConfig

GenerateCritConfig generates a new crit config for creating new control plane nodes.

func (*ControlPlane) HasDeletingMachine

func (c *ControlPlane) HasDeletingMachine() bool

HasDeletingMachine returns true if any machine in the control plane is in the process of being deleted.

func (*ControlPlane) InfrastructureTemplate

func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference

InfrastructureTemplate returns the CritControlPlane's infrastructure template.

func (*ControlPlane) Logger

func (c *ControlPlane) Logger() logr.Logger

Logger returns a logger with useful context.

func (*ControlPlane) MachineInFailureDomainWithMostMachines

func (c *ControlPlane) MachineInFailureDomainWithMostMachines(machines FilterableMachineCollection) (*clusterv1.Machine, error)

MachineInFailureDomainWithMostMachines returns the first matching failure domain with machines that has the most control-plane machines on it.

func (*ControlPlane) MachinesNeedingUpgrade

func (c *ControlPlane) MachinesNeedingUpgrade() FilterableMachineCollection

MachinesNeedingUpgrade return a list of machines that need to be upgraded.

func (*ControlPlane) NFailureDomainsWithFewestMachines added in v0.4.2

func (c *ControlPlane) NFailureDomainsWithFewestMachines(replicas int) []*string

NFailureDomainWithFewestMachines returns N failure domains with the fewest number of machines. Used to distribute control plane replicas over several failure domains

func (*ControlPlane) NewMachine

func (c *ControlPlane) NewMachine(infraRef, bootstrapRef *corev1.ObjectReference, failureDomain *string) *clusterv1.Machine

NewMachine returns a machine configured to be a part of the control plane.

func (*ControlPlane) SpecHash

func (c *ControlPlane) SpecHash() string

SpecHash returns the hash of the CritControlPlane spec.

func (*ControlPlane) Version

func (c *ControlPlane) Version() *string

Version returns the CritControlPlane's version.

type FilterableMachineCollection

type FilterableMachineCollection map[string]*clusterv1.Machine

FilterableMachineCollection is a set of Machines

func NewFilterableMachineCollection

func NewFilterableMachineCollection(machines ...*clusterv1.Machine) FilterableMachineCollection

NewFilterableMachineCollection creates a FilterableMachineCollection from a list of values.

func NewFilterableMachineCollectionFromMachineList

func NewFilterableMachineCollectionFromMachineList(machineList *clusterv1.MachineList) FilterableMachineCollection

NewFilterableMachineCollectionFromMachineList creates a FilterableMachineCollection from the given MachineList

func (FilterableMachineCollection) AnyFilter

AnyFilter returns a FilterableMachineCollection containing only the Machines that match any of the given MachineFilters

func (FilterableMachineCollection) DeepCopy

DeepCopy returns a deep copy

func (FilterableMachineCollection) Filter

Filter returns a FilterableMachineCollection containing only the Machines that match all of the given MachineFilters

func (FilterableMachineCollection) Insert

Insert adds items to the set.

func (FilterableMachineCollection) Len

Len returns the size of the set.

func (FilterableMachineCollection) Newest

Newest returns the Machine with the most recent CreationTimestamp

func (FilterableMachineCollection) Oldest

Oldest returns the Machine with the oldest CreationTimestamp

func (FilterableMachineCollection) SortedByCreationTimestamp

func (s FilterableMachineCollection) SortedByCreationTimestamp() []*clusterv1.Machine

SortedByCreationTimestamp returns the machines sorted by creation timestamp

type HealthCheckResult

type HealthCheckResult map[string]error

HealthCheckResult maps nodes that are checked to any errors the node has related to the check.

type Management

type Management struct {
	Client ctrlclient.Reader
}

Management holds operations on the management cluster.

func (*Management) GetMachinesForCluster

func (m *Management) GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error)

GetMachinesForCluster returns a list of machines that can be filtered or not. If no filter is supplied then all machines associated with the target cluster are returned.

func (*Management) GetWorkloadCluster

func (m *Management) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error)

GetWorkloadCluster builds a cluster object. The cluster comes with an etcd client generator to connect to any etcd pod living on a managed machine.

func (*Management) TargetClusterControlPlaneIsHealthy

func (m *Management) TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey client.ObjectKey, controlPlaneName string) error

TargetClusterControlPlaneIsHealthy checks every node for control plane health.

type ManagementCluster

type ManagementCluster interface {
	GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error)
	TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey client.ObjectKey, controlPlaneName string) error
	GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error)
}

ManagementCluster defines all behaviors necessary for something to function as a management cluster.

type Workload

type Workload struct {
	Client ctrlclient.Client
	// contains filtered or unexported fields
}

Workload defines operations on workload clusters.

func (*Workload) ClusterStatus

func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error)

ClusterStatus returns the status of the cluster.

func (*Workload) ControlPlaneIsHealthy

func (w *Workload) ControlPlaneIsHealthy(ctx context.Context) (HealthCheckResult, error)

controlPlaneIsHealthy does a best effort check of the control plane components the kubeadm control plane cares about. The return map is a map of node names as keys to error that that node encountered. All nodes will exist in the map with nil errors if there were no errors for that node.

type WorkloadCluster

type WorkloadCluster interface {
	// Basic health and status checks.
	ClusterStatus(ctx context.Context) (ClusterStatus, error)
	ControlPlaneIsHealthy(ctx context.Context) (HealthCheckResult, error)
}

WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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