Open topic with navigation

# 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.

Before proceeding, verify that the correct tag has been assigned to the VPC.
To create the Auto Scaling group using the web UI:

1. Using the Find Services search tool, locate and browse to the EC2 dashboard.
2. In the left navigation panel, under Auto Scaling, select Auto Scaling Groups.
3. On the landing page, click Create Auto Scaling Group to launch the creation wizard.

If no Auto Scaling groups have been created yet, the introduction to Auto Scaling implementation in AWS is displayed.

1. On the Choose Launch template or configuration page, enter values for the following:
   1. Name: Enter a descriptive name for the Auto Scaling group.
   2. Under Launch template, select the launch template you created previously.

2. Click Next.
3. On the Configure settings page, enter values for the following:
   1. VPC: Choose the previously-created VPC recorded in the AWS worksheet.
   2. Subnets: Select all 3 private subnets (recorded on the AWS worksheet).

4. Click Next.

5. On the Configure advanced options page, leave all values at default and click Next.

6. 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.)

7. Click Next.

8. On the Add Notifications page, ignore all settings and click Next.

9. On the Add Tags page, add tags as follows:

   1. Add the mandatory tag key: `kubernetes.io/cluster/<your cluster name>` with value: `owned` (replace `<your cluster name>` with your actual cluster name).

   2. Optionally, add these tags as desired:

      1. Key: `Name` with value: derived from the auto-scaling group name.
      2. Key: `owner` with value: corresponding to you.
   3. For all new tags you add, select the Tag new instances checkbox so new instances are automatically tagged.
10. Click Next.

1. On the Review page, verify your settings, and then click Create Auto Scaling Group.

1. 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.

1. From the Instances tab, record all instance IDs in the AWS worksheet.

To create the Auto Scaling group using the CLI:

1. 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:

1. Run the command:

       # aws autoscaling describe-auto-scaling-instances \
       | jq -r '.AutoScalingInstances[] | select(.AutoScalingGroupName=="srgdemo-autoscaling-group").InstanceId'

2. 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:

1. 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