cloudify - 如何在 Cloudify 中正确地自动扩展虚拟机组?
问题描述
我正在使用 cloudify 社区版本 19.01.24。
试图弄清楚如何自动扩展一组两个虚拟机。到目前为止,这是我想出的(跳过不相关的部分):
monitored_vm1_port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: *openstack_config
relationships:
- type: cloudify.relationships.contained_in
target: proxy_server_network
monitored_vm2_port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: *openstack_config
relationships:
- type: cloudify.relationships.contained_in
target: proxy_server_network
monitored_vm1_host:
type: cloudify.openstack.nodes.Server
properties:
image: { get_input: image }
flavor: { get_input: flavor }
resource_id: { concat: ['monitored_vm1-', { get_input: client_name }] }
agent_config:
user: { get_input: agent_user }
key: { get_property: [ keypair, private_key_path ] }
interfaces:
cloudify.interfaces.monitoring_agent:
install:
implementation: diamond.diamond_agent.tasks.install
inputs:
diamond_config:
interval: 10
start: diamond.diamond_agent.tasks.start
stop: diamond.diamond_agent.tasks.stop
uninstall: diamond.diamond_agent.tasks.uninstall
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
NetworkCollector: {}
relationships:
- type: cloudify.openstack.server_connected_to_port
target: monitored_vm1_port
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
monitored_vm2_host:
type: cloudify.openstack.nodes.Server
properties:
image: { get_input: image }
flavor: { get_input: flavor }
resource_id: { concat: ['monitored_vm2-', { get_input: client_name }] }
agent_config:
user: { get_input: agent_user }
key: { get_property: [ keypair, private_key_path ] }
interfaces:
cloudify.interfaces.monitoring_agent:
install:
implementation: diamond.diamond_agent.tasks.install
inputs:
diamond_config:
interval: 10
start: diamond.diamond_agent.tasks.start
stop: diamond.diamond_agent.tasks.stop
uninstall: diamond.diamond_agent.tasks.uninstall
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
NetworkCollector: {}
relationships:
- type: cloudify.openstack.server_connected_to_port
target: monitored_vm2_port
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
groups:
vm_group:
members: [monitored_vm1_host, monitored_vm2_host]
scale_up_group:
members: [monitored_vm1_host, monitored_vm2_host]
policies:
auto_scale_up:
type: scale_policy_type
properties:
policy_operates_on_group: true
scale_limit: 2 # max additional instances
scale_direction: '<'
scale_threshold: 31457280
service_selector: .*monitored_vm1_host.*network.eth0.rx.bit
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: 1
scalable_entity_name: vm_group
scale_compute: true
policies:
vm_group_scale_policy:
type: cloudify.policies.scaling
properties:
default_instances: 1
targets: [vm_group]
因此蓝图已正确部署,并且正在根据指定条件(VM 界面上的流量)触发扩展工作流,但在创建新 VM 实例期间失败,并出现以下错误:
2019-11-18 14:54:46,591:ERROR: Task nova_plugin.server.create[f736f81c-7f8c-4f82-a280-8352c1d01bff] raised:
Traceback (most recent call last):
(...)
NonRecoverableError: Port 3b727b5e-a2ec-47cc-b711-37cb80a7b4e5 is still in use. [status_code=409]
看起来 Cloudify 正在尝试使用现有端口生成新实例,这很奇怪。所以我想,也许我应该明确地将 VM 的端口也放在伸缩组中,以便将它们与 VM 一起复制。像这样尝试过:
vm_group:
members: [monitored_vm1_host, monitored_vm1_port, monitored_vm2_host, monitored_vm2_port]
但在这种情况下,我已经在蓝图验证阶段收到关于一些缺失对象关系的错误:
Invalid blueprint - Node 'monitored_vm1_host' and 'monitored_vm1_port' belong to some shared group but they are not contained in any shared node, nor is any ancestor node of theirs.
in: /opt/manager/resources/blueprint-with-scaling-d79fed3d-0b3b-4459-a851-fedd9ecf50c6/blueprint-with-scaling.yaml
我浏览了文档和我能找到的任何示例(没有很多),但我不清楚。
我怎样才能让它正确缩放?
解决方案
正如您所说,您遇到了第一个错误,因为 Cloudify 尝试扩展 VM 并将其连接到已经绑定到第一个 VM 的端口。
第二个错误表示如果端口不依赖于也被缩放的节点,则无法缩放端口,这是为了避免无法缩放的资源规模。
对此的解决方案是,拥有一个 cloudify.nodes.Root 类型的节点并通过端口关系连接到它,如果端口依赖于该节点并且该节点将成为缩放组的一部分,您将能够进行缩放.
你的蓝图会是这样的:
my_relationship_node:
type: cloudify.nodes.Root
port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: *openstack_config
relationships:
- type: cloudify.relationships.connected_to
target: public_network
- type: cloudify.relationships.depends_on
target: public_subnet
- type: cloudify.openstack.port_connected_to_security_group
target: security_group
- type: cloudify.openstack.port_connected_to_floating_ip
target: ip
- type: cloudify.relationships.contained_in
target: my_relationship_node
我希望它有所帮助。
推荐阅读
- reactjs - 如果使用带有元素样式 Reactjs 的 useRef() 条件,UI 不会更新
- azure - 为什么此 Azure 资源管理器模板验证失败?
- kubernetes - Kubernetes 生命周期命令未运行
- node.js - 如何在 MongoDB 中管理连接
- r - 匹配相同的列
- python - 从 Pandas Dataframe 创建 Networkx 有向图时如何创建多线节点标签
- python - 如何使用moviepy反转视频和音频剪辑?
- sql - 如何在Postgres中按年月按最大(日期)组获取行?
- python - 我如何检查指定用户是否是有效用户(也在服务器中)(discord.py)
- swift - 使用 PropertyListDecoder 使用 swift Codable 解析 plist 文件并维护字典的排序