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

Pin karpenter support to 0.6.* #4903

Merged
merged 5 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ const (
minimumVPCCNIVersionForIPv6 = "1.10.0"
)

// supported version of Karpenter
const (
supportedKarpenterVersion = "0.6"
supportedKarpenterVersionMinor = 6
)

var (
// DefaultIPFamily defines the default IP family to use when creating a new VPC and cluster.
DefaultIPFamily = IPV4Family
Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ func validateKarpenterConfig(cfg *ClusterConfig) error {
if cfg.Karpenter.Version == "" {
return errors.New("version field is required if installing Karpenter is enabled")
}

v, err := version.NewVersion(cfg.Karpenter.Version)
if err != nil {
return fmt.Errorf("failed to parse karpenter version %q: %w", cfg.Karpenter.Version, err)
}

minor := v.Segments()[1]
if minor > supportedKarpenterVersionMinor {
return fmt.Errorf("failed to validate karpenter config: maximum supported version is %s", supportedKarpenterVersion)
}

if IsDisabled(cfg.IAM.WithOIDC) {
return errors.New("iam.withOIDC must be enabled with Karpenter")
}
Expand Down
25 changes: 22 additions & 3 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1690,17 +1690,36 @@ var _ = Describe("ClusterConfig validation", func() {
})

Describe("Karpenter", func() {
It("returns an error when OIDC is not set", func() {
cfg := api.NewClusterConfig()
cfg.Karpenter = &api.Karpenter{
Version: "0.6.1",
}
Expect(api.ValidateClusterConfig(cfg)).To(MatchError(ContainSubstring("failed to validate karpenter config: iam.withOIDC must be enabled with Karpenter")))
})

It("returns an error when version is missing", func() {
cfg := api.NewClusterConfig()
cfg.Karpenter = &api.Karpenter{}
Expect(api.ValidateClusterConfig(cfg)).To(MatchError(ContainSubstring("version field is required if installing Karpenter is enabled")))
})
It("returns an error when OIDC is not set", func() {

It("returns an error when version is missing", func() {
cfg := api.NewClusterConfig()
cfg.IAM.WithOIDC = aws.Bool(true)
cfg.Karpenter = &api.Karpenter{
Version: "0.5.1",
Version: "isitmeeeyourlookingfoorrrr",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

}
Expect(api.ValidateClusterConfig(cfg)).To(MatchError(ContainSubstring("failed to validate karpenter config: iam.withOIDC must be enabled with Karpenter")))
Expect(api.ValidateClusterConfig(cfg)).To(MatchError(ContainSubstring("failed to parse karpenter version")))
})

It("returns an error when the version is not supported", func() {
cfg := api.NewClusterConfig()
cfg.IAM.WithOIDC = aws.Bool(true)
cfg.Karpenter = &api.Karpenter{
Version: "0.7.0",
}
Expect(api.ValidateClusterConfig(cfg)).To(MatchError(ContainSubstring("failed to validate karpenter config: maximum supported version is 0.6")))
})
})

Expand Down