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 ¶
- Variables
- type KubeCmd
- func (k *KubeCmd) ApplyJoinConfig(ctx context.Context, newAttestConfig config.AttestationCfg, ...) error
- func (k *KubeCmd) BackupCRDs(ctx context.Context, upgradeDir string) ([]apiextensionsv1.CustomResourceDefinition, error)
- func (k *KubeCmd) BackupCRs(ctx context.Context, crds []apiextensionsv1.CustomResourceDefinition, ...) error
- func (k *KubeCmd) ClusterStatus(ctx context.Context) (map[string]NodeStatus, error)
- func (k *KubeCmd) ExtendClusterConfigCertSANs(ctx context.Context, alternativeNames []string) error
- func (k *KubeCmd) GetClusterAttestationConfig(ctx context.Context, variant variant.Variant) (config.AttestationCfg, error)
- func (k *KubeCmd) GetConstellationVersion(ctx context.Context) (NodeVersion, error)
- func (k *KubeCmd) RemoveAttestationConfigHelmManagement(ctx context.Context) error
- func (k *KubeCmd) RemoveHelmKeepAnnotation(ctx context.Context) error
- func (k *KubeCmd) UpgradeNodeVersion(ctx context.Context, conf *config.Config, force, skipImage, skipK8s bool) error
- type NodeStatus
- type NodeVersion
Constants ¶
This section is empty.
Variables ¶
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(outWriter io.Writer, kubeConfigPath string, fileHandler file.Handler, 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, upgradeDir string) ([]apiextensionsv1.CustomResourceDefinition, error)
BackupCRDs backs up all CRDs to the upgrade workspace.
func (*KubeCmd) BackupCRs ¶
func (k *KubeCmd) BackupCRs(ctx context.Context, crds []apiextensionsv1.CustomResourceDefinition, upgradeDir string) error
BackupCRs backs up all CRs to the upgrade workspace.
func (*KubeCmd) ClusterStatus ¶
ClusterStatus returns a map from node name to NodeStatus.
func (*KubeCmd) ExtendClusterConfigCertSANs ¶
ExtendClusterConfigCertSANs extends the ClusterConfig stored under "kube-system/kubeadm-config" with the given SANs. 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, extracts the config and returns both the full configmap and 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) RemoveAttestationConfigHelmManagement ¶
RemoveAttestationConfigHelmManagement removes labels and annotations from the join-config ConfigMap that are added by Helm. This is to ensure we can cleanly transition from Helm to Constellation's management of the ConfigMap. TODO(v2.11): Remove this function after v2.11 is released.
func (*KubeCmd) RemoveHelmKeepAnnotation ¶
RemoveHelmKeepAnnotation removes the Helm Resource Policy annotation from the join-config ConfigMap. TODO(v2.12): Remove this function after v2.12 is released.
func (*KubeCmd) UpgradeNodeVersion ¶
func (k *KubeCmd) UpgradeNodeVersion(ctx context.Context, conf *config.Config, force, skipImage, skipK8s bool) 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. TODO(elchead): AB#3434 Split K8s and image upgrade of UpgradeNodeVersion.
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.