架构
术语
- 集群(Cluster)
- 集群
- 节点(node)
- 比如虚拟机
- 配置(profile)
- 集群的规格, 类似于虚拟机的 flavor, 比如有 nova server, heat stack
- 策略(policy)
- 集群的更新策略, 比如自动伸缩,负载均衡,高可用,我理解策略决定了集群是什么样的集群,单个集群可以附加不同的策略
basic
创建 profile
$ cat senlin_basic.yaml
type: os.nova.server
version: 1.0
properties:
name: cirros_server
flavor: fabian_test
image: "cirros-0.3.4-x86_64-uec"
key_name: mykey
networks:
- network: private
metadata:
test_key: test_value
user_data: >
#!/bin/bash
echo 'hello, world' > /tmp/test_file
$ senlin profile-create -s senlin_basic.yaml myprofile
创建 cluster
$ senlin cluster-create -p myprofile mycluster
扩展集群
$ senlin cluster-scale-out mycluster
desired_capacity
变为 1 nova list 中显示创建了一个新的节点
缩小集群
$ senlin cluster-scale-in mycluster
desired_capacity
变为 0 nova list 中显示删除一个节点
改变集群大小
$ senlin cluster-resize --capacity 4 mycluster
desired_capacity
变为 4 nova list 中显示有四个节点
创建一个节点
$ senlin node-create -p myprofile newnode
$ senlin node-show newnode
增加一个节点到集群
$ senlin cluster-node-add -n newnode mycluster
$ senlin node-show myserver
$ senlin node-show newnode
从集群删除一个节点
$ senlin cluster-node-del -n newnode mycluster
$ senlin node-show myserver
$ senlin node-show newnode
policy
创建策略
模板文件
# 策略类型,可通过 senlin policy-type-list查看支持的策略
type: senlin.policy.deletion
version: 1.0
description: 一个简单的删除最老节点的删除策略
properties:
# 删除条件:删除最旧的节点, 可选的值为
# OLDEST_FIRST, OLDEST_PROFILE_FIRST, YOUNGEST_FIRST, RANDOM
criteria: OLDEST_FIRST
# 从集群删除节点后否销毁节点
destroy_after_deletion: True
# Length in number of seconds before the actual deletion happens
# This param buys an instance some time before deletion
grace_period: 60
# Whether the deletion will reduce the desired capacity of
# the cluster as well
reduce_desired_capacity: False
根据模板创建文件
$ senlin policy-create -s ~/m8x/senlin_policy.yaml mypolicy
$ openstack cluster policy show mypolicy
附加策略到集群上
$ senlin cluster-policy-attach -p mypolicy mycluster