kubernetes

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package kubernetes provides functions to interact with a live cluster to the CLI.

Currently it is used to implement the status and upgrade commands.

Index

Constants

This section is empty.

Variables

View Source
var ErrInProgress = errors.New("upgrade in progress")

ErrInProgress signals that an upgrade is in progress inside the cluster.

Functions

func ClusterStatus

func ClusterStatus(ctx context.Context, kubeclient kubeClient) (map[string]NodeStatus, error)

ClusterStatus returns a map from node name to NodeStatus.

func GetConstellationVersion

func GetConstellationVersion(ctx context.Context, client DynamicInterface) (updatev1alpha1.NodeVersion, error)

GetConstellationVersion queries the constellation-version object for a given field.

Types

type DynamicInterface

type DynamicInterface interface {
	GetCurrent(ctx context.Context, name string) (*unstructured.Unstructured, error)
	Update(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
}

DynamicInterface is a general interface to query custom resources.

type NodeStatus

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

NodeStatus bundles status information about a node.

func NewNodeStatus

func NewNodeStatus(node corev1.Node) NodeStatus

NewNodeStatus returns a new NodeStatus.

func (*NodeStatus) ImageVersion

func (n *NodeStatus) ImageVersion() string

ImageVersion returns the node image of the node.

func (*NodeStatus) KubeletVersion

func (n *NodeStatus) KubeletVersion() string

KubeletVersion returns the kubelet version of the node.

type NodeVersionClient

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

NodeVersionClient implements the DynamicInterface interface to interact with NodeVersion objects.

func NewNodeVersionClient

func NewNodeVersionClient(client dynamic.Interface) *NodeVersionClient

NewNodeVersionClient returns a new NodeVersionClient.

func (*NodeVersionClient) GetCurrent

func (u *NodeVersionClient) GetCurrent(ctx context.Context, name string) (*unstructured.Unstructured, error)

GetCurrent returns the current NodeVersion object.

func (*NodeVersionClient) Update

Update updates the NodeVersion object.

type TargetVersions

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

TargetVersions bundles version information about the target versions of a cluster.

func NewTargetVersions

func NewTargetVersions(nodeVersion updatev1alpha1.NodeVersion) (TargetVersions, error)

NewTargetVersions returns the target versions for the cluster.

func (*TargetVersions) Image

func (c *TargetVersions) Image() string

Image return the image version.

func (*TargetVersions) ImagePath

func (c *TargetVersions) ImagePath() string

ImagePath return the image path.

func (*TargetVersions) Kubernetes

func (c *TargetVersions) Kubernetes() string

Kubernetes return the Kubernetes version.

type Upgrader

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

Upgrader handles upgrading the cluster's components using the CLI.

func NewUpgrader

func NewUpgrader(outWriter io.Writer, log debugLog) (*Upgrader, error)

NewUpgrader returns a new Upgrader.

func (*Upgrader) CurrentImage

func (u *Upgrader) CurrentImage(ctx context.Context) (string, error)

CurrentImage returns the currently used image version of the cluster.

func (*Upgrader) CurrentKubernetesVersion

func (u *Upgrader) CurrentKubernetesVersion(ctx context.Context) (string, error)

CurrentKubernetesVersion returns the currently used Kubernetes version.

func (*Upgrader) GetClusterMeasurements

func (u *Upgrader) GetClusterMeasurements(ctx context.Context) (measurements.M, *corev1.ConfigMap, error)

GetClusterMeasurements fetches the join-config configmap from the cluster, extracts the measurements and returns both the full configmap and the measurements.

func (*Upgrader) KubernetesVersion

func (u *Upgrader) KubernetesVersion() (string, error)

KubernetesVersion returns the version of Kubernetes the Constellation is currently running on.

func (*Upgrader) UpdateMeasurements

func (u *Upgrader) UpdateMeasurements(ctx context.Context, newMeasurements measurements.M) error

UpdateMeasurements fetches the cluster's measurements, compares them to a set of new measurements and updates the cluster's measurements if they are different from the new ones.

func (*Upgrader) UpgradeHelmServices

func (u *Upgrader) UpgradeHelmServices(ctx context.Context, config *config.Config, timeout time.Duration, allowDestructive bool) error

UpgradeHelmServices upgrade helm services.

func (*Upgrader) UpgradeNodeVersion

func (u *Upgrader) UpgradeNodeVersion(ctx context.Context, conf *config.Config) error

UpgradeNodeVersion upgrades the cluster's NodeVersion object and in turn triggers image & k8s version upgrades. The versions set in the config are validated against the versions running in the cluster.

Jump to

Keyboard shortcuts

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