Skip to content

Commit

Permalink
Expand Karpenter settings.aws block to settings for v0.33.0 and greater
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiang-zhang committed Jan 25, 2024
1 parent 9575570 commit f75c48e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
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

0 comments on commit f75c48e

Please sign in to comment.