Note
This tutorial assumes that you are working on the master branch of the senlin source code which contains the latest profile samples and policy samples. To clone the latest code base:
$ git clone https://git.openstack.org/openstack/senlin.git
Follow the Installation Guide to install the senlin service.
A profile captures the necessary elements you need to create a node. The
following is a profile specification (spec
for short) that can be used
to create a nova server:
type: os.nova.server
version: 1.0
properties:
name: cirros_server
flavor: 1
image: "cirros-0.3.5-x86_64-disk"
key_name: oskey
networks:
- network: private
metadata:
test_key: test_value
user_data: |
#!/bin/sh
echo 'hello, world' > /tmp/test_file
Note
The above source file can be found in senlin source tree at
/examples/profiles/nova_server/cirros_basic.yaml
.
The spec assumes that:
oskey
, andprivate
, andcirros-0.3.5-x86_64-disk
You may have to change the values based on your environment setup before using this file to create a profile. After the spec file is modified properly, you can use the following command to create a profile object:
$ cd $SENLIN_ROOT/examples/profiles/nova_server
$ openstack cluster profile create --spec-file cirros_basic.yaml myserver
Check the Profiles section in the 3 User References documentation for more details.
With a profile created, we can proceed to create a cluster by specifying the profile and a cluster name.
$ openstack cluster create --profile myserver mycluster
If you don’t explicitly specify a number as the desired capacity of the cluster, senlin won’t create nodes in the cluster. That means the newly created cluster is empty. If you do provide a number as the desired capacity for the cluster as shown below, senlin will create the specified number of nodes in the cluster.
$ openstack cluster create --profile myserver --desired-capacity 1 mycluster
$ openstack cluster show mycluster
For more details, check the Creating a Cluster section in the 3 User References documentation.
Now you can try to change the size of your cluster. To increase the size, use the following command:
$ openstack cluster expand mycluster
$ openstack cluster show mycluster
To decrease the size of the cluster, use the following command:
$ openstack cluster shrink mycluster
$ openstack cluster show mycluster
For more details, please check the Resizing a Cluster section in the 3 User References section.
Yet another way to change the size of a cluster is to use the command
cluster-resize
:
$ openstack cluster resize --capacity 2 mycluster
$ openstack cluster show mycluster
The cluster-resize
command supports more flexible options to control how
a cluster is resized. For more details, please check the
Resizing a Cluster section in the
3 User References section.
Another way to manage cluster node membership is to create a standalone node then add it to a cluster. To create a node using a given profile:
$ openstack cluster node create --profile myserver newnode
$ openstack cluster node show newnode
For other options supported by the node-create
command, please check the
Creating a Node subsection in the
3 User References documentation.
If a node has the same profile type as that of a cluster, you can add the node
to the cluster using the cluster-node-add
command:
$ openstack cluster members add --nodes newnode mycluster
$ openstack cluster members list mycluster
$ openstack cluster show mycluster
$ openstack cluster node show newnode
After the operation is completed, you will see that the node becomes a member of the target cluster, with an index value assigned.
You can also remove a node from a cluster using the cluster-node-del
command:
$ openstack cluster members del --nodes newnode mycluster
$ openstack cluster members list mycluster
$ openstack cluster show mycluster
$ openstack cluster node show newnode
For other cluster membership management commands and options, please check the Cluster Membership section in the 3 User References section.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.