Creating the AWS Auto Scaling Group
AWS Auto Scaling enables you to build scaling plans that automate how groups of different resources respond to changes in demand. You can optimize availability, costs, or a balance of both.
- Using the Find Services search tool, locate and browse to the EC2 dashboard.
- In the left navigation panel, under Auto Scaling, select Auto Scaling Groups.
- On the landing page, click Create Auto Scaling Group to launch the creation wizard.
- On the Choose Launch template or configuration page, enter values for the following:
- Name: Enter a descriptive name for the Auto Scaling group.
- Under Launch template, select the launch template you created previously.
- Click Next.
- On the Configure settings page, enter values for the following:
- VPC: Choose the previously-created VPC recorded in the AWS worksheet.
- Subnets: Select all 3 private subnets (recorded on the AWS worksheet).
- Click Next.
-
On the Configure advanced options page, leave all values at default and click Next.
-
On the Configure group size and scaling policies page, set values for Desired capacity and Maximum capacity. In the example shown here, there will initially be 3 nodes and enough space to instantiate 2 more by simply increasing the desired capacity. (For a production cluster, the minimum capacity setting should not be less than 2.)
-
Click Next.
-
On the Add Notifications page, ignore all settings and click Next.
-
On the Add Tags page, add tags as follows:
-
Add the mandatory tag key:
kubernetes.io/cluster/<your cluster name>
with value:owned
(replace<your cluster name>
with your actual cluster name). -
Optionally, add these tags as desired:
- Key:
Name
with value: derived from the auto-scaling group name. - Key:
owner
with value: corresponding to you.
- Key:
- For all new tags you add, select the Tag new instances checkbox so new instances are automatically tagged.
-
- Click Next.
- On the Review page, verify your settings, and then click Create Auto Scaling Group.
- For networking configurations, we will need to know the machine instance IDs in the new Auto Scaling group. On the Auto Scaling Groups management page, select your new group.
- From the Instances tab, record all instance IDs in the AWS worksheet.
- Run the following command:
# aws autoscaling create-auto-scaling-group \ --auto-scaling-group-name <Autoscaling group name> \ --launch-configuration-name <Launch template name> \ --min-size <min size> \ --desired-capacity <desired size> \ --max-size <max size> \ --tags "Key=kubernetes.io/cluster/<cluster name>,Value=owned" "Key=Name,Value=<auto scaling group name>" \ --vpc-zone-identifier "<subnet Ids>"
Parameters:
<Autoscaling group name>:
Choose a name which helps with easier identification; in this guide we will use srgdemo-autoscaling-group. Record the value in the AWS worksheet.
<Launch template name>:
Name of the launch template created earlier.
<min size>:
The minimum size of the group. For a production cluster, this should not be less than 2. If installing Transformation Hub, no less than 3.
<desired size>:
The number of Amazon EC2 instances that the Auto Scaling group attempts to maintain. This number must be greater than or equal to the minimum size of the group and less than or equal to the maximum size of the group. If you do not specify a desired capacity, the default is the minimum size of the group.
<max size>:
The maximum size of the group.
<Cluster Name>:
Use the cluster name from the AWS worksheet.
<subnet Ids>:
A comma-separated list of private subnet IDs for your virtual private cloud (VPC); use values from from the AWS worksheet.
Example:
aws autoscaling create-auto-scaling-group \ --auto-scaling-group-name srgdemo-autoscaling-group \ --launch-template LaunchTemplateId=lt-0d2a237fcf4f5193e \ --min-size 1 \ --desired-capacity 3 \ --max-size 3 \ --tags "Key=kubernetes.io/cluster/srgdemo-cluster,Value=owned" "Key=Name,Value=srgdemo-autoscaling-group" --vpc-zone-identifier "subnet-0fb2ebb5882c061f0,subnet-0f0cac4ec6837abed,subnet-0abd7cd806e04c7be"
It can take approximately 5 minutes for nodes to be created and join the cluster.
Retrieve the instance IDs from auto-scaling group
For networking configurations, we will need to know the machine instances in the new Auto Scaling group.
To retrieve the instance IDs:
- Run the command:
# aws autoscaling describe-auto-scaling-instances \ | jq -r '.AutoScalingInstances[] | select(.AutoScalingGroupName=="srgdemo-autoscaling-group").InstanceId'
- Record the returned IDs in the AWS worksheet.
Example command and output:
# aws autoscaling describe-auto-scaling-instances \ | jq -r '.AutoScalingInstances[] | select(.AutoScalingGroupName=="srgdemo-autoscaling-group").InstanceId' i-05662f9ef84c182ca i-07cfcd6716e9890b5 i-08d819b5ccabe83cb
After approximately 5 minutes, the nodes will be created and be joined to the cluster. You can then list all the worker nodes.
To list the worker nodes:
- On the bastion host, run the following command:
# kubectl get nodes
At this point, you should see all nodes listed in the Ready state with the expected Kubernetes version.
Next Step: Configuring Route 53