Skip to content

Commit

Permalink
Add a way for users to provide bootstrap command
Browse files Browse the repository at this point in the history
This should allow those who _know what their are doing_ to pass
a custom script to run inside of cloud-init. Anyone looking to
use this will need to defined a shell script that would resemble
`bootstrap.{al2,ubuntu}.sh`. This should cater for any of advanced
use-cases, where additional files must be created on EC2 instances
prior to boot or anything of that nature. Alternative approach is
to use a custom AMI, or propose an eksctl feature, but this is
meant as a stop-gap for testing things out.
  • Loading branch information
errordeveloper committed Feb 7, 2019
1 parent cfa16dc commit 4fbfa95
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pkg/apis/eksctl.io/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ type NodeGroup struct {

// +optional
IAM *NodeGroupIAM `json:"iam"`

OverrideBootstrapCommand *string `json:"overrideBootstrapCommand,omitempty"`
}

// ListOptions returns metav1.ListOptions with label selector for the nodegroup
Expand Down
12 changes: 8 additions & 4 deletions pkg/nodebootstrap/userdata_al2.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ func makeAmazonLinux2Config(spec *api.ClusterConfig, ng *api.NodeGroup) (configF
func NewUserDataForAmazonLinux2(spec *api.ClusterConfig, ng *api.NodeGroup) (string, error) {
config := cloudconfig.New()

scripts := []string{
"bootstrap.al2.sh",
}

files, err := makeAmazonLinux2Config(spec, ng)
if err != nil {
return "", err
}

scripts := []string{}

if ng.OverrideBootstrapCommand != nil {
config.AddShellCommand(*ng.OverrideBootstrapCommand)
} else {
scripts = append(scripts, "bootstrap.al2.sh")
}

if err = addFilesAndScripts(config, files, scripts); err != nil {
return "", err
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/nodebootstrap/userdata_ubuntu.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ func makeUbuntu1804Config(spec *api.ClusterConfig, ng *api.NodeGroup) (configFil
func NewUserDataForUbuntu1804(spec *api.ClusterConfig, ng *api.NodeGroup) (string, error) {
config := cloudconfig.New()

scripts := []string{
"bootstrap.ubuntu.sh",
}

files, err := makeUbuntu1804Config(spec, ng)
if err != nil {
return "", err
}

scripts := []string{}

if ng.OverrideBootstrapCommand != nil {
config.AddShellCommand(*ng.OverrideBootstrapCommand)
} else {
scripts = append(scripts, "bootstrap.ubuntu.sh")
}

if err = addFilesAndScripts(config, files, scripts); err != nil {
return "", err
}
Expand Down

0 comments on commit 4fbfa95

Please sign in to comment.