Skip to content

Commit

Permalink
fix: Karpenter 1.0 installation fails when using Bottlerocket (#251)
Browse files Browse the repository at this point in the history
* fix: Add AMI Lookups for Bottlerocket
* fix function name spelling for getEKSOptimizedAMI

Fixes #249

---------

Co-authored-by: Joe North <jbnorth@amazon.com>
  • Loading branch information
JoeNorth and Joe North authored Sep 28, 2024
1 parent 9ce9c2e commit 2266e9d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
13 changes: 12 additions & 1 deletion pkg/application/karpenter/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ func newOptions() (options *KarpenterOptions, flags cmd.Flags) {
}
if strings.EqualFold(options.AMIFamily, "Bottlerocket") {
options.AMIFamily = "Bottlerocket"
return nil

bottlerocketAMI, err := ssm.GetBottlerocketAMI(eksVersion)
if err != nil {
return err
}

bottlerocketArm64AMI, err := ssm.GetBottlerocketArm64AMI(eksVersion)
if err != nil {
return err
}

options.AMISelectorIDs = append(options.AMISelectorIDs, bottlerocketAMI, bottlerocketArm64AMI)
}
return nil
},
Expand Down
24 changes: 19 additions & 5 deletions pkg/resource/ssm/parameter/ami_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,37 @@ const eksAL2023AMI = "/aws/service/eks/optimized-ami/%s/amazon-linux-2023/x86_64
// /aws/service/eks/optimized-ami/<eks-version>/amazon-linux-2023/arm64/standard/recommended/image_id
const eksAL2023Arm64AMI = "/aws/service/eks/optimized-ami/%s/amazon-linux-2023/arm64/standard/recommended/image_id"

// /aws/service/bottlerocket/aws-k8s-<eks-version>/x86_64/latest/image_id
const bottlerocketAMI = "/aws/service/bottlerocket/aws-k8s-%s/x86_64/latest/image_id"

// /aws/service/bottlerocket/aws-k8s-<eks-version>/arm64/latest/image_id
const bottlerocketArm64AMI = "/aws/service/bottlerocket/aws-k8s-%s/arm64/latest/image_id"

func (g *Getter) GetEKSOptimizedAL2AMI(eksVersion string) (string, error) {
return g.getEKSOptmizedAMI(eksAL2AMI, eksVersion)
return g.getEKSOptimizedAMI(eksAL2AMI, eksVersion)
}

func (g *Getter) GetEKSOptimizedAL2Arm64AMI(eksVersion string) (string, error) {
return g.getEKSOptmizedAMI(eksAL2Arm64AMI, eksVersion)
return g.getEKSOptimizedAMI(eksAL2Arm64AMI, eksVersion)
}

func (g *Getter) GetEKSOptimizedAL2023AMI(eksVersion string) (string, error) {
return g.getEKSOptmizedAMI(eksAL2023AMI, eksVersion)
return g.getEKSOptimizedAMI(eksAL2023AMI, eksVersion)
}

func (g *Getter) GetEKSOptimizedAL2023Arm64AMI(eksVersion string) (string, error) {
return g.getEKSOptmizedAMI(eksAL2023Arm64AMI, eksVersion)
return g.getEKSOptimizedAMI(eksAL2023Arm64AMI, eksVersion)
}

func (g *Getter) GetBottlerocketAMI(eksVersion string) (string, error) {
return g.getEKSOptimizedAMI(bottlerocketAMI, eksVersion)
}

func (g *Getter) GetBottlerocketArm64AMI(eksVersion string) (string, error) {
return g.getEKSOptimizedAMI(bottlerocketArm64AMI, eksVersion)
}

func (g *Getter) getEKSOptmizedAMI(paramName, eksVersion string) (string, error) {
func (g *Getter) getEKSOptimizedAMI(paramName, eksVersion string) (string, error) {
param, err := g.ssmClient.GetParameter(fmt.Sprintf(paramName, eksVersion))
if err != nil {
return "", err
Expand Down

0 comments on commit 2266e9d

Please sign in to comment.