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

Expand Karpenter settings.aws block to settings for v0.33.0 and greater #7503

Merged
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
21 changes: 14 additions & 7 deletions pkg/karpenter/karpenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/karpenter/providers"
"github.com/weaveworks/eksctl/pkg/utils"
)

const (
Expand Down Expand Up @@ -78,16 +79,22 @@ func (k *Installer) Install(ctx context.Context, serviceAccountRoleARN string, i
defaultInstanceProfile: instanceProfileName,
},
settings: map[string]interface{}{
aws: map[string]interface{}{
defaultInstanceProfile: instanceProfileName,
clusterName: k.ClusterConfig.Metadata.Name,
clusterEndpoint: k.ClusterConfig.Status.Endpoint,
interruptionQueueName: k.ClusterConfig.Metadata.Name,
},
defaultInstanceProfile: instanceProfileName,
clusterName: k.ClusterConfig.Metadata.Name,
clusterEndpoint: k.ClusterConfig.Status.Endpoint,
interruptionQueueName: k.ClusterConfig.Metadata.Name,
},
serviceAccount: serviceAccountMap,
}

version := k.ClusterConfig.Karpenter.Version
compareVersions, err := utils.CompareVersions(version, "0.33.0")
if err == nil && compareVersions < 0 {
values[settings] = map[string]interface{}{
aws: values[settings],
}
}

registryClient, err := registry.NewClient(
registry.ClientOptEnableCache(true),
)
Expand All @@ -101,7 +108,7 @@ func (k *Installer) Install(ctx context.Context, serviceAccountRoleARN string, i
Namespace: DefaultNamespace,
ReleaseName: releaseName,
Values: values,
Version: k.ClusterConfig.Karpenter.Version,
Version: version,
RegistryClient: registryClient,
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/karpenter/karpenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ var _ = Describe("Install", func() {
}))
})

It("installs karpenter with expanded settings.aws values for version greater or equal to v0.33.0", func() {
installerUnderTest.Options.ClusterConfig.Karpenter.Version = "0.33.0"
Expect(installerUnderTest.Install(context.Background(), "dummy", "dummy")).To(Succeed())
_, opts := fakeHelmInstaller.InstallChartArgsForCall(0)
values := map[string]interface{}{
settings: map[string]interface{}{
defaultInstanceProfile: "dummy",
clusterName: cfg.Metadata.Name,
clusterEndpoint: cfg.Status.Endpoint,
interruptionQueueName: cfg.Metadata.Name,
},
}
Expect(opts.Values[settings]).To(Equal(values[settings]))
})

When("install chart fails", func() {

BeforeEach(func() {
Expand Down
Loading