Overview
Instance Pools
Exoscale Instance Pools are a service to provision groups of identical Compute instances automatically. You can define a number of instances in the pool and the service will keep the required number up and running for you in order to achieve:
- High availability: using an Instance Pool ensures that the target quantity of instances is running.
- Elasticity: Instance Pools can be scaled up and down dynamically so the number of instances matches the actual load for better cost efficiency.
Getting Started
Before getting started with Instance Pools, please note the following aspects and restrictions:
- Instance Pools and their managed Compute instances cannot span multiple Exoscale zones, and cannot be migrated to another zone after they are created.
- Instance Pool member instances might have different types. Updating the instance type applies only to new members. Existing members remain untouched.
- If an Instance Pool is referenced by a Network Load Balancer service, it cannot be deleted.
You can create an Instance Pool from the Instance Pools section in the Portal under COMPUTE in the main navigation. You can also use the CLI.
Here is an example of Instance Pool creation using the CLI:
$ exo compute instance-pool create web \
--zone ch-gva-2 \
--size 3 \
--description "Web servers" \
--instance-type medium \
--template "Linux Ubuntu 20.04 LTS 64-bit" \
--security-group web \
--ssh-key admin \
--ipv6
✔ Creating Instance Pool "web"... 33s
┼──────────────────────┼──────────────────────────────────────┼
│ ID │ ab8fbe95-72d4-0703-fcae-6401540d86ff │
│ Name │ web │
│ Description │ Web servers │
│ Instance Type │ standard.medium │
│ Template │ Linux Ubuntu 20.04 LTS 64-bit │
│ Zone │ ch-gva-2 │
│ Anti-Affinity Groups | n/a │
│ Security Groups │ web │
│ Private Networks │ n/a │
│ Elastic IPs │ n/a │
│ IPv6 │ true │
│ SSH Key │ admin │
│ Size │ 3 │
│ Disk Size │ 50 GiB │
│ Instance Prefix │ pool │
│ State │ running │
│ Labels │ n/a │
│ Instances │ pool-ab8fb-xbedt │
│ │ pool-ab8fb-obain │
│ │ pool-ab8fb-cjrfw │
┼──────────────────────┼──────────────────────────────────────┼
NOTE - Instance Pool size is constrained by your organization’s resource quotas. If you want to scale an Instance Pool up, make sure your account’s instance quota allows you to do so prior to attempt scaling up. You can request a quota increase if necessary.If an Instance Pool needs to be deployed to a dedicated hypervisor, specify the
--deploy-target
flag.
Managing Instance Pools
In addition to normal CRUD operations, the following actions are available:
scale
: scales an Instance Pool to a desired number of instancesevict
: evicts specific members of an Instance Pool, shrinking its size.
Retrieve Instance Pool information
You can access an expanded view of an instance pool to retrieve its properties.
Click on on the instance pool name in the instance pools list view
on the Portal under COMPUTE, or use the command
exo compute instance-pool show
in the CLI:
$ exo compute instance-pool show --zone ch-gva-2 web
┼──────────────────────┼──────────────────────────────────────┼
│ INSTANCE POOL │ │
┼──────────────────────┼──────────────────────────────────────┼
│ ID │ ab8fbe95-72d4-0703-fcae-6401540d86ff │
│ Name │ web │
│ Description │ Web servers │
│ Instance Type │ standard.medium │
│ Template │ Linux Ubuntu 20.04 LTS 64-bit │
│ Zone │ ch-gva-2 │
│ Anti-Affinity Groups | n/a │
│ Security Groups │ web │
│ Private Networks │ n/a │
│ Elastic IPs │ n/a │
│ IPv6 │ true │
│ SSH Key │ admin │
│ Size │ 3 │
│ Disk Size │ 50 GiB │
│ Instance Prefix │ pool │
│ State │ running │
│ Labels │ n/a │
│ Instances │ pool-ab8fb-xbedt │
│ │ pool-ab8fb-obain │
│ │ pool-ab8fb-cjrfw │
┼──────────────────────┼──────────────────────────────────────┼
Update an Instance Pool’s properties
The following properties can be updated in place for an Instance Pool:
- Name
- Description
- Deploy Target
- IPv6 support
- User Data
- Labels
- Managed Compute instances prefix
- Managed Compute instances template
- Managed Compute instances type
- Managed Compute instances Anti-Affinity Groups
- Managed Compute instances Elastic IPs
- Managed Compute instances Private Networks
- Managed Compute instances Security Groups
- Managed Compute instances prefix
- Managed Compute instances SSH key
- Managed Compute instances Storage volume size
To update an instance pool, click on the instance pool name on the instance pools list in the Portal, then click on the UPDATE POOL button in the top right of the header.
In the CLI, use the exo compute instance-pool update
command:
$ exo compute instance-pool update web --zone ch-gva-2 --disk-size 20
✔ Updating Instance Pool "web"... 6s
┼──────────────────────┼──────────────────────────────────────┼
│ INSTANCE POOL │ │
┼──────────────────────┼──────────────────────────────────────┼
│ ID │ ab8fbe95-72d4-0703-fcae-6401540d86ff │
│ Name │ web │
│ Description │ Web servers │
│ Service Offering │ Medium │
│ Template │ Linux Ubuntu 20.04 LTS 64-bit │
│ Zone │ ch-gva-2 │
│ Anti-Affinity Groups | group1 │
│ Security Groups │ web │
│ Private Networks │ n/a │
│ Elastic IPs │ n/a │
│ IPv6 │ true │
│ SSH Key │ admin │
│ Size │ 3 │
│ Disk Size │ 20 GiB │
│ Instance Prefix │ pool │
│ State │ running │
│ Labels │ n/a |
│ Instances │ pool-ab8fb-xbedt │
│ │ pool-ab8fb-obain │
│ │ pool-ab8fb-cjrfw │
┼──────────────────────┼──────────────────────────────────────┼
NOTE - When updating Instance Pool properties related to its managed Compute instances (such as template, type or storage volume size), the new value will be taken into account only for newly created instances. Current instances in the pool will not be affected by the change. These instances will need to be destroyed manually, so that the Instance Pool manager can replace them with up-to-date versions.
NOTE - In the event an Instance Pool scales down, the excess managed Compute instances are deleted, starting with the oldest instances. This feature can be used to quickly recycle the Instance Pool members by temporarily scaling up the size of the pool to double its size, and after the new Compute instances are operational, scale down the pool to its original size to automatically delete the stale Compute instances.
Delete an Instance Pool
To delete an Instance Pool, click on the instance pool name on the instance pools list in the Portal, then click on the DELETE POOL button in the top right of the header.
You can use the exo compute instance-pool delete
command in the
CLI.
WARNING - Deleting an Instance Pool also deletes its managed Compute instances.
Labels
Instance Pool supports labels that will also be propagated to the member instances.
The Instance Pool lifecycle
An Instance Pool’s lifecycle can be described by the following states:
State | Description |
---|---|
CREATING | The Instance Pool is being provisioned for the first time. |
SCALING UP | The Instance Pool is being scaled up following its creation or a user’s scaling request, creating Compute instances to meet the requested pool size. |
RUNNING | The Instance Pool is in a stable state, all of its managed Compute instances are running. |
SCALING DOWN | The Instance Pool is being scaled down following a user’s scaling request, deleting Compute instances to meet the requested pool size. |
DESTROYING | The Instance Pool is being destroyed. |
Instance Pool prefixes
By default, Instance Pool-managed Compute instances are named as:
pool-<first letters of the ID of the managing Instance Pool>-<random unique instance ID>
.
This naming pattern can be customized by passing the --instance-prefix
parameter during an Instance Pool creation or update. For example, if you pass the string applications
to --instance-prefix
, pool
will be replaced by applications
in the instance names.
Going Further
- If you intend to deploy a cluster using Instance Pools, you can leverage the Exoscale Private Networks functionality for high performance and low latency connectivity between your Instance Pool member instances.
- Provision Instance Pools using the Exoscale Terraform provider.
Pricing
This service is offered free of charge, only the resources consumed as a byproduct of running Instance Pools (such as Compute instances, storage, egress network traffic) are charged at our regular rates.
Resources
- Create an Instance Pool in the Portal.
- Instance Pools API documentation.
Anti-Affinity Groups
Anti-Affinity Groups let you specify which instances should run on separate hosts. In case of a HA cluster for example, you could keep your instances on separate hypervisors to ensure a more reliable fault tolerance.
Manage Anti-Affinity Groups
From COMPUTE in the Portal, select the ANTI-AFFINITY section. You can then create, delete or view the details of your groups and in the detail of a group you can see the instances attributed to that group.
Associating Anti-Affinity Groups During Instance Creation
When you create an instance, you will see a list of your Anti-Affinity Groups. You can choose to associate your instance to any number of groups. Please note that you will have this option only during the instance creation.
Although there is no limit to how many groups you may have, an Anti-Affinity Group cannot contain more than 8 instances. If a group is full, it will not be presented in the available options.
How to Use Anti-Affinity Groups
Two instances on the same group will be spawned on different hypervisors.
After creation, your instance will stay on its hypervisor for its entire life. To define a proper distribution strategy, it is best practice to define your groups in advance.
An example of how Anti-Affinity Groups may prove useful would be to associate your instances to different groups based on their role. You could define one Anti-Affinity Group for the database servers and another Anti-Affinity Group for the front servers. In this way, any issue on one hypervisor will not affect your entire infrastructure.
If you find yourself needing more than 8 instances per Anti-Affinity Group, a possible strategy would be to split a group in two to grant the best spread possible.
Cloud-init
User data is a way to automatically provision your instance with additional software or settings. You can provide a set of commands (a script) or enter cloud-config information as YAML. It is important to understand that the User Data provided will be used only when the machine is created.
Cloud-init Datasources
Historically, Exoscale templates used the Cloudstack
cloud-init datasource.
Since Cloud Init version 19.3
, Exoscale has its own datasource.
Although the new Exoscale datasource is backwards-compatible with the Cloudstack datasource, new features such as managed private networks require using the Exoscale datasource. We recommend using the Exoscale datasource for all installations.
Adding User Data
When you create a new instance, the wizard lets you enter user data at the bottom of the form.
You can find everything that can be done with user data and cloud-init in the documentation
Example: Script
In this example, we install screen
and htop
on an Ubuntu instance using Apt
after having
upgraded all packages on an Debian/Ubuntu system.
Add the following to the User Data
field to install the screen
package:
#cloud-config
runcmd:
- apt-get --yes upgrade
- apt-get --yes install screen htop
NOTE - Cloud-init has pre-built directives for many items. Therefore, the previous scripts launched as command lines can be achieved with:
#cloud-config
package_upgrade: true
packages:
- screen
- htop
Example: Cloud-Config YAML
We will set our locale to en_US.UTF-8 using cloud-config YAML. Add the following YAML in the user data:
#cloud-config
locale: "en_US.UTF-8"
Example: Installing WordPress
See our WordPress tutorial.
Querying the User Data and Meta Data from the Instance
User Data
and Meta Data
can be retrieved from an instance to
integrate in scripts for example or configuration management tools.
This information is published on the Link Local Address
169.254.169.254 which is private between the hypervisor and the
running instance.
User Data (cloud-config contents)
curl http://metadata.exoscale.com/latest/user-data
Meta Data (instance size or IP address)
curl http://metadata.exoscale.com/latest/meta-data
curl http://metadata.exoscale.com/latest/meta-data/public-ipv4
The list of available metadata is:
metadata name | description |
---|---|
availability-zone | The zone - datacenter in which the instance is running |
cloud-identifier | Returns “Exoscale Compute Platform” if running on Exoscale |
instance-id | The unique identifier or UUID for the instance |
local-hostname | The name of the instance as set during the add instance phase |
local-ipv4 | The primary network IP address of the instance |
public-hostname | Same as local-hostname |
public-ipv4 | The public IP address of the instance |
public-keys | The associated SSH public key associated to the instance |
service-offering | The size of the instance |
vm-id | Same as instance-id |
Adding Password Management to Your Templates
Exoscale provides an optional password reset feature that allows users to set a temporary admin or root password as well as reset the existing admin or root password from the Exoscale Portal.
This password is provided to an instance via the Link Local Address 169.254.169.254 on port 8080:
curl --header "DomU_Request: send_my_password" http://169.254.169.254:8080
After the password is retrieved and changed on the running instance, issue a command to indicate that the password was saved and that it can be deleted:
curl --header "DomU_Request: saved_password" http://169.254.169.254:8080
NOTES - Linux-based distributions with a standard cloud-Init implementation will follow the process outlined above automatically if the system allows for password-based logins. Passwords are only provided one time back to the user who starts or resets an instance and are not persisted at the orchestration layer.