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

Add support for preBootstrapCommands in AL2023 #8031

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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 @@ -767,9 +767,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 @@ -2186,15 +2186,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 @@ -2204,14 +2195,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
Loading