state

package
v1.7.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SystemDStatusUnknown    = 1 << iota // systemd unit unknown
	SystemdDStatusDead                  // systemd unit dead
	SystemDStatusRestarting             // systemd unit restarting
	ComponentInstalled                  // installed (package, or direct download)
	SystemDStatusActive                 // systemd unit is activated
	SystemDStatusRunning                // systemd unit is running
	KubeletInitialized                  // kubelet config found (means node is initialized)
	PodRunning                          // pod is running
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CCMStatus added in v1.3.0

type CCMStatus struct {
	InTreeCloudProviderEnabled      bool
	InTreeCloudProviderUnregistered bool
	ExternalCCMDeployed             bool
	CSIMigrationEnabled             bool
}

type Cluster

type Cluster struct {
	ControlPlane            []Host
	StaticWorkers           []Host
	ExpectedVersion         *semver.Version
	EncryptionConfiguration *EncryptionConfiguration
	CCMClusterName          string
	CCMStatus               *CCMStatus
	Lock                    sync.Mutex
}

func (*Cluster) BrokenHosts

func (c *Cluster) BrokenHosts() []string

BrokenHosts returns a list of broken hosts that needs to be removed manually

func (*Cluster) CertsToExpireInLessThen90Days added in v1.3.0

func (c *Cluster) CertsToExpireInLessThen90Days() bool

CertsToExpireInLessThen90Days will return true if any of the control plane certificates are to be expired soon (90 days).

func (*Cluster) CustomEncryptionEnabled added in v1.3.0

func (c *Cluster) CustomEncryptionEnabled() bool

func (*Cluster) EncryptionEnabled added in v1.3.0

func (c *Cluster) EncryptionEnabled() bool

func (*Cluster) EtcdToleranceRemain

func (c *Cluster) EtcdToleranceRemain() int

EtcdToleranceRemain returns how many non-working nodes can be removed at the same time.

func (*Cluster) Healthy

func (c *Cluster) Healthy() bool

Healthy checks the cluster overall healthiness

func (*Cluster) IsProvisioned

func (c *Cluster) IsProvisioned() bool

IsProvisioned returns is the target cluster provisioned. The cluster is consider provisioned if there is at least one initialized host

func (*Cluster) SafeToDeleteHosts

func (c *Cluster) SafeToDeleteHosts() []string

func (*Cluster) SafeToRepair

func (c *Cluster) SafeToRepair(targetVersion string) (bool, string)

func (*Cluster) UpgradeNeeded

func (c *Cluster) UpgradeNeeded() (bool, error)

UpgradeNeeded compares actual and expected Kubernetes versions for control plane and static worker nodes

type ComponentStatus

type ComponentStatus struct {
	Version *semver.Version
	Status  uint64
	Name    string
}

func (*ComponentStatus) Healthy

func (cs *ComponentStatus) Healthy() bool

Healthy checks is a component running and not restarting

func (*ComponentStatus) IsProvisioned

func (cs *ComponentStatus) IsProvisioned() bool

IsProvisioned checks is a component running, installed and active

type ContainerStatus

type ContainerStatus struct {
	Status uint64
}

func (*ContainerStatus) Healthy

func (cs *ContainerStatus) Healthy() bool

Healthy checks is a pod running

type EncryptionConfiguration added in v1.3.0

type EncryptionConfiguration struct {
	Enable bool
	Config *apiserverconfigv1.EncryptionConfiguration
	Custom bool
}

type Host

type Host struct {
	Config *kubeoneapi.HostConfig

	ContainerRuntimeDocker     ComponentStatus
	ContainerRuntimeContainerd ComponentStatus
	Kubelet                    ComponentStatus

	// Applicable only for CP nodes
	APIServer ContainerStatus
	Etcd      ContainerStatus

	EarliestCertExpiry time.Time

	IsInCluster bool
	Kubeconfig  []byte
}

func (*Host) ControlPlaneHealthy

func (h *Host) ControlPlaneHealthy() bool

ControlPlaneHealthy checks is a control-plane host part of the cluster and are CRI, Kubelet, and API server healthy

func (*Host) Initialized

func (h *Host) Initialized() bool

Initialized checks is a host provisioned and is kubelet initialized

func (*Host) IsProvisioned

func (h *Host) IsProvisioned() bool

IsProvisioned checks are CRI and Kubelet provisioned on a host

func (*Host) RestConfig

func (h *Host) RestConfig() (*rest.Config, error)

RestConfig grabs Kubeconfig from a node

func (*Host) WorkerHealthy

func (h *Host) WorkerHealthy() bool

WorkerHealthy checks is a worker host part of the cluster and are CRI and Kubelet healthy

type NodeTask

type NodeTask func(ctx *State, node *kubeoneapi.HostConfig, conn executor.Interface) error

NodeTask is a task that is specifically tailored to run on a single node.

type Option added in v1.5.0

type Option func(*State)

func WithExecutorAdapter added in v1.5.0

func WithExecutorAdapter(adapter executor.Adapter) Option

type RunModeEnum

type RunModeEnum bool
const (
	RunSequentially RunModeEnum = false
	RunParallel     RunModeEnum = true
)

type State

type State struct {
	Cluster                   *kubeoneapi.KubeOneCluster
	LiveCluster               *Cluster
	Logger                    logrus.FieldLogger
	Executor                  executor.Adapter
	Configuration             *configupload.Configuration
	Images                    *images.Resolver
	Runner                    *runner.Runner
	Context                   context.Context
	WorkDir                   string
	JoinCommand               string
	JoinToken                 string
	RESTConfig                *rest.Config
	DynamicClient             dynclient.Client
	Verbose                   bool
	BackupFile                string
	DestroyWorkers            bool
	RemoveBinaries            bool
	ForceUpgrade              bool
	ForceInstall              bool
	UpgradeMachineDeployments bool
	CreateMachineDeployments  bool
	CCMMigration              bool
	CCMMigrationComplete      bool
	CredentialsFilePath       string
	ManifestFilePath          string
	PauseImage                string
}

State holds together currently test flags and parsed info, along with utilities like logger

func New

func New(ctx context.Context, opts ...Option) (*State, error)

func (*State) Clone

func (s *State) Clone() *State

Clone returns a shallow copy of the State.

func (*State) EncryptionEnabled added in v1.3.0

func (s *State) EncryptionEnabled() bool

func (*State) GetEncryptionProviderConfigName added in v1.3.0

func (s *State) GetEncryptionProviderConfigName() string

func (*State) GetKMSSocketPath added in v1.3.0

func (s *State) GetKMSSocketPath() (string, error)

func (*State) KubeadmVerboseFlag

func (s *State) KubeadmVerboseFlag() string

func (*State) RunTaskOnAllNodes

func (s *State) RunTaskOnAllNodes(task NodeTask, parallel RunModeEnum) error

RunTaskOnAllNodes runs the given task on all hosts.

func (*State) RunTaskOnControlPlane

func (s *State) RunTaskOnControlPlane(task NodeTask, parallel RunModeEnum) error

func (*State) RunTaskOnFollowers

func (s *State) RunTaskOnFollowers(task NodeTask, parallel RunModeEnum) error

RunTaskOnFollowers runs the given task on the follower hosts.

func (*State) RunTaskOnLeader

func (s *State) RunTaskOnLeader(task NodeTask) error

RunTaskOnLeader runs the given task on the leader host.

func (*State) RunTaskOnLeaderWithMutator added in v1.4.12

func (s *State) RunTaskOnLeaderWithMutator(task NodeTask, stateMutator stateMutatorFn) error

RunTaskOnLeaderWithMutator runs the given task on the leader host with a state mutator function.

func (*State) RunTaskOnNodes

func (s *State) RunTaskOnNodes(nodes []kubeoneapi.HostConfig, task NodeTask, parallel RunModeEnum, stateMutator stateMutatorFn) error

RunTaskOnNodes runs the given task on the given selection of hosts.

func (*State) RunTaskOnStaticWorkers

func (s *State) RunTaskOnStaticWorkers(task NodeTask, parallel RunModeEnum) error

func (*State) ShouldDisableEncryption added in v1.3.0

func (s *State) ShouldDisableEncryption() bool

func (*State) ShouldEnableCSIMigration added in v1.3.0

func (s *State) ShouldEnableCSIMigration() bool

ShouldEnableCSIMigration returns if CSI migration feature gates should be enabled. This function ensures we'll keep CSI migration feature gates enabled for existing clusters if they're already enabled or if we're starting the CCM/CSI migration process

func (*State) ShouldEnableEncryption added in v1.3.0

func (s *State) ShouldEnableEncryption() bool

func (*State) ShouldEnableInTreeCloudProvider added in v1.3.0

func (s *State) ShouldEnableInTreeCloudProvider() bool

ShouldEnableInTreeCloudProvider returns if in-tree cloud provider should be enabled. This function ensures we'll keep in-tree cloud provider enabled for existing clusters if it's already enabled, or disable it if we're completing the CCM/CSI migration process

func (*State) ShouldUnregisterInTreeCloudProvider added in v1.3.0

func (s *State) ShouldUnregisterInTreeCloudProvider() bool

ShouldUnregisterInTreeCloudProvider returns if the in-tree cloud provider should be unregistered. This function ensures we'll keep the in-tree cloud provider registered for existing clusters if it's already registered, or unregister it if we're completing the CCM/CSI migration process NB: We're intentionally using a dedicated function instead of reusing ShouldEnableInTreeCloudProvider because the provider should be unregistered only if we support and completed CSI migration.

Jump to

Keyboard shortcuts

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