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 ¶
- Variables
- func ClusterStatus(ctx context.Context, kubeclient kubeClient) (map[string]NodeStatus, error)
- func GetConstellationVersion(ctx context.Context, client DynamicInterface) (updatev1alpha1.NodeVersion, error)
- type DynamicInterface
- type NodeStatus
- type NodeVersionClient
- type StableInterface
- type TargetVersions
- type UpgradeCmdKind
- type Upgrader
- func (u *Upgrader) AddManualStateMigration(migration terraform.StateMigration)
- func (u *Upgrader) ApplyTerraformMigrations(ctx context.Context, fileHandler file.Handler, ...) error
- func (u *Upgrader) CheckTerraformMigrations(fileHandler file.Handler) error
- func (u *Upgrader) CleanUpTerraformMigrations(fileHandler file.Handler) error
- func (u *Upgrader) CurrentImage(ctx context.Context) (string, error)
- func (u *Upgrader) CurrentKubernetesVersion(ctx context.Context) (string, error)
- func (u *Upgrader) GetClusterAttestationConfig(ctx context.Context, variant variant.Variant) (config.AttestationCfg, *corev1.ConfigMap, error)
- func (u *Upgrader) KubernetesVersion() (string, error)
- func (u *Upgrader) PlanTerraformMigrations(ctx context.Context, opts upgrade.TerraformUpgradeOptions) (bool, error)
- func (u *Upgrader) UpdateAttestationConfig(ctx context.Context, newAttestConfig config.AttestationCfg) error
- func (u *Upgrader) UpgradeHelmServices(ctx context.Context, config *config.Config, timeout time.Duration, ...) error
- func (u *Upgrader) UpgradeNodeVersion(ctx context.Context, conf *config.Config, force bool) error
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 ¶
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 ¶
func (u *NodeVersionClient) Update(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
Update updates the NodeVersion object.
type StableInterface ¶ added in v2.9.0
type StableInterface interface {
GetCurrentConfigMap(ctx context.Context, name string) (*corev1.ConfigMap, error)
UpdateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error)
CreateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error)
KubernetesVersion() (string, error)
}
StableInterface is an interface to interact with stable resources.
func NewStableClient ¶ added in v2.9.0
func NewStableClient(client kubernetes.Interface) StableInterface
NewStableClient returns a new StableInterface.
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 UpgradeCmdKind ¶ added in v2.9.0
type UpgradeCmdKind int
UpgradeCmdKind is the kind of the upgrade command (check, apply).
const ( // UpgradeCmdKindCheck corresponds to the upgrade check command. UpgradeCmdKindCheck UpgradeCmdKind = iota // UpgradeCmdKindApply corresponds to the upgrade apply command. UpgradeCmdKindApply )
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, upgradeCmdKind UpgradeCmdKind) (*Upgrader, error)
NewUpgrader returns a new Upgrader.
func (*Upgrader) AddManualStateMigration ¶ added in v2.9.0
func (u *Upgrader) AddManualStateMigration(migration terraform.StateMigration)
AddManualStateMigration adds a manual state migration to the Terraform client. TODO(AB#3248): Remove this method after we can assume that all existing clusters have been migrated.
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
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
CleanUpTerraformMigrations cleans up the Terraform migration workspace, for example when an upgrade is aborted by the user.
func (*Upgrader) CurrentImage ¶
CurrentImage returns the currently used image version of the cluster.
func (*Upgrader) CurrentKubernetesVersion ¶
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 ¶
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, force bool) error
UpgradeHelmServices upgrade helm services.
func (*Upgrader) UpgradeNodeVersion ¶
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.