2. Tạo Autoscale Profile từ Cloud-init script

Mục đích: Việc dùng cloud-init script giúp người dùng có thể tự do thay đổi các thông số, tự động hóa quá trình setup network, storage,... một cách linh hoạt. Đoạn script này nên được thử nghiệm trên các Virtual Instances đảm bảo hoạt động tốt trước khi dùng cho việc tạo Autocale Profile.

Điều kiện cần thiết (Có thể bỏ qua nếu VPC đã có sẵn):

Bước 1: Truy cập trang Autoscale Profile > Chọn Create profile.

Bước 2: Cấu hình các thông tin sau:

SectionFieldDescription

Credentials

Name

Nhập tên profile hoặc mặc định hệ thống sẽ tự đặt cho người dùng.

Authentication

  • Đối với Openstack Platform, người dùng sẽ có tùy chọn SSH. (Yêu cầu VPC đã có sẵn SSH Key)

  • Đối với VMware Platform, người dùng sẽ có tùy chọn Password.

  • Ngoài ra, nếu người dùng không có nhu cầu sử dụng thì có thể chọn None để không áp dụng tùy chọn nào.

Configuration

Image

Mỗi nhóm OS sẽ gồm nhiều phiên bản khác nhau, mặc định là phiên bản mới nhất trên hệ thống. Ở đây ta sẽ chọn Custom và lựa chọn Custom Image phù hợp trong danh sách.

Resource type

Mỗi dòng máy sẽ cấu hình CPU, RAM khác nhau. Hoặc người dùng có thể tự tạo một dòng máy phù hợp nhất với nhu cầu.

Storage

Policy

Chọn policy ổ đĩa phù hợp với nhu cầu. Mặc định sẽ là Premium-SSD.

Size (GB)

Tăng giảm dung lượng hoặc để dung lượng mặc định, mặc định tối thiểu sẽ là 40GB.default size will be 40GB.

Network

Subnet

Sẽ được tự động chọn dựa trên network của VPC, có thể thay đổi nếu muốn.

Security Group

Tương tự như Subnet, Security Group cũng sẽ được tự động lựa chọn, và người dùng cũng có thể thay đổi theo nhu cầu.d

User data

Nơi chứa cloud-init script. Khi node khởi động, cloud-init sẽ đọc các metadata được cung cấp từ cloud, và khởi tạo hệ thống dựa trên chúng. Cloud-init thường được dùng với mục đích setup network, storage, SSH keys, và nhiều phần khác của hệ thống.

Cloud-init script mẫu: Với đoạn script mẫu này, các node trong group sẽ chạy một static website, người dùng có thể thực hiện Allocate Floating IP cho node và thực hiện truy cập vào website thông qua 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

Bước 4: Chọn Create Profile.

Hệ thống sẽ xác nhận và tiến hành khởi tạo profile.

Last updated