2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-03-30 10:13:14 -04:00
|
|
|
package kubernetes
|
2022-08-29 10:49:44 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
2023-05-22 07:31:20 -04:00
|
|
|
"path/filepath"
|
2023-07-21 10:43:51 -04:00
|
|
|
"sort"
|
2023-06-05 03:13:02 -04:00
|
|
|
"strings"
|
2022-12-19 10:52:15 -05:00
|
|
|
"time"
|
2022-08-29 10:49:44 -04:00
|
|
|
|
2023-07-24 04:30:53 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/cli/internal/clusterid"
|
2022-11-24 10:39:33 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/cli/internal/helm"
|
2023-05-22 07:31:20 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/cli/internal/terraform"
|
|
|
|
"github.com/edgelesssys/constellation/v2/cli/internal/upgrade"
|
2023-06-07 10:16:32 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
2023-06-09 09:41:02 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
2023-05-23 03:17:27 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
2023-02-09 09:54:12 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/compatibility"
|
2022-12-19 10:52:15 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
2023-05-22 07:31:20 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
2023-05-23 03:17:27 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/imagefetcher"
|
2023-02-09 09:54:12 -05:00
|
|
|
internalk8s "github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
2022-12-19 02:08:46 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/kubernetes/kubectl"
|
2023-03-03 03:38:23 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
2023-02-09 09:54:12 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
|
|
|
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/api/v1alpha1"
|
2023-06-21 03:22:32 -04:00
|
|
|
"github.com/google/uuid"
|
2022-08-29 10:49:44 -04:00
|
|
|
corev1 "k8s.io/api/core/v1"
|
2023-02-09 09:54:12 -05:00
|
|
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
2022-08-29 10:49:44 -04:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
2023-02-09 09:54:12 -05:00
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
2022-08-29 10:49:44 -04:00
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
|
|
"k8s.io/client-go/dynamic"
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
|
|
"k8s.io/client-go/tools/clientcmd"
|
2023-07-24 06:15:11 -04:00
|
|
|
"k8s.io/client-go/util/retry"
|
2023-07-21 10:43:51 -04:00
|
|
|
kubeadmv1beta3 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
|
|
|
"sigs.k8s.io/yaml"
|
2022-08-29 10:49:44 -04:00
|
|
|
)
|
|
|
|
|
2023-06-21 03:22:32 -04:00
|
|
|
// UpgradeCmdKind is the kind of the upgrade command (check, apply).
|
|
|
|
type UpgradeCmdKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// UpgradeCmdKindCheck corresponds to the upgrade check command.
|
|
|
|
UpgradeCmdKindCheck UpgradeCmdKind = iota
|
|
|
|
// UpgradeCmdKindApply corresponds to the upgrade apply command.
|
|
|
|
UpgradeCmdKindApply
|
|
|
|
)
|
|
|
|
|
2023-02-09 09:54:12 -05:00
|
|
|
// ErrInProgress signals that an upgrade is in progress inside the cluster.
|
|
|
|
var ErrInProgress = errors.New("upgrade in progress")
|
|
|
|
|
2023-03-24 06:51:18 -04:00
|
|
|
// GetConstellationVersion queries the constellation-version object for a given field.
|
|
|
|
func GetConstellationVersion(ctx context.Context, client DynamicInterface) (updatev1alpha1.NodeVersion, error) {
|
|
|
|
raw, err := client.GetCurrent(ctx, "constellation-version")
|
|
|
|
if err != nil {
|
|
|
|
return updatev1alpha1.NodeVersion{}, err
|
|
|
|
}
|
|
|
|
var nodeVersion updatev1alpha1.NodeVersion
|
|
|
|
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(raw.UnstructuredContent(), &nodeVersion); err != nil {
|
|
|
|
return updatev1alpha1.NodeVersion{}, fmt.Errorf("converting unstructured to NodeVersion: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodeVersion, nil
|
|
|
|
}
|
|
|
|
|
2023-04-13 09:58:37 -04:00
|
|
|
// InvalidUpgradeError present an invalid upgrade. It wraps the source and destination version for improved debuggability.
|
|
|
|
type applyError struct {
|
|
|
|
expected string
|
|
|
|
actual string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error returns the String representation of this error.
|
|
|
|
func (e *applyError) Error() string {
|
|
|
|
return fmt.Sprintf("expected NodeVersion to contain %s, got %s", e.expected, e.actual)
|
|
|
|
}
|
|
|
|
|
2022-08-29 10:49:44 -04:00
|
|
|
// Upgrader handles upgrading the cluster's components using the CLI.
|
|
|
|
type Upgrader struct {
|
2023-07-07 11:02:01 -04:00
|
|
|
stableInterface StableInterface
|
2023-03-24 06:51:18 -04:00
|
|
|
dynamicInterface DynamicInterface
|
2022-11-24 10:39:33 -05:00
|
|
|
helmClient helmInterface
|
2023-03-03 03:38:23 -05:00
|
|
|
imageFetcher imageFetcher
|
|
|
|
outWriter io.Writer
|
2023-06-27 07:12:50 -04:00
|
|
|
// TODO(AB#3248): Remove this tfClient after we can assume that all existing clusters have been migrated.
|
|
|
|
tfClient *terraform.Client
|
|
|
|
tfUpgrader *upgrade.TerraformUpgrader
|
|
|
|
log debugLog
|
|
|
|
upgradeID string
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewUpgrader returns a new Upgrader.
|
2023-07-18 03:33:42 -04:00
|
|
|
func NewUpgrader(ctx context.Context, outWriter io.Writer, fileHandler file.Handler, log debugLog, upgradeCmdKind UpgradeCmdKind) (*Upgrader, error) {
|
2023-06-21 03:22:32 -04:00
|
|
|
upgradeID := "upgrade-" + time.Now().Format("20060102150405") + "-" + strings.Split(uuid.New().String(), "-")[0]
|
|
|
|
if upgradeCmdKind == UpgradeCmdKindCheck {
|
|
|
|
// When performing an upgrade check, the upgrade directory will only be used temporarily to store the
|
|
|
|
// Terraform state. The directory is deleted after the check is finished.
|
|
|
|
// Therefore, add a tmp-suffix to the upgrade ID to indicate that the directory will be cleared after the check.
|
|
|
|
upgradeID += "-tmp"
|
|
|
|
}
|
|
|
|
|
|
|
|
u := &Upgrader{
|
|
|
|
imageFetcher: imagefetcher.New(),
|
|
|
|
outWriter: outWriter,
|
|
|
|
log: log,
|
|
|
|
upgradeID: upgradeID,
|
|
|
|
}
|
|
|
|
|
2022-08-29 10:49:44 -04:00
|
|
|
kubeConfig, err := clientcmd.BuildConfigFromFlags("", constants.AdminConfFilename)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("building kubernetes config: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeClient, err := kubernetes.NewForConfig(kubeConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("setting up kubernetes client: %w", err)
|
|
|
|
}
|
2023-06-21 03:22:32 -04:00
|
|
|
u.stableInterface = &stableClient{client: kubeClient}
|
2022-08-29 10:49:44 -04:00
|
|
|
|
|
|
|
// use unstructured client to avoid importing the operator packages
|
|
|
|
unstructuredClient, err := dynamic.NewForConfig(kubeConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("setting up custom resource client: %w", err)
|
|
|
|
}
|
2023-06-21 03:22:32 -04:00
|
|
|
u.dynamicInterface = &NodeVersionClient{client: unstructuredClient}
|
2022-08-29 10:49:44 -04:00
|
|
|
|
2023-08-02 09:49:40 -04:00
|
|
|
helmClient, err := helm.NewUpgradeClient(kubectl.New(), constants.AdminConfFilename, constants.HelmNamespace, log)
|
2022-11-24 10:39:33 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("setting up helm client: %w", err)
|
|
|
|
}
|
2023-06-21 03:22:32 -04:00
|
|
|
u.helmClient = helmClient
|
2022-11-24 10:39:33 -05:00
|
|
|
|
2023-06-21 03:22:32 -04:00
|
|
|
tfClient, err := terraform.New(ctx, filepath.Join(constants.UpgradeDir, upgradeID, constants.TerraformUpgradeWorkingDir))
|
2023-05-22 07:31:20 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("setting up terraform client: %w", err)
|
|
|
|
}
|
2023-06-27 07:12:50 -04:00
|
|
|
u.tfClient = tfClient
|
2023-05-22 07:31:20 -04:00
|
|
|
|
2023-07-18 03:33:42 -04:00
|
|
|
tfUpgrader, err := upgrade.NewTerraformUpgrader(tfClient, outWriter, fileHandler)
|
2023-05-22 07:31:20 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("setting up terraform upgrader: %w", err)
|
|
|
|
}
|
2023-06-21 03:22:32 -04:00
|
|
|
u.tfUpgrader = tfUpgrader
|
2023-05-22 07:31:20 -04:00
|
|
|
|
2023-06-21 03:22:32 -04:00
|
|
|
return u, nil
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
2023-07-24 04:30:53 -04:00
|
|
|
// GetUpgradeID returns the upgrade ID.
|
|
|
|
func (u *Upgrader) GetUpgradeID() string {
|
|
|
|
return u.upgradeID
|
|
|
|
}
|
|
|
|
|
2023-06-27 07:12:50 -04:00
|
|
|
// 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 (u *Upgrader) AddManualStateMigration(migration terraform.StateMigration) {
|
|
|
|
u.tfClient.WithManualStateMigration(migration)
|
|
|
|
}
|
|
|
|
|
2023-05-22 07:31:20 -04:00
|
|
|
// 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.
|
2023-07-18 03:33:42 -04:00
|
|
|
func (u *Upgrader) CheckTerraformMigrations() error {
|
2023-07-24 04:30:53 -04:00
|
|
|
return u.tfUpgrader.CheckTerraformMigrations(u.upgradeID, constants.TerraformUpgradeBackupDir)
|
2023-05-22 07:31:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CleanUpTerraformMigrations cleans up the Terraform migration workspace, for example when an upgrade is
|
|
|
|
// aborted by the user.
|
2023-07-18 03:33:42 -04:00
|
|
|
func (u *Upgrader) CleanUpTerraformMigrations() error {
|
|
|
|
return u.tfUpgrader.CleanUpTerraformMigrations(u.upgradeID)
|
2023-05-22 07:31:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 (u *Upgrader) PlanTerraformMigrations(ctx context.Context, opts upgrade.TerraformUpgradeOptions) (bool, error) {
|
2023-06-21 03:22:32 -04:00
|
|
|
return u.tfUpgrader.PlanTerraformMigrations(ctx, opts, u.upgradeID)
|
2023-05-22 07:31:20 -04:00
|
|
|
}
|
|
|
|
|
2023-07-24 04:30:53 -04:00
|
|
|
// ApplyTerraformMigrations applies the migrations planned by PlanTerraformMigrations.
|
2023-05-22 07:31:20 -04:00
|
|
|
// 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.
|
2023-07-18 03:33:42 -04:00
|
|
|
func (u *Upgrader) ApplyTerraformMigrations(ctx context.Context, opts upgrade.TerraformUpgradeOptions) error {
|
|
|
|
return u.tfUpgrader.ApplyTerraformMigrations(ctx, opts, u.upgradeID)
|
2023-05-22 07:31:20 -04:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:23 -05:00
|
|
|
// UpgradeHelmServices upgrade helm services.
|
2023-07-24 04:30:53 -04:00
|
|
|
func (u *Upgrader) UpgradeHelmServices(ctx context.Context, config *config.Config, idFile clusterid.File, timeout time.Duration, allowDestructive bool, force bool) error {
|
|
|
|
return u.helmClient.Upgrade(ctx, config, idFile, timeout, allowDestructive, force, u.upgradeID)
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2023-06-21 09:49:42 -04:00
|
|
|
func (u *Upgrader) UpgradeNodeVersion(ctx context.Context, conf *config.Config, force bool) error {
|
2023-05-23 03:17:27 -04:00
|
|
|
provider := conf.GetProvider()
|
|
|
|
attestationVariant := conf.GetAttestationConfig().GetVariant()
|
|
|
|
region := conf.GetRegion()
|
|
|
|
imageReference, err := u.imageFetcher.FetchReference(ctx, provider, attestationVariant, conf.Image, region)
|
2023-02-09 09:54:12 -05:00
|
|
|
if err != nil {
|
2023-03-03 03:38:23 -05:00
|
|
|
return fmt.Errorf("fetching image reference: %w", err)
|
2023-02-09 09:54:12 -05:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:23 -05:00
|
|
|
imageVersion, err := versionsapi.NewVersionFromShortPath(conf.Image, versionsapi.VersionKindImage)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("parsing version from image short path: %w", err)
|
2023-02-09 09:54:12 -05:00
|
|
|
}
|
|
|
|
|
2023-06-21 09:49:42 -04:00
|
|
|
nodeVersion, err := u.getClusterStatus(ctx)
|
2023-03-03 03:38:23 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:23 -05:00
|
|
|
upgradeErrs := []error{}
|
2023-06-30 10:46:05 -04:00
|
|
|
var upgradeErr *compatibility.InvalidUpgradeError
|
2023-06-21 09:49:42 -04:00
|
|
|
|
2023-08-01 10:48:13 -04:00
|
|
|
err = u.updateImage(&nodeVersion, imageReference, imageVersion.Version(), force)
|
2023-03-22 06:53:47 -04:00
|
|
|
switch {
|
|
|
|
case errors.As(err, &upgradeErr):
|
2023-03-03 03:38:23 -05:00
|
|
|
upgradeErrs = append(upgradeErrs, fmt.Errorf("skipping image upgrades: %w", err))
|
2023-03-22 06:53:47 -04:00
|
|
|
case err != nil:
|
|
|
|
return fmt.Errorf("updating image version: %w", err)
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
2023-06-05 03:13:02 -04:00
|
|
|
// We have to allow users to specify outdated k8s patch versions.
|
|
|
|
// Therefore, this code has to skip k8s updates if a user configures an outdated (i.e. invalid) k8s version.
|
|
|
|
var components *corev1.ConfigMap
|
|
|
|
currentK8sVersion, err := versions.NewValidK8sVersion(conf.KubernetesVersion, true)
|
|
|
|
if err != nil {
|
|
|
|
innerErr := fmt.Errorf("unsupported Kubernetes version, supported versions are %s", strings.Join(versions.SupportedK8sVersions(), ", "))
|
|
|
|
err = compatibility.NewInvalidUpgradeError(nodeVersion.Spec.KubernetesClusterVersion, conf.KubernetesVersion, innerErr)
|
|
|
|
} else {
|
|
|
|
versionConfig := versions.VersionConfigs[currentK8sVersion]
|
2023-06-21 09:49:42 -04:00
|
|
|
components, err = u.updateK8s(&nodeVersion, versionConfig.ClusterVersion, versionConfig.KubernetesComponents, force)
|
2023-06-05 03:13:02 -04:00
|
|
|
}
|
|
|
|
|
2023-03-22 06:53:47 -04:00
|
|
|
switch {
|
|
|
|
case err == nil:
|
|
|
|
err := u.applyComponentsCM(ctx, components)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("applying k8s components ConfigMap: %w", err)
|
|
|
|
}
|
|
|
|
case errors.As(err, &upgradeErr):
|
2023-03-03 03:38:23 -05:00
|
|
|
upgradeErrs = append(upgradeErrs, fmt.Errorf("skipping Kubernetes upgrades: %w", err))
|
2023-03-22 06:53:47 -04:00
|
|
|
default:
|
|
|
|
return fmt.Errorf("updating Kubernetes version: %w", err)
|
2023-02-09 09:54:12 -05:00
|
|
|
}
|
2023-01-31 06:12:19 -05:00
|
|
|
|
2023-03-03 03:38:23 -05:00
|
|
|
if len(upgradeErrs) == 2 {
|
|
|
|
return errors.Join(upgradeErrs...)
|
2023-02-09 09:54:12 -05:00
|
|
|
}
|
|
|
|
|
2023-03-22 06:53:47 -04:00
|
|
|
updatedNodeVersion, err := u.applyNodeVersion(ctx, nodeVersion)
|
2022-08-31 05:59:07 -04:00
|
|
|
if err != nil {
|
2023-03-03 03:38:23 -05:00
|
|
|
return fmt.Errorf("applying upgrade: %w", err)
|
2022-08-31 05:59:07 -04:00
|
|
|
}
|
2023-03-22 06:53:47 -04:00
|
|
|
switch {
|
2023-04-13 09:58:37 -04:00
|
|
|
case updatedNodeVersion.Spec.ImageReference != nodeVersion.Spec.ImageReference:
|
|
|
|
return &applyError{expected: nodeVersion.Spec.ImageReference, actual: updatedNodeVersion.Spec.ImageReference}
|
|
|
|
case updatedNodeVersion.Spec.ImageVersion != nodeVersion.Spec.ImageVersion:
|
|
|
|
return &applyError{expected: nodeVersion.Spec.ImageVersion, actual: updatedNodeVersion.Spec.ImageVersion}
|
2023-03-22 06:53:47 -04:00
|
|
|
case updatedNodeVersion.Spec.KubernetesComponentsReference != nodeVersion.Spec.KubernetesComponentsReference:
|
2023-04-13 09:58:37 -04:00
|
|
|
return &applyError{expected: nodeVersion.Spec.KubernetesComponentsReference, actual: updatedNodeVersion.Spec.KubernetesComponentsReference}
|
|
|
|
case updatedNodeVersion.Spec.KubernetesClusterVersion != nodeVersion.Spec.KubernetesClusterVersion:
|
|
|
|
return &applyError{expected: nodeVersion.Spec.KubernetesClusterVersion, actual: updatedNodeVersion.Spec.KubernetesClusterVersion}
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return errors.Join(upgradeErrs...)
|
|
|
|
}
|
2022-08-31 05:59:07 -04:00
|
|
|
|
2023-03-14 13:34:58 -04:00
|
|
|
// KubernetesVersion returns the version of Kubernetes the Constellation is currently running on.
|
|
|
|
func (u *Upgrader) KubernetesVersion() (string, error) {
|
2023-07-07 11:02:01 -04:00
|
|
|
return u.stableInterface.KubernetesVersion()
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CurrentImage returns the currently used image version of the cluster.
|
|
|
|
func (u *Upgrader) CurrentImage(ctx context.Context) (string, error) {
|
2023-03-24 06:51:18 -04:00
|
|
|
nodeVersion, err := GetConstellationVersion(ctx, u.dynamicInterface)
|
2023-03-14 13:34:58 -04:00
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("getting constellation-version: %w", err)
|
|
|
|
}
|
|
|
|
return nodeVersion.Spec.ImageVersion, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// CurrentKubernetesVersion returns the currently used Kubernetes version.
|
|
|
|
func (u *Upgrader) CurrentKubernetesVersion(ctx context.Context) (string, error) {
|
2023-03-24 06:51:18 -04:00
|
|
|
nodeVersion, err := GetConstellationVersion(ctx, u.dynamicInterface)
|
2023-03-14 13:34:58 -04:00
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("getting constellation-version: %w", err)
|
|
|
|
}
|
|
|
|
return nodeVersion.Spec.KubernetesClusterVersion, nil
|
|
|
|
}
|
|
|
|
|
2023-05-03 05:11:53 -04:00
|
|
|
// 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 (u *Upgrader) UpdateAttestationConfig(ctx context.Context, newAttestConfig config.AttestationCfg) error {
|
|
|
|
currentAttestConfig, joinConfig, err := u.GetClusterAttestationConfig(ctx, newAttestConfig.GetVariant())
|
|
|
|
if err != nil {
|
2023-07-10 08:03:45 -04:00
|
|
|
return fmt.Errorf("getting attestation config: %w", err)
|
2023-05-03 05:11:53 -04:00
|
|
|
}
|
|
|
|
equal, err := newAttestConfig.EqualTo(currentAttestConfig)
|
2023-03-14 13:34:58 -04:00
|
|
|
if err != nil {
|
2023-05-03 05:11:53 -04:00
|
|
|
return fmt.Errorf("comparing attestation configs: %w", err)
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
2023-05-03 05:11:53 -04:00
|
|
|
if equal {
|
|
|
|
fmt.Fprintln(u.outWriter, "Cluster is already using the chosen attestation config, skipping config upgrade")
|
2023-03-14 13:34:58 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// backup of previous measurements
|
2023-05-03 05:11:53 -04:00
|
|
|
joinConfig.Data[constants.AttestationConfigFilename+"_backup"] = joinConfig.Data[constants.AttestationConfigFilename]
|
2023-03-14 13:34:58 -04:00
|
|
|
|
2023-05-03 05:11:53 -04:00
|
|
|
newConfigJSON, err := json.Marshal(newAttestConfig)
|
2023-03-14 13:34:58 -04:00
|
|
|
if err != nil {
|
2023-05-03 05:11:53 -04:00
|
|
|
return fmt.Errorf("marshaling attestation config: %w", err)
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
2023-05-03 05:11:53 -04:00
|
|
|
joinConfig.Data[constants.AttestationConfigFilename] = string(newConfigJSON)
|
|
|
|
u.log.Debugf("Triggering attestation config update now")
|
2023-07-07 11:02:01 -04:00
|
|
|
if _, err = u.stableInterface.UpdateConfigMap(ctx, joinConfig); err != nil {
|
2023-05-03 05:11:53 -04:00
|
|
|
return fmt.Errorf("setting new attestation config: %w", err)
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
|
|
|
|
2023-05-03 05:11:53 -04:00
|
|
|
fmt.Fprintln(u.outWriter, "Successfully updated the cluster's attestation config")
|
2023-03-14 13:34:58 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-05-03 05:11:53 -04:00
|
|
|
// GetClusterAttestationConfig fetches the join-config configmap from the cluster, extracts the config
|
|
|
|
// and returns both the full configmap and the attestation config.
|
|
|
|
func (u *Upgrader) GetClusterAttestationConfig(ctx context.Context, variant variant.Variant) (config.AttestationCfg, *corev1.ConfigMap, error) {
|
2023-07-07 11:02:01 -04:00
|
|
|
existingConf, err := u.stableInterface.GetCurrentConfigMap(ctx, constants.JoinConfigMap)
|
2023-03-14 13:34:58 -04:00
|
|
|
if err != nil {
|
2023-05-03 05:11:53 -04:00
|
|
|
return nil, nil, fmt.Errorf("retrieving current attestation config: %w", err)
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
2023-05-03 05:11:53 -04:00
|
|
|
if _, ok := existingConf.Data[constants.AttestationConfigFilename]; !ok {
|
|
|
|
return nil, nil, errors.New("attestation config missing from join-config")
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
2023-05-03 05:11:53 -04:00
|
|
|
|
|
|
|
existingAttestationConfig, err := config.UnmarshalAttestationConfig([]byte(existingConf.Data[constants.AttestationConfigFilename]), variant)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, fmt.Errorf("retrieving current attestation config: %w", err)
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
|
|
|
|
2023-05-03 05:11:53 -04:00
|
|
|
return existingAttestationConfig, existingConf, nil
|
2023-03-14 13:34:58 -04:00
|
|
|
}
|
|
|
|
|
2023-07-21 10:43:51 -04:00
|
|
|
// ExtendClusterConfigCertSANs extends the ClusterConfig stored under "kube-system/kubeadm-config" with the given SANs.
|
|
|
|
// Existing SANs are preserved.
|
|
|
|
func (u *Upgrader) ExtendClusterConfigCertSANs(ctx context.Context, alternativeNames []string) error {
|
|
|
|
clusterConfiguration, kubeadmConfig, err := u.GetClusterConfiguration(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("getting ClusterConfig: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
existingSANs := make(map[string]struct{})
|
|
|
|
for _, existingSAN := range clusterConfiguration.APIServer.CertSANs {
|
|
|
|
existingSANs[existingSAN] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
var missingSANs []string
|
|
|
|
for _, san := range alternativeNames {
|
|
|
|
if _, ok := existingSANs[san]; !ok {
|
|
|
|
missingSANs = append(missingSANs, san)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(missingSANs) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
u.log.Debugf("Extending the cluster's apiserver SAN field with the following SANs: %s\n", strings.Join(missingSANs, ", "))
|
|
|
|
|
|
|
|
clusterConfiguration.APIServer.CertSANs = append(clusterConfiguration.APIServer.CertSANs, missingSANs...)
|
|
|
|
sort.Strings(clusterConfiguration.APIServer.CertSANs)
|
|
|
|
|
|
|
|
newConfigYAML, err := yaml.Marshal(clusterConfiguration)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("marshaling ClusterConfiguration: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeadmConfig.Data[constants.ClusterConfigurationKey] = string(newConfigYAML)
|
|
|
|
u.log.Debugf("Triggering kubeadm config update now")
|
|
|
|
if _, err = u.stableInterface.UpdateConfigMap(ctx, kubeadmConfig); err != nil {
|
|
|
|
return fmt.Errorf("setting new kubeadm config: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Fprintln(u.outWriter, "Successfully extended the cluster's apiserver SAN field")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetClusterConfiguration fetches the kubeadm-config configmap from the cluster, extracts the config
|
|
|
|
// and returns both the full configmap and the ClusterConfiguration.
|
|
|
|
func (u *Upgrader) GetClusterConfiguration(ctx context.Context) (kubeadmv1beta3.ClusterConfiguration, *corev1.ConfigMap, error) {
|
|
|
|
existingConf, err := u.stableInterface.GetCurrentConfigMap(ctx, constants.KubeadmConfigMap)
|
|
|
|
if err != nil {
|
|
|
|
return kubeadmv1beta3.ClusterConfiguration{}, nil, fmt.Errorf("retrieving current kubeadm-config: %w", err)
|
|
|
|
}
|
|
|
|
clusterConf, ok := existingConf.Data[constants.ClusterConfigurationKey]
|
|
|
|
if !ok {
|
|
|
|
return kubeadmv1beta3.ClusterConfiguration{}, nil, errors.New("ClusterConfiguration missing from kubeadm-config")
|
|
|
|
}
|
|
|
|
|
|
|
|
var existingClusterConfig kubeadmv1beta3.ClusterConfiguration
|
|
|
|
if err := yaml.Unmarshal([]byte(clusterConf), &existingClusterConfig); err != nil {
|
|
|
|
return kubeadmv1beta3.ClusterConfiguration{}, nil, fmt.Errorf("unmarshaling ClusterConfiguration: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return existingClusterConfig, existingConf, nil
|
|
|
|
}
|
|
|
|
|
2023-03-22 06:53:47 -04:00
|
|
|
// applyComponentsCM applies the k8s components ConfigMap to the cluster.
|
|
|
|
func (u *Upgrader) applyComponentsCM(ctx context.Context, components *corev1.ConfigMap) error {
|
2023-07-07 11:02:01 -04:00
|
|
|
_, err := u.stableInterface.CreateConfigMap(ctx, components)
|
2023-02-09 09:54:12 -05:00
|
|
|
// If the map already exists we can use that map and assume it has the same content as 'configMap'.
|
|
|
|
if err != nil && !k8serrors.IsAlreadyExists(err) {
|
2023-03-22 06:53:47 -04:00
|
|
|
return fmt.Errorf("creating k8s-components ConfigMap: %w. %T", err, err)
|
2022-08-31 05:59:07 -04:00
|
|
|
}
|
2023-03-22 06:53:47 -04:00
|
|
|
return nil
|
|
|
|
}
|
2023-02-09 09:54:12 -05:00
|
|
|
|
2023-03-22 06:53:47 -04:00
|
|
|
func (u *Upgrader) applyNodeVersion(ctx context.Context, nodeVersion updatev1alpha1.NodeVersion) (updatev1alpha1.NodeVersion, error) {
|
|
|
|
u.log.Debugf("Triggering NodeVersion upgrade now")
|
2023-03-03 03:38:23 -05:00
|
|
|
var updatedNodeVersion updatev1alpha1.NodeVersion
|
2023-07-24 06:15:11 -04:00
|
|
|
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
|
|
|
|
newNode, err := u.getClusterStatus(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("retrieving current NodeVersion: %w", err)
|
|
|
|
}
|
|
|
|
cmd := newUpgradeVersionCmd(nodeVersion)
|
|
|
|
cmd.SetUpdatedVersions(&newNode)
|
|
|
|
raw, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&newNode)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("converting nodeVersion to unstructured: %w", err)
|
|
|
|
}
|
|
|
|
updated, err := u.dynamicInterface.Update(ctx, &unstructured.Unstructured{Object: raw})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-02-09 09:54:12 -05:00
|
|
|
|
2023-07-24 06:15:11 -04:00
|
|
|
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(updated.UnstructuredContent(), &updatedNodeVersion); err != nil {
|
|
|
|
return fmt.Errorf("converting unstructured to NodeVersion: %w", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return updatedNodeVersion, err
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
|
|
|
|
2023-06-21 09:49:42 -04:00
|
|
|
func (u *Upgrader) getClusterStatus(ctx context.Context) (updatev1alpha1.NodeVersion, error) {
|
2023-03-24 06:51:18 -04:00
|
|
|
nodeVersion, err := GetConstellationVersion(ctx, u.dynamicInterface)
|
2023-03-03 03:38:23 -05:00
|
|
|
if err != nil {
|
|
|
|
return updatev1alpha1.NodeVersion{}, fmt.Errorf("retrieving current image: %w", err)
|
2022-08-31 05:59:07 -04:00
|
|
|
}
|
2023-03-03 03:38:23 -05:00
|
|
|
|
|
|
|
return nodeVersion, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// updateImage upgrades the cluster to the given measurements and image.
|
2023-06-21 09:49:42 -04:00
|
|
|
func (u *Upgrader) updateImage(nodeVersion *updatev1alpha1.NodeVersion, newImageReference, newImageVersion string, force bool) error {
|
2023-03-03 03:38:23 -05:00
|
|
|
currentImageVersion := nodeVersion.Spec.ImageVersion
|
2023-06-21 09:49:42 -04:00
|
|
|
if !force {
|
|
|
|
if upgradeInProgress(*nodeVersion) {
|
|
|
|
return ErrInProgress
|
|
|
|
}
|
|
|
|
if err := compatibility.IsValidUpgrade(currentImageVersion, newImageVersion); err != nil {
|
|
|
|
return fmt.Errorf("validating image update: %w", err)
|
|
|
|
}
|
2022-08-31 05:59:07 -04:00
|
|
|
}
|
2023-03-03 03:38:23 -05:00
|
|
|
u.log.Debugf("Updating local copy of nodeVersion image version from %s to %s", nodeVersion.Spec.ImageVersion, newImageVersion)
|
|
|
|
nodeVersion.Spec.ImageReference = newImageReference
|
|
|
|
nodeVersion.Spec.ImageVersion = newImageVersion
|
|
|
|
|
2023-02-09 09:54:12 -05:00
|
|
|
return nil
|
2022-12-19 10:52:15 -05:00
|
|
|
}
|
|
|
|
|
2023-06-21 09:49:42 -04:00
|
|
|
func (u *Upgrader) updateK8s(nodeVersion *updatev1alpha1.NodeVersion, newClusterVersion string, components components.Components, force bool) (*corev1.ConfigMap, error) {
|
2023-03-03 03:38:23 -05:00
|
|
|
configMap, err := internalk8s.ConstructK8sComponentsCM(components, newClusterVersion)
|
|
|
|
if err != nil {
|
2023-03-22 06:53:47 -04:00
|
|
|
return nil, fmt.Errorf("constructing k8s-components ConfigMap: %w", err)
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
2023-06-21 09:49:42 -04:00
|
|
|
if !force {
|
|
|
|
if err := compatibility.IsValidUpgrade(nodeVersion.Spec.KubernetesClusterVersion, newClusterVersion); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
u.log.Debugf("Updating local copy of nodeVersion Kubernetes version from %s to %s", nodeVersion.Spec.KubernetesClusterVersion, newClusterVersion)
|
|
|
|
nodeVersion.Spec.KubernetesComponentsReference = configMap.ObjectMeta.Name
|
|
|
|
nodeVersion.Spec.KubernetesClusterVersion = newClusterVersion
|
|
|
|
|
2023-03-22 06:53:47 -04:00
|
|
|
return &configMap, nil
|
2023-03-03 03:38:23 -05:00
|
|
|
}
|
|
|
|
|
2023-03-24 06:51:18 -04:00
|
|
|
// NodeVersionClient implements the DynamicInterface interface to interact with NodeVersion objects.
|
|
|
|
type NodeVersionClient struct {
|
|
|
|
client dynamic.Interface
|
|
|
|
}
|
2023-02-09 09:54:12 -05:00
|
|
|
|
2023-03-24 06:51:18 -04:00
|
|
|
// NewNodeVersionClient returns a new NodeVersionClient.
|
|
|
|
func NewNodeVersionClient(client dynamic.Interface) *NodeVersionClient {
|
|
|
|
return &NodeVersionClient{client: client}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetCurrent returns the current NodeVersion object.
|
|
|
|
func (u *NodeVersionClient) GetCurrent(ctx context.Context, name string) (*unstructured.Unstructured, error) {
|
|
|
|
return u.client.Resource(schema.GroupVersionResource{
|
|
|
|
Group: "update.edgeless.systems",
|
|
|
|
Version: "v1alpha1",
|
|
|
|
Resource: "nodeversions",
|
|
|
|
}).Get(ctx, name, metav1.GetOptions{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update updates the NodeVersion object.
|
|
|
|
func (u *NodeVersionClient) Update(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
|
|
|
|
return u.client.Resource(schema.GroupVersionResource{
|
|
|
|
Group: "update.edgeless.systems",
|
|
|
|
Version: "v1alpha1",
|
|
|
|
Resource: "nodeversions",
|
|
|
|
}).Update(ctx, obj, metav1.UpdateOptions{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// DynamicInterface is a general interface to query custom resources.
|
|
|
|
type DynamicInterface interface {
|
|
|
|
GetCurrent(ctx context.Context, name string) (*unstructured.Unstructured, error)
|
|
|
|
Update(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
|
2023-02-09 09:54:12 -05:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:23 -05:00
|
|
|
// upgradeInProgress checks if an upgrade is in progress.
|
2023-02-09 09:54:12 -05:00
|
|
|
// Returns true with errors as it's the "safer" response. If caller does not check err they at least won't update the cluster.
|
2023-03-03 03:38:23 -05:00
|
|
|
func upgradeInProgress(nodeVersion updatev1alpha1.NodeVersion) bool {
|
2023-02-09 09:54:12 -05:00
|
|
|
conditions := nodeVersion.Status.Conditions
|
|
|
|
activeUpgrade := nodeVersion.Status.ActiveClusterVersionUpgrade
|
|
|
|
|
|
|
|
if activeUpgrade {
|
|
|
|
return true
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
2023-02-09 09:54:12 -05:00
|
|
|
for _, condition := range conditions {
|
|
|
|
if condition.Type == updatev1alpha1.ConditionOutdated && condition.Status == metav1.ConditionTrue {
|
|
|
|
return true
|
|
|
|
}
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
2023-02-09 09:54:12 -05:00
|
|
|
return false
|
|
|
|
}
|
2022-08-29 10:49:44 -04:00
|
|
|
|
2023-07-07 11:02:01 -04:00
|
|
|
// StableInterface is an interface to interact with stable resources.
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewStableClient returns a new StableInterface.
|
|
|
|
func NewStableClient(client kubernetes.Interface) StableInterface {
|
|
|
|
return &stableClient{client: client}
|
2022-08-29 10:49:44 -04:00
|
|
|
}
|
|
|
|
|
2022-11-24 10:39:33 -05:00
|
|
|
type stableClient struct {
|
2022-08-29 10:49:44 -04:00
|
|
|
client kubernetes.Interface
|
|
|
|
}
|
|
|
|
|
2023-07-07 11:02:01 -04:00
|
|
|
// GetCurrentConfigMap returns a ConfigMap given it's name.
|
|
|
|
func (u *stableClient) GetCurrentConfigMap(ctx context.Context, name string) (*corev1.ConfigMap, error) {
|
2022-08-29 10:49:44 -04:00
|
|
|
return u.client.CoreV1().ConfigMaps(constants.ConstellationNamespace).Get(ctx, name, metav1.GetOptions{})
|
|
|
|
}
|
|
|
|
|
2023-07-07 11:02:01 -04:00
|
|
|
// UpdateConfigMap updates the given ConfigMap.
|
|
|
|
func (u *stableClient) UpdateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
|
2022-08-29 10:49:44 -04:00
|
|
|
return u.client.CoreV1().ConfigMaps(constants.ConstellationNamespace).Update(ctx, configMap, metav1.UpdateOptions{})
|
|
|
|
}
|
2022-11-24 10:39:33 -05:00
|
|
|
|
2023-07-07 11:02:01 -04:00
|
|
|
// CreateConfigMap creates the given ConfigMap.
|
|
|
|
func (u *stableClient) CreateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
|
2023-02-09 09:54:12 -05:00
|
|
|
return u.client.CoreV1().ConfigMaps(constants.ConstellationNamespace).Create(ctx, configMap, metav1.CreateOptions{})
|
|
|
|
}
|
|
|
|
|
2023-07-07 11:02:01 -04:00
|
|
|
// KubernetesVersion returns the Kubernetes version of the cluster.
|
|
|
|
func (u *stableClient) KubernetesVersion() (string, error) {
|
2022-11-24 10:39:33 -05:00
|
|
|
serverVersion, err := u.client.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return serverVersion.GitVersion, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type helmInterface interface {
|
2023-07-24 04:30:53 -04:00
|
|
|
Upgrade(ctx context.Context, config *config.Config, idFile clusterid.File, timeout time.Duration, allowDestructive, force bool, upgradeID string) error
|
2022-12-19 10:52:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type debugLog interface {
|
|
|
|
Debugf(format string, args ...any)
|
|
|
|
Sync()
|
2022-11-24 10:39:33 -05:00
|
|
|
}
|
2023-03-30 10:13:14 -04:00
|
|
|
|
|
|
|
// imageFetcher gets an image reference from the versionsapi.
|
|
|
|
type imageFetcher interface {
|
2023-05-23 03:17:27 -04:00
|
|
|
FetchReference(ctx context.Context,
|
|
|
|
provider cloudprovider.Provider, attestationVariant variant.Variant,
|
|
|
|
image, region string,
|
|
|
|
) (string, error)
|
2023-03-30 10:13:14 -04:00
|
|
|
}
|
2023-07-24 06:15:11 -04:00
|
|
|
|
|
|
|
type upgradeVersionCmd struct {
|
|
|
|
imageVersion string
|
|
|
|
imageRef string
|
|
|
|
k8sComponentsRef string
|
|
|
|
k8sVersion string
|
|
|
|
}
|
|
|
|
|
|
|
|
func newUpgradeVersionCmd(newNodeVersion updatev1alpha1.NodeVersion) upgradeVersionCmd {
|
|
|
|
return upgradeVersionCmd{
|
|
|
|
imageVersion: newNodeVersion.Spec.ImageVersion,
|
|
|
|
imageRef: newNodeVersion.Spec.ImageReference,
|
|
|
|
k8sComponentsRef: newNodeVersion.Spec.KubernetesComponentsReference,
|
|
|
|
k8sVersion: newNodeVersion.Spec.KubernetesClusterVersion,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u upgradeVersionCmd) SetUpdatedVersions(node *updatev1alpha1.NodeVersion) {
|
|
|
|
if u.imageVersion != "" {
|
|
|
|
node.Spec.ImageVersion = u.imageVersion
|
|
|
|
}
|
|
|
|
if u.imageRef != "" {
|
|
|
|
node.Spec.ImageReference = u.imageRef
|
|
|
|
}
|
|
|
|
if u.k8sComponentsRef != "" {
|
|
|
|
node.Spec.KubernetesComponentsReference = u.k8sComponentsRef
|
|
|
|
}
|
|
|
|
if u.k8sVersion != "" {
|
|
|
|
node.Spec.KubernetesClusterVersion = u.k8sVersion
|
|
|
|
}
|
|
|
|
}
|