Skip to content

Commit

Permalink
Add image family switch
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Oct 29, 2018
1 parent 5ffa575 commit 702a280
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ var _ = Describe("CloudFormation template builder API", func() {
cfg.ClusterName = clusterName
cfg.AvailabilityZones = testAZs
ng.InstanceType = "t2.medium"
ng.AMIFamily = "AmazonLinux2"

*cfg.VPC.CIDR = api.DefaultCIDR()

Expand Down Expand Up @@ -179,6 +180,7 @@ var _ = Describe("CloudFormation template builder API", func() {
NodeGroups: []*api.NodeGroup{
{
AMI: "",
AMIFamily: "AmazonLinux2",
InstanceType: "t2.medium",
SubnetTopology: "Public",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (n *NodeGroupResourceSet) AddAllResources() error {

n.vpc = makeImportValue(n.clusterStackName, cfnOutputClusterVPC)

userData, err := nodebootstrap.NewUserDataForAmazonLinux2(n.clusterSpec, n.id)
userData, err := nodebootstrap.NewUserData(n.clusterSpec, n.id)
if err != nil {
return err
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/nodebootstrap/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/pkg/errors"
"k8s.io/client-go/tools/clientcmd"

"github.com/weaveworks/eksctl/pkg/ami"
"github.com/weaveworks/eksctl/pkg/cloudconfig"
"github.com/weaveworks/eksctl/pkg/eks/api"
"github.com/weaveworks/eksctl/pkg/utils/kubeconfig"
Expand Down Expand Up @@ -110,3 +111,15 @@ func makeMetadata(spec *api.ClusterConfig) []string {
fmt.Sprintf("AWS_EKS_ENDPOINT=%s", spec.Endpoint),
}
}

// NewUserData creates new user data for a given node image family
func NewUserData(spec *api.ClusterConfig, nodeGroupID int) (string, error) {
switch spec.NodeGroups[nodeGroupID].AMIFamily {
case ami.ImageFamilyAmazonLinux2:
return NewUserDataForAmazonLinux2(spec, nodeGroupID)
case ami.ImageFamilyUbuntu1804:
return NewUserDataForUbuntu1804(spec, nodeGroupID)
default:
return "", nil
}
}

0 comments on commit 702a280

Please sign in to comment.