Skip to content

Commit

Permalink
Add support for creating self managed Windows Nodes (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhipth authored Oct 12, 2021
1 parent b676965 commit 408858d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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
13 changes: 13 additions & 0 deletions eks/ng/asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,19 @@ 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"
& $EKSBootstrapScriptFile -EKSClusterName %s -Base64ClusterCA %s -APIServerEndpoint %s -KubeletExtraArgs %s 3>&1 4>&1 5>&1 6>&1
</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

0 comments on commit 408858d

Please sign in to comment.