kubecmd

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package kubecmd provides functions to interact with a Kubernetes cluster to the CLI. The package should be used for:

  • Fetching status information about the cluster
  • Creating, deleting, or migrating resources not managed by Helm

The package should not be used for anything that doesn't just require the Kubernetes API. For example, Terraform and Helm actions should not be accessed by this package.

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

This section is empty.

Types

type KubeCmd

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

KubeCmd handles interaction with the cluster's components using the CLI.

func New

func New(kubeConfig []byte, log debugLog) (*KubeCmd, error)

New returns a new KubeCmd.

func (*KubeCmd) ApplyJoinConfig

func (k *KubeCmd) ApplyJoinConfig(ctx context.Context, newAttestConfig config.AttestationCfg, measurementSalt []byte) error

ApplyJoinConfig creates or updates the Constellation cluster's join-config ConfigMap. This ConfigMap holds the attestation config and measurement salt of the cluster. A backup of the previous attestation config is created with the suffix `_backup` in the config map data.

func (*KubeCmd) BackupCRDs

func (k *KubeCmd) BackupCRDs(ctx context.Context, fileHandler file.Handler, upgradeDir string) ([]apiextensionsv1.CustomResourceDefinition, error)

BackupCRDs backs up all CRDs to the upgrade workspace.

func (*KubeCmd) BackupCRs

func (k *KubeCmd) BackupCRs(ctx context.Context, fileHandler file.Handler, crds []apiextensionsv1.CustomResourceDefinition, upgradeDir string) error

BackupCRs backs up all CRs to the upgrade workspace.

func (*KubeCmd) ClusterStatus

func (k *KubeCmd) ClusterStatus(ctx context.Context) (map[string]NodeStatus, error)

ClusterStatus returns a map from node name to NodeStatus.

func (*KubeCmd) ExtendClusterConfigCertSANs

func (k *KubeCmd) ExtendClusterConfigCertSANs(ctx context.Context, alternativeNames []string) error

ExtendClusterConfigCertSANs extends the ClusterConfig stored under "kube-system/kubeadm-config" with the given SANs. Empty strings are ignored, existing SANs are preserved.

func (*KubeCmd) GetClusterAttestationConfig

func (k *KubeCmd) GetClusterAttestationConfig(ctx context.Context, variant variant.Variant) (config.AttestationCfg, error)

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

func (*KubeCmd) GetConstellationVersion

func (k *KubeCmd) GetConstellationVersion(ctx context.Context) (NodeVersion, error)

GetConstellationVersion retrieves the Kubernetes and image version of a Constellation cluster, as well as the Kubernetes components reference, and image reference string.

func (*KubeCmd) UpgradeKubernetesVersion

func (k *KubeCmd) UpgradeKubernetesVersion(ctx context.Context, kubernetesVersion versions.ValidK8sVersion, force bool) error

UpgradeKubernetesVersion upgrades the Kubernetes version of a Constellation cluster.

func (*KubeCmd) UpgradeNodeImage

func (k *KubeCmd) UpgradeNodeImage(ctx context.Context, imageVersion semver.Semver, imageReference string, force bool) error

UpgradeNodeImage upgrades the image version of a Constellation cluster.

type NodeStatus

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

NodeStatus bundles status information about a Kubernetes 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 NodeVersion

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

NodeVersion bundles version information of a Constellation cluster.

func NewNodeVersion

func NewNodeVersion(nodeVersion updatev1alpha1.NodeVersion) (NodeVersion, error)

NewNodeVersion returns the target versions for the cluster.

func (NodeVersion) ClusterStatus

func (n NodeVersion) ClusterStatus() string

ClusterStatus is a string describing the status of the cluster.

func (NodeVersion) ImageReference

func (n NodeVersion) ImageReference() string

ImageReference is a CSP specific path to the image.

func (NodeVersion) ImageVersion

func (n NodeVersion) ImageVersion() string

ImageVersion is the version of the image running on a node.

func (NodeVersion) KubernetesVersion

func (n NodeVersion) KubernetesVersion() string

KubernetesVersion is the Kubernetes version running on a node.

Jump to

Keyboard shortcuts

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