Skip to content

Commit 408858d

Browse files
authored
Add support for creating self managed Windows Nodes (#241)
1 parent b676965 commit 408858d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

ec2config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const (
3131
// AMITypeAL2X8664GPU is the AMI type for Amazon Linux 2 AMI with GPU.
3232
AMITypeAL2X8664GPU = "AL2_x86_64_GPU"
3333

34+
AMITypeWindowsServerCore2019X8664 = "WINDOWS_SERVER_CORE_2019_x86_64"
35+
3436
// DefaultNodeInstanceTypeCPUARM is the default EC2 instance type for CPU worker node.
3537
// https://aws.amazon.com/ec2/instance-types/m6/
3638
DefaultNodeInstanceTypeCPUARM = "m6g.xlarge"

eks/ng/asg.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,19 @@ func (ts *tester) fetchImageID(ssmParam string) (img string, err error) {
371371

372372
func (ts *tester) generateUserData(asgName string, amiType string, kubeletExtraArgs string, bootstrapArgs string) (d string, err error) {
373373
switch amiType {
374+
case ec2config.AMITypeWindowsServerCore2019X8664:
375+
d = fmt.Sprintf(`
376+
<powershell>
377+
[string]$EKSBinDir = "$env:ProgramFiles\Amazon\EKS"
378+
[string]$EKSBootstrapScriptName = 'Start-EKSBootstrap.ps1'
379+
[string]$EKSBootstrapScriptFile = "$EKSBinDir\$EKSBootstrapScriptName"
380+
& $EKSBootstrapScriptFile -EKSClusterName %s -Base64ClusterCA %s -APIServerEndpoint %s -KubeletExtraArgs %s 3>&1 4>&1 5>&1 6>&1
381+
</powershell>`,
382+
ts.cfg.EKSConfig.Name,
383+
ts.cfg.EKSConfig.Status.ClusterCA,
384+
ts.cfg.EKSConfig.Status.ClusterAPIServerEndpoint,
385+
fmt.Sprintf(`"--node-labels=NodeType=regular,AMIType=%s,NGType=custom,NGName=%s %s"`, amiType, asgName, kubeletExtraArgs))
386+
374387
case ec2config.AMITypeBottleRocketCPU:
375388
d = fmt.Sprintf(`[settings.kubernetes]
376389
cluster-name = "%s"

eksconfig/add-on-node-groups.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ func (cfg *Config) validateAddOnNodeGroups() error {
240240
if cur.RemoteAccessUserName != "ec2-user" {
241241
return fmt.Errorf("AMIType %q but unexpected RemoteAccessUserName %q", cur.AMIType, cur.RemoteAccessUserName)
242242
}
243+
case ec2config.AMITypeWindowsServerCore2019X8664:
244+
if cur.RemoteAccessUserName != "ec2-user" {
245+
return fmt.Errorf("AMIType %q but unexpected RemoteAccessUserName %q", cur.AMIType, cur.RemoteAccessUserName)
246+
}
243247
default:
244248
return fmt.Errorf("unknown ASGs[%q].AMIType %q", k, cur.AMIType)
245249
}
@@ -249,7 +253,7 @@ func (cfg *Config) validateAddOnNodeGroups() error {
249253
if cur.InstanceType == "" {
250254
cur.InstanceType = DefaultNodeInstanceTypeCPU
251255
}
252-
case fmt.Sprint(aws_eks_v2_types.AMITypesAl2X8664):
256+
case fmt.Sprint(aws_eks_v2_types.AMITypesAl2X8664), ec2config.AMITypeWindowsServerCore2019X8664:
253257
if cur.InstanceType == "" {
254258
cur.InstanceType = DefaultNodeInstanceTypeCPU
255259
}

0 commit comments

Comments
 (0)