Skip to content

Commit

Permalink
Pin karpenter support to 0.6.* (#4903)
Browse files Browse the repository at this point in the history
* pin karpenter support to 0.6.*

* Update pkg/apis/eksctl.io/v1alpha5/validation.go

Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

* add docs

Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
  • Loading branch information
aclevername and Skarlso authored Mar 8, 2022
1 parent 77f31d6 commit 72e2f58
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
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
10 changes: 10 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,16 @@ 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)
}

if minor := v.Segments()[1]; 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",
}
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
2 changes: 1 addition & 1 deletion userdocs/src/usage/eksctl-karpenter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`eksctl` provides adding [Karpenter](https://karpenter.sh/) to a newly created cluster. It will create all the necessary
prerequisites outlined in Karpenter's [Getting Started](https://karpenter.sh/docs/getting-started/) section including installing
Karpenter itself using Helm.
Karpenter itself using Helm. We currently support installing version's up to `0.6.*`

To that end, a new configuration value has been introduced into `eksctl` cluster config called `karpenter`. The following
yaml outlines a typical installation configuration:
Expand Down

0 comments on commit 72e2f58

Please sign in to comment.