kubernetes

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: AGPL-3.0 Imports: 34 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.

View Source
var ErrLegacyJoinConfig = errors.New("legacy join-config with missing attestationConfig found")

ErrLegacyJoinConfig signals that a legacy join-config was found. TODO(daniel-weisse): v2.9 remove.

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(ctx context.Context, outWriter io.Writer, log debugLog) (*Upgrader, error)

NewUpgrader returns a new Upgrader.

func (*Upgrader) ApplyTerraformMigrations added in v2.8.0

func (u *Upgrader) ApplyTerraformMigrations(ctx context.Context, fileHandler file.Handler, opts upgrade.TerraformUpgradeOptions) error

ApplyTerraformMigrations applies the migerations planned by PlanTerraformMigrations. If PlanTerraformMigrations has not been executed before, it will return an error. In case of a successful upgrade, the output will be written to the specified file and the old Terraform directory is replaced By the new one.

func (*Upgrader) CheckTerraformMigrations added in v2.8.0

func (u *Upgrader) CheckTerraformMigrations(fileHandler file.Handler) error

CheckTerraformMigrations checks whether Terraform migrations are possible in the current workspace. If the files that will be written during the upgrade already exist, it returns an error.

func (*Upgrader) CleanUpTerraformMigrations added in v2.8.0

func (u *Upgrader) CleanUpTerraformMigrations(fileHandler file.Handler) error

CleanUpTerraformMigrations cleans up the Terraform migration workspace, for example when an upgrade is aborted by the user.

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) GetClusterAttestationConfig added in v2.8.0

func (u *Upgrader) GetClusterAttestationConfig(ctx context.Context, variant variant.Variant) (config.AttestationCfg, *corev1.ConfigMap, error)

GetClusterAttestationConfig fetches the join-config configmap from the cluster, extracts the config and returns both the full configmap and the attestation config.

func (*Upgrader) KubernetesVersion

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

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

func (*Upgrader) PlanTerraformMigrations added in v2.8.0

func (u *Upgrader) PlanTerraformMigrations(ctx context.Context, opts upgrade.TerraformUpgradeOptions) (bool, error)

PlanTerraformMigrations prepares the upgrade workspace and plans the Terraform migrations for the Constellation upgrade. If a diff exists, it's being written to the upgrader's output writer. It also returns a bool indicating whether a diff exists.

func (*Upgrader) UpdateAttestationConfig added in v2.8.0

func (u *Upgrader) UpdateAttestationConfig(ctx context.Context, newAttestConfig config.AttestationCfg) error

UpdateAttestationConfig fetches the cluster's attestation config, compares them to a new config, and updates the cluster's config if it is different from the new one.

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