Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Bottlerocket node with explicit Version field #7666

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 79 additions & 12 deletions integration/tests/update/update_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/go-version"

"github.com/aws/aws-sdk-go-v2/service/eks/types"
"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
Expand Down Expand Up @@ -60,6 +61,7 @@ var (

const (
initNG = "kp-ng-0"
botNG = "bot-ng-0"
)

var _ = BeforeSuite(func() {
Expand Down Expand Up @@ -91,23 +93,55 @@ var _ = BeforeSuite(func() {

eksVersion, nextEKSVersion = clusterutils.GetCurrentAndNextVersionsForUpgrade(params.Version)

clusterConfig := api.NewClusterConfig()
clusterConfig.Metadata.Name = defaultCluster
clusterConfig.Metadata.Region = params.Region
clusterConfig.Metadata.Version = eksVersion
clusterConfig.Metadata.Tags = map[string]string{
"alpha.eksctl.io/description": "eksctl integration test",
}
clusterConfig.ManagedNodeGroups = []*api.ManagedNodeGroup{
{
NodeGroupBase: &api.NodeGroupBase{
Name: initNG,
InstanceType: "t3.large",
ScalingConfig: &api.ScalingConfig{
DesiredCapacity: aws.Int(1),
},
Labels: map[string]string{
"ng-name": initNG,
},
},
},
{
NodeGroupBase: &api.NodeGroupBase{
Name: botNG,
AMIFamily: api.NodeImageFamilyBottlerocket,
InstanceType: "t3.small",
ScalingConfig: &api.ScalingConfig{
DesiredCapacity: aws.Int(1),
},
Labels: map[string]string{
"ng-name": botNG,
},
},
},
}

cmd := params.EksctlCreateCmd.WithArgs(
"cluster",
"--verbose", "4",
"--name", defaultCluster,
"--tags", "alpha.eksctl.io/description=eksctl integration test",
"--nodegroup-name", initNG,
"--node-labels", "ng-name="+initNG,
"--nodes", "1",
"--node-type", "t3.large",
"--version", eksVersion,
"--config-file", "-",
"--kubeconfig", params.KubeconfigPath,
)
"--verbose", "4",
).
WithoutArg("--region", params.Region).
WithStdin(clusterutils.Reader(clusterConfig))
Expect(cmd).To(RunSuccessfully())
})
var _ = Describe("(Integration) Update addons", func() {

Context("update cluster and addons", func() {
var _ = Describe("(Integration) Upgrading cluster", func() {

Context("control plane", func() {
It("should have created an EKS cluster and two CloudFormation stacks", func() {
config := NewConfig(params.Region)

Expand Down Expand Up @@ -139,7 +173,9 @@ var _ = Describe("(Integration) Update addons", func() {
return fmt.Sprintf("%s.%s", serverVersion.Major, strings.TrimSuffix(serverVersion.Minor, "+"))
}, k8sUpdatePollTimeout, k8sUpdatePollInterval).Should(Equal(nextEKSVersion))
})
})

Context("addons", func() {
It("should upgrade kube-proxy", func() {
cmd := params.EksctlUtilsCmd.WithArgs(
"update-kube-proxy",
Expand Down Expand Up @@ -195,7 +231,10 @@ var _ = Describe("(Integration) Update addons", func() {
Expect(cmd).To(RunSuccessfully())
})

It("should upgrade the nodegroup to the next version", func() {
})

Context("nodegroup", func() {
It("should upgrade the initial nodegroup to the next version", func() {
cmd := params.EksctlUpgradeCmd.WithArgs(
"nodegroup",
"--verbose", "4",
Expand All @@ -205,6 +244,34 @@ var _ = Describe("(Integration) Update addons", func() {
"--timeout=60m", // wait for CF stacks to finish update
)
ExpectWithOffset(1, cmd).To(RunSuccessfullyWithOutputString(ContainSubstring("nodegroup successfully upgraded")))

cmd = params.EksctlGetCmd.WithArgs(
"nodegroup",
"--cluster", params.ClusterName,
"--name", initNG,
"--output", "yaml",
)
ExpectWithOffset(1, cmd).To(RunSuccessfullyWithOutputString(ContainSubstring(fmt.Sprintf("Version: \"%s\"", nextEKSVersion))))
})

It("should upgrade the Bottlerocket nodegroup to the next version", func() {
cmd := params.EksctlUpgradeCmd.WithArgs(
"nodegroup",
"--verbose", "4",
"--cluster", params.ClusterName,
"--name", botNG,
"--kubernetes-version", nextEKSVersion,
"--timeout=60m", // wait for CF stacks to finish update
)
ExpectWithOffset(1, cmd).To(RunSuccessfullyWithOutputString(ContainSubstring("nodegroup successfully upgraded")))

cmd = params.EksctlGetCmd.WithArgs(
"nodegroup",
"--cluster", params.ClusterName,
"--name", botNG,
"--output", "yaml",
)
ExpectWithOffset(1, cmd).To(RunSuccessfullyWithOutputString(ContainSubstring(fmt.Sprintf("Version: \"%s\"", nextEKSVersion))))
})
})
})
Expand Down
13 changes: 9 additions & 4 deletions pkg/actions/nodegroup/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,17 @@ func (m *Manager) upgradeUsingStack(ctx context.Context, options UpgradeOptions,
latestReleaseVersion, err := m.getLatestReleaseVersion(ctx, kubernetesVersion, nodegroup)
if err != nil {
return err
}

if latestReleaseVersion != "" {
} else if latestReleaseVersion != "" {
if err := m.updateReleaseVersion(latestReleaseVersion, options.LaunchTemplateVersion, nodegroup, ngResource); err != nil {
return err
}
} else {
}

if ngResource.ReleaseVersion == nil {
ngResource.Version = gfnt.NewString(kubernetesVersion)
logger.Info(fmt.Sprintf("will upgrade nodes to Kubernetes version: %s", ngResource.Version))
} else {
logger.Info(fmt.Sprintf("will upgrade nodes to release version: %s", ngResource.ReleaseVersion))
}
}
if options.LaunchTemplateVersion != "" {
Expand All @@ -282,6 +285,8 @@ func (m *Manager) upgradeUsingStack(ctx context.Context, options UpgradeOptions,

ngResource.ForceUpdateEnabled = gfnt.NewBoolean(options.ForceUpgrade)

logger.Debug("nodegroup resources for upgrade: %+v", ngResource)

logger.Info("upgrading nodegroup version")
if err := updateStack(stack, options.Wait); err != nil {
return err
Expand Down