state

package
v1.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: Apache-2.0 Imports: 21 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 Cluster

type Cluster struct {
	ControlPlane            []Host
	StaticWorkers           []Host
	ExpectedVersion         *semver.Version
	EncryptionConfiguration *EncryptionConfiguration
	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 *kubeone.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 ssh.Connection) error

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

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
	Connector                 *ssh.Connector
	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
	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) (*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) RunTaskOnNodes

func (s *State) RunTaskOnNodes(nodes []kubeoneapi.HostConfig, task NodeTask, parallel RunModeEnum) 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) ShouldEnableEncryption added in v1.3.0

func (s *State) ShouldEnableEncryption() bool

Jump to

Keyboard shortcuts

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