diff --git a/ec2config/config.go b/ec2config/config.go index 7efc1035d..8bb0a2256 100644 --- a/ec2config/config.go +++ b/ec2config/config.go @@ -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" diff --git a/eks/ng/asg.go b/eks/ng/asg.go index 965ca7dc8..411dab506 100644 --- a/eks/ng/asg.go +++ b/eks/ng/asg.go @@ -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(` + +[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 +`, + 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" diff --git a/eksconfig/add-on-node-groups.go b/eksconfig/add-on-node-groups.go index ba145bdde..f817fbc80 100644 --- a/eksconfig/add-on-node-groups.go +++ b/eksconfig/add-on-node-groups.go @@ -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) } @@ -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 }