Skip to content

Commit

Permalink
add support for preBootstrapCommands in AL2023
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Nov 5, 2024
1 parent aa58c6a commit 3371857
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
3 changes: 0 additions & 3 deletions pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,6 @@ func validateNodeGroupBase(np NodePool, path string, controlPlaneOnOutposts bool
field: field,
}
}
if ng.PreBootstrapCommands != nil {
return fieldNotSupported("preBootstrapCommands")
}
if ng.OverrideBootstrapCommand != nil {
return fieldNotSupported("overrideBootstrapCommand")
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2087,15 +2087,6 @@ var _ = Describe("ClusterConfig validation", func() {
err := api.ValidateManagedNodeGroup(0, ng)
Expect(err).To(MatchError(ContainSubstring("eksctl does not support configuring maxPodsPerNode EKS-managed nodes")))
})
It("returns an error when setting preBootstrapCommands for self-managed nodegroups", func() {
cfg := api.NewClusterConfig()
ng := cfg.NewNodeGroup()
ng.Name = "node-group"
ng.AMI = "ami-1234"
ng.AMIFamily = api.NodeImageFamilyAmazonLinux2023
ng.PreBootstrapCommands = []string{"echo 'rubarb'"}
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(MatchError(ContainSubstring(fmt.Sprintf("preBootstrapCommands is not supported for %s nodegroups", api.NodeImageFamilyAmazonLinux2023))))
})
It("returns an error when setting overrideBootstrapCommand for self-managed nodegroups", func() {
cfg := api.NewClusterConfig()
ng := cfg.NewNodeGroup()
Expand All @@ -2105,14 +2096,6 @@ var _ = Describe("ClusterConfig validation", func() {
ng.OverrideBootstrapCommand = aws.String("echo 'rubarb'")
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(MatchError(ContainSubstring(fmt.Sprintf("overrideBootstrapCommand is not supported for %s nodegroups", api.NodeImageFamilyAmazonLinux2023))))
})
It("returns an error when setting preBootstrapCommands for EKS-managed nodegroups", func() {
ng := api.NewManagedNodeGroup()
ng.Name = "node-group"
ng.AMI = "ami-1234"
ng.AMIFamily = api.NodeImageFamilyAmazonLinux2023
ng.PreBootstrapCommands = []string{"echo 'rubarb'"}
Expect(api.ValidateManagedNodeGroup(0, ng)).To(MatchError(ContainSubstring(fmt.Sprintf("preBootstrapCommands is not supported for %s nodegroups", api.NodeImageFamilyAmazonLinux2023))))
})
It("returns an error when setting overrideBootstrapCommand for EKS-managed nodegroups", func() {
ng := api.NewManagedNodeGroup()
ng.Name = "node-group"
Expand Down
5 changes: 5 additions & 0 deletions pkg/nodebootstrap/al2023.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (m *AL2023) UserData() (string, error) {
if err != nil {
return "", fmt.Errorf("generating node config: %w", err)
}

for _, command := range m.nodePool.BaseNodeGroup().PreBootstrapCommands {
m.scripts = append(m.scripts, "#!/bin/bash\n"+command)
}

if len(m.scripts) == 0 && len(m.cloudboot) == 0 && nodeConfig == nil {
return "", nil
}
Expand Down

0 comments on commit 3371857

Please sign in to comment.