Skip to content

Commit

Permalink
Create one ASG per AZ
Browse files Browse the repository at this point in the history
This is required for the cluster-autoscaler to properly work. It assumes
that all nodes in a ASG are equal. This includes their AZ. Without this,
the autoscaler won't be able to add nodes if a pod can't be scheduled
due to AZ related constraints.
  • Loading branch information
discordianfish committed Apr 16, 2018
1 parent 8e7e688 commit 2990156
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:sid

ENV KUBE_VERSION v1.8.4
ENV KUBE_VERSION v1.10.1
ENV KUBEADM_URL https://storage.googleapis.com/kubernetes-release/release/$KUBE_VERSION/bin/linux/amd64/kubeadm

RUN apt-get -qy update && apt-get -qy install curl make awscli golang-cfssl jq \
Expand Down
75 changes: 69 additions & 6 deletions kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,27 @@ Resources:
- "*"
Condition:
StringEquals:
"ec2:ResourceTag/aws:cloudformation:stack-id": !Ref WorkerPoolDefault
"ec2:ResourceTag/aws:cloudformation:stack-id": !Ref WorkerPoolDefaultA
- Effect: Allow
Action:
- "ec2:RevokeSecurityGroup*"
- "ec2:ModifyInstanceAttribute"
- "ec2:AuthorizeSecurityGroup*" # ...for the workers too
Resource:
- "*"
Condition:
StringEquals:
"ec2:ResourceTag/aws:cloudformation:stack-id": !Ref WorkerPoolDefaultB
- Effect: Allow
Action:
- "ec2:RevokeSecurityGroup*"
- "ec2:ModifyInstanceAttribute"
- "ec2:AuthorizeSecurityGroup*" # ...for the workers too
Resource:
- "*"
Condition:
StringEquals:
"ec2:ResourceTag/aws:cloudformation:stack-id": !Ref WorkerPoolDefaultC
- Effect: Allow
Action:
- "ec2:AuthorizeSecurityGroup*"
Expand Down Expand Up @@ -1179,7 +1199,23 @@ Resources:
ResourceRecords:
- !GetAtt [ "ControllerELB", "DNSName" ]

WorkerPoolDefault:
WorkerPoolDefaultA:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Sub
- "https://s3.amazonaws.com/${assetBucket}/${DomainName}/templates/worker.yaml"
- assetBucket: !Ref assetBucket
DomainName: !Ref DomainName
Parameters:
DomainName: !Ref DomainName
FeatureGates: !Ref WorkerFeatureGates
CPUManagerPolicy: !Ref WorkerCPUManagerPolicy
assetBucket: !Ref assetBucket
VPCID: !Ref VPCID
PrivateSubnet: !Ref PrivateSubnetA
KubeletImageTag: !Ref KubeletImageTag

WorkerPoolDefaultB:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Sub
Expand All @@ -1192,9 +1228,23 @@ Resources:
CPUManagerPolicy: !Ref WorkerCPUManagerPolicy
assetBucket: !Ref assetBucket
VPCID: !Ref VPCID
PrivateSubnetA: !Ref PrivateSubnetA
PrivateSubnetB: !Ref PrivateSubnetB
PrivateSubnetC: !Ref PrivateSubnetC
PrivateSubnet: !Ref PrivateSubnetB
KubeletImageTag: !Ref KubeletImageTag

WorkerPoolDefaultC:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Sub
- "https://s3.amazonaws.com/${assetBucket}/${DomainName}/templates/worker.yaml"
- assetBucket: !Ref assetBucket
DomainName: !Ref DomainName
Parameters:
DomainName: !Ref DomainName
FeatureGates: !Ref WorkerFeatureGates
CPUManagerPolicy: !Ref WorkerCPUManagerPolicy
assetBucket: !Ref assetBucket
VPCID: !Ref VPCID
PrivateSubnet: !Ref PrivateSubnetC
KubeletImageTag: !Ref KubeletImageTag

Outputs:
Expand All @@ -1203,9 +1253,22 @@ Outputs:
Export:
Name: !Sub "${AWS::StackName}-ControllerRole"
WorkerRole:
Value: !GetAtt WorkerPoolDefault.Outputs.WorkerRole
Value: !GetAtt WorkerPoolDefaultA.Outputs.WorkerRole
Export:
Name: !Sub "${AWS::StackName}-WorkerRole"
WorkerRoleA:
Value: !GetAtt WorkerPoolDefaultA.Outputs.WorkerRole
Export:
Name: !Sub "${AWS::StackName}-WorkerRoleA"
WorkerRoleB:
Value: !GetAtt WorkerPoolDefaultB.Outputs.WorkerRole
Export:
Name: !Sub "${AWS::StackName}-WorkerRoleB"
WorkerRoleC:
Value: !GetAtt WorkerPoolDefaultC.Outputs.WorkerRole
Export:
Name: !Sub "${AWS::StackName}-WorkerRoleC"

WorkerTemplateURL:
Value: !Sub
- "https://s3.amazonaws.com/${assetBucket}/${DomainName}/templates/worker.yaml"
Expand Down
12 changes: 2 additions & 10 deletions templates/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ Parameters:
Description: Existing VPC with attached internet gateway to use for this cluster.
Type: AWS::EC2::VPC::Id

PrivateSubnetA:
Type: String

PrivateSubnetB:
Type: String

PrivateSubnetC:
PrivateSubnet:
Type: String

assetBucket:
Expand Down Expand Up @@ -337,9 +331,7 @@ Resources:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier:
- !Ref PrivateSubnetA
- !Ref PrivateSubnetB
- !Ref PrivateSubnetC
- !Ref PrivateSubnet
LaunchConfigurationName:
Ref: WorkerLaunchConfiguration
MaxSize: !Ref WorkerPoolSizeMax
Expand Down

0 comments on commit 2990156

Please sign in to comment.