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 creating self managed Windows Nodes #241

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions ec2config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
// AMITypeAL2X8664GPU is the AMI type for Amazon Linux 2 AMI with GPU.
AMITypeAL2X8664GPU = "AL2_x86_64_GPU"

AMITypeWindowsServerCore2019X8664 = "WINDOWS_SERVER_CORE_2019_x86_64"

// DefaultNodeInstanceTypeCPUARM is the default EC2 instance type for CPU worker node.
// https://aws.amazon.com/ec2/instance-types/m6/
DefaultNodeInstanceTypeCPUARM = "m6g.xlarge"
Expand Down
16 changes: 16 additions & 0 deletions eks/ng/asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,22 @@ func (ts *tester) fetchImageID(ssmParam string) (img string, err error) {

func (ts *tester) generateUserData(asgName string, amiType string, kubeletExtraArgs string, bootstrapArgs string) (d string, err error) {
switch amiType {
case ec2config.AMITypeWindowsServerCore2019X8664:
d = fmt.Sprintf(`
<powershell>
[string]$EKSBinDir = "$env:ProgramFiles\Amazon\EKS"
[string]$EKSBootstrapScriptName = 'Start-EKSBootstrap.ps1'
[string]$EKSBootstrapScriptFile = "$EKSBinDir\$EKSBootstrapScriptName"
[string]$cfn_signal = "$env:ProgramFiles\Amazon\cfn-bootstrap\cfn-signal.exe"
& $EKSBootstrapScriptFile -EKSClusterName %s -Base64ClusterCA %s -APIServerEndpoint %s -KubeletExtraArgs %s 3>&1 4>&1 5>&1 6>&1
$LastError = if ($?) { 0 } else { $Error[0].Exception.HResult }
& $cfn_signal --exit-code=$LastError --stack="${AWS::StackName}" --resource="NodeGroup" --region=${AWS::Region}
</powershell>`,
ts.cfg.EKSConfig.Name,
ts.cfg.EKSConfig.Status.ClusterCA,
ts.cfg.EKSConfig.Status.ClusterAPIServerEndpoint,
fmt.Sprintf("'--node-labels=NodeType=regular,AMIType=%s,NGType=custom,NGName=%s %s'", amiType, asgName, kubeletExtraArgs))

case ec2config.AMITypeBottleRocketCPU:
d = fmt.Sprintf(`[settings.kubernetes]
cluster-name = "%s"
Expand Down
6 changes: 5 additions & 1 deletion eksconfig/add-on-node-groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func (cfg *Config) validateAddOnNodeGroups() error {
if cur.RemoteAccessUserName != "ec2-user" {
return fmt.Errorf("AMIType %q but unexpected RemoteAccessUserName %q", cur.AMIType, cur.RemoteAccessUserName)
}
case ec2config.AMITypeWindowsServerCore2019X8664:
if cur.RemoteAccessUserName != "ec2-user" {
return fmt.Errorf("AMIType %q but unexpected RemoteAccessUserName %q", cur.AMIType, cur.RemoteAccessUserName)
}
default:
return fmt.Errorf("unknown ASGs[%q].AMIType %q", k, cur.AMIType)
}
Expand All @@ -249,7 +253,7 @@ func (cfg *Config) validateAddOnNodeGroups() error {
if cur.InstanceType == "" {
cur.InstanceType = DefaultNodeInstanceTypeCPU
}
case fmt.Sprint(aws_eks_v2_types.AMITypesAl2X8664):
case fmt.Sprint(aws_eks_v2_types.AMITypesAl2X8664), ec2config.AMITypeWindowsServerCore2019X8664:
if cur.InstanceType == "" {
cur.InstanceType = DefaultNodeInstanceTypeCPU
}
Expand Down