-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
875e50d
commit bbb9e30
Showing
2 changed files
with
83 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package nodebootstrap | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/kubicorn/kubicorn/pkg/logger" | ||
|
||
"github.com/weaveworks/eksctl/pkg/cloudconfig" | ||
"github.com/weaveworks/eksctl/pkg/eks/api" | ||
) | ||
|
||
func makeAmazonLinux2Config(spec *api.ClusterConfig, nodeGroupID int) (configFiles, error) { | ||
clientConfigData, err := makeClientConfigData(spec) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
files := configFiles{ | ||
kubeletDropInUnitDir: { | ||
"10-eksclt.al2.conf": {isAsset: true}, | ||
}, | ||
configDir: { | ||
"metadata.env": {content: strings.Join(makeMetadata(spec), "\n")}, | ||
"kubelet.env": {content: strings.Join(makeKubeletParams(spec, nodeGroupID), "\n")}, | ||
// TODO: https://github.com/weaveworks/eksctl/issues/161 | ||
"ca.crt": {content: string(spec.CertificateAuthorityData)}, | ||
"kubeconfig.yaml": {content: string(clientConfigData)}, | ||
}, | ||
} | ||
|
||
return files, nil | ||
} | ||
|
||
// NewUserDataForAmazonLinux2 creates new user data for Amazon Linux 2 nodes | ||
func NewUserDataForAmazonLinux2(spec *api.ClusterConfig, nodeGroupID int) (string, error) { | ||
config := cloudconfig.New() | ||
|
||
scripts := []string{ | ||
"bootstrap.al2.sh", | ||
} | ||
|
||
files, err := makeAmazonLinux2Config(spec, nodeGroupID) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if err = addFilesAndScripts(config, files, scripts); err != nil { | ||
return "", err | ||
} | ||
|
||
body, err := config.Encode() | ||
if err != nil { | ||
return "", errors.Wrap(err, "encoding user data") | ||
} | ||
|
||
logger.Debug("user-data = %s", body) | ||
return body, nil | ||
} |