2. Create Autoscale Profile from Cloud-init script

Purpose: The use of cloud-init scripts allows users to flexibly customize parameters and automate the process of setting up network, storage, etc. This script should be tested on Virtual Instances before being used for Autocale Profile creation.

Requirements (Can be ignored if VPC is already available):

Step 1: Go to Autoscaling page > Autoscale Profile > Select Create profile.

Step 2: Configure the profile following fields of information:

SectionFieldDescription

Credentials

Name

Enter profile name or default name will be set.

Configuration

Image

Each OS group will consist of many different versions. The default is the latest version. Select Custom and select the appropriate Custom Image in the list.

Resource type

Each model will configure CPU and RAM differently. Or users can create a model that best suits their needs.

Storage

Policy

Choose the drive policy that suits your needs. The default will be Premium-SSD.

Size (GB)

Increase/decrease/leave the default capacity. The minimum default size will be 40GB.

Network

Subnet

Automatically selected. It can be changed if desired.

Security Group

Automatically selected. It can be changed if desired

User data

Where the cloud-init script is located. When the node starts, the cloud-init will read the metadata provided from the cloud, and initialize the system based on them. Cloud-init is often used for setting up networks, storage, SSH keys, and many other parts of the system.

Sample Cloud-init script: With this sample script, the nodes in one group will run a static website, users can allocate Floating IP to the node and access to the website through that Floating IP.

#cloud-config

# Update apt database on first boot (run 'apt-get update').
# Note, if packages are given, or package_upgrade is true, then
# update will be done independent of this setting.
package_update: true
chpasswd:
  list: |
    root:Welcome***123

# if packages are specified, this package_update will be set to true
# packages may be supplied as a single package name or as a list
# with the format [<package>, <version>] wherein the specific
# package version will be installed.
packages:
  - nginx
  - git
  
# runcmd contains a list of either lists or a string
# each item will be executed in order at rc.local like level with
# output to the console
# - runcmd only runs during the first boot
# - if the item is a list, the items will be properly executed as if
#   passed to execve(3) (with the first arg as the command).
# - if the item is a string, it will be simply written to the file and
#   will be interpreted by 'sh'
runcmd:
  - systemctl enable nginx
  - systemctl start nginx
  - git clone https://github.com/cloudacademy/static-website-example.git
  - cp -r ./static-website-example/* /var/www/html/
  - rm -r ./static-website-example

Step 3: Select Create Profile.

The system will confirm and create profile.

Last updated