Skip to content

Commit f33fb96

Browse files
committed
Update documentation for cluster run
1 parent 5fe845b commit f33fb96

2 files changed

Lines changed: 190 additions & 33 deletions

File tree

README.md

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,82 @@ Description for Network
7979
Update `ip` runtime property in VM by data from network.
8080

8181
## Examples
82-
* [Ubuntu:amd64 vm with scale support](examples/vm_agent.yaml)
82+
83+
### Without external connectivity
84+
8385
* [Ubuntu:amd64 vm with connection by fabric](examples/vm_ssh.amd64.yaml)
8486
* [Ubuntu:arm64 vm with connection by fabric](examples/vm_ssh.arm64.yaml)
8587
* [CentOS:amd64 vm with connection by fabric](examples/vm_centos.amd64.yaml)
86-
* [CentOS:Cluster blueprint, run vm on separate cento host](examples/cluster.yaml)
87-
Has support `floating ips` separated by commas. Look to inputs.
8888

8989
For documentation `backup` / `restore` workflows with noncluster blueprints look to
9090
[Utilities Plugin](https://github.com/cloudify-incubator/cloudify-utilities-plugin/blob/master/cloudify_suspend/README.md).
9191

92+
### With external connectivity
93+
94+
* [CentOS:amd64 vm with scale support](examples/vm_agent.yaml)
95+
* [CentOS:Manager install with kubernetes nested install](examples/cluster.yaml)
96+
97+
Notes for use:
98+
99+
* Enable ssh login between manager and libvirt host without password, by call:
100+
```shell
101+
cat examples/cluster/id_rsa.pub | ssh centos@<manager_host> "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
102+
cat examples/cluster/id_rsa.pub | ssh centos@<libvirt_host> "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
103+
```
104+
105+
* Provide private key '/etc/cloudify/kvm.key' to manager host:
106+
```shell
107+
cat examples/cluster/id_rsa | ssh centos@<manager_host> "cat >> ~/kvm.key && sudo mv kvm.key /etc/cloudify/kvm.key && sudo chown cfyuser:cfyuser /etc/cloudify/kvm.key && sudo chmod 400 /etc/cloudify/kvm.key
108+
```
109+
110+
* Check that manager can connect to virthost by ssh, run on manager:
111+
```shell
112+
sudo su cfyuser -
113+
ssh -i /etc/cloudify/kvm.key centos@<libvirt_host>
114+
```
115+
116+
* You can use any user instead 'centos' with sudo rights without password ('ALL=(ALL) NOPASSWD:ALL' in sudoers).
117+
118+
* Install libvirt client libraries on manager:
119+
```shell
120+
sudo yum install -y libvirt-devel libvirt libvirt-python
121+
sudo service libvirtd restart
122+
sudo groupadd libvirt
123+
sudo usermod -a -G libvirt cfyuser
124+
sudo usermod -a -G kvm cfyuser
125+
sudo usermod -a -G qemu cfyuser
126+
```
127+
128+
* Fix routing on manager for see "external ips" from libvirt host, `192.168.202.0` will be fake network for exteranl ip's.
129+
```shell
130+
sudo route add -net 192.168.202.0 netmask 255.255.255.0 gw <libvirt_host>
131+
```
132+
133+
* If you use openstack for host libvirt host (nested in nested virtualization) attach additional ip's to port:
134+
```shell
135+
openstack port list | grep <libvirt_host> # search for <openstack_port_id>
136+
openstack port set --allowed-address ip-address=192.168.202.16 <openstack_port_id>
137+
openstack port set --allowed-address ip-address=192.168.202.17 <openstack_port_id>
138+
openstack port set --allowed-address ip-address=192.168.202.18 <openstack_port_id>
139+
openstack port set --allowed-address ip-address=192.168.202.19 <openstack_port_id>
140+
openstack port set --allowed-address ip-address=192.168.202.20 <openstack_port_id>
141+
```
142+
143+
* Set default secrets for blueprints:
144+
```shell
145+
cfy profile use <manager_host> -u admin -p admin -t default_tenant
146+
cfy secret create agent_user -u -s "cfyagent"
147+
cfy secret create agent_use_public_ip -u -s "true"
148+
cfy secret create libvirt_cluster_user -u -s "centos"
149+
cfy secret create libvirt_cluster_key -u -s "/etc/cloudify/kvm.key"
150+
cfy secret create libvirt_cluster_host -u -s <libvirt_host>
151+
cfy secret create libvirt_cluster_external_ip -u -s "192.168.202.16,192.168.202.17,192.168.202.18,192.168.202.19,192.168.202.20"
152+
cfy secret create libvirt_cluster_external_dev -u -s "eth0"
153+
cfy secret create agent_key_public -u -f examples/cluster/id_rsa.pub
154+
cfy secret create agent_key_private -u -f examples/cluster/id_rsa
155+
cfy secret create libvirt_common_network -u -s "manager_network"
156+
```
157+
92158
## Wagon creation:
93159
94160
Recommended constraints file for CentOs 7.x and RedHat 7.x is:

examples/cluster.yaml

Lines changed: 121 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# before use:
2-
# * cat examples/cluster/id_rsa.pub | ssh <cluster_user>@<cluster_host> "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
3-
# * and set cluster_key to examples/cluster/id_rsa
41
tosca_definitions_version: cloudify_dsl_1_3
52

63
imports:
@@ -18,8 +15,11 @@ inputs:
1815
agent_public_key:
1916
default: { get_secret: agent_key_public }
2017

18+
agent_key_private:
19+
default: { get_secret: agent_key_private }
20+
2121
disk_size:
22-
default: 24GB
22+
default: 80GB
2323

2424
agent_private_key:
2525
default: { get_secret: agent_private_key }
@@ -37,12 +37,6 @@ inputs:
3737
SSH key for cluster user.
3838
default: { get_secret: libvirt_cluster_key }
3939

40-
manager_network:
41-
type: string
42-
description: >
43-
Manager network.
44-
default: { get_secret: libvirt_common_network }
45-
4640
cluster_host:
4741
type: string
4842
description: >
@@ -61,6 +55,12 @@ inputs:
6155
Device with external access (same device as used for cluster_host ip)
6256
default: { get_secret: libvirt_cluster_external_dev }
6357

58+
libvirt_common_network:
59+
type: string
60+
description: >
61+
Manager common network
62+
default: { get_secret: libvirt_common_network }
63+
6464
relationships:
6565

6666
vm_connected_to_storage:
@@ -99,10 +99,10 @@ node_templates:
9999
inputs:
100100
fabric_env: *fab_env
101101
script_path: scripts/download_vm.sh
102-
CATALOG_URL: https://cloud.centos.org/centos/7/images/
103-
DISK: CentOS-7-x86_64-GenericCloud-1805.qcow2
102+
CATALOG_URL: http://repository.cloudifysource.org/cloudify/4.4.0/ga-release
103+
DISK: cloudify-manager-4.4ga.qcow2
104104

105-
common_network:
105+
manager_network:
106106
type: cloudify.libvirt.network
107107
properties:
108108
libvirt_auth: &libvirt_auth
@@ -118,15 +118,16 @@ node_templates:
118118
create:
119119
inputs:
120120
params:
121-
dev: virbr1
121+
resource_id: manager_network
122+
dev: virbr9
122123
forwards:
123124
- mode: nat
124125
ips:
125-
- address: 192.168.141.1
126+
- address: 192.168.149.1
126127
netmask: 255.255.255.0
127128
dhcp:
128-
start: 192.168.141.2
129-
end: 192.168.141.254
129+
start: 192.168.149.2
130+
end: 192.168.149.254
130131
relationships:
131132
- target: vm_download
132133
type: cloudify.relationships.depends_on
@@ -146,6 +147,15 @@ node_templates:
146147
sudo: ['ALL=(ALL) NOPASSWD:ALL']
147148
ssh-authorized-keys:
148149
- { get_input: agent_public_key }
150+
write_files:
151+
- path: /etc/cloudify/kvm.key
152+
owner: cfyuser:cfyuser
153+
permissions: '0400'
154+
content: { get_input: agent_private_key }
155+
- path: /etc/cloudify/kvm.key.pub
156+
owner: cfyuser:cfyuser
157+
permissions: '0400'
158+
content: { get_input: agent_public_key }
149159

150160
disk_clone:
151161
type: cloudify.nodes.ApplicationServer
@@ -186,13 +196,13 @@ node_templates:
186196
inputs:
187197
params:
188198
vcpu: 2
189-
memory_size: 1048576
199+
memory_size: 8388608 # 8Gb in Kb
190200
domain_type: kvm
191201
networks:
192-
- network: { get_attribute: [common_network, resource_id] }
202+
- network: { get_attribute: [manager_network, resource_id] }
193203
dev: vnet0
194204
relationships:
195-
- target: common_network
205+
- target: manager_network
196206
type: cloudify.libvirt.relationships.connected_to
197207
- target: disk_clone
198208
type: vm_connected_to_storage
@@ -218,19 +228,100 @@ node_templates:
218228
- target: base_vm
219229
type: cloudify.relationships.connected_to
220230

231+
qemu_vm:
232+
type: agent_domain
233+
properties:
234+
use_public_ip: true
235+
agent_config:
236+
user: { get_input: agent_user }
237+
key: { get_input: agent_private_key }
238+
install_method: remote
239+
interfaces:
240+
cloudify.interfaces.lifecycle:
241+
create:
242+
implementation: scripts/vm_fillip.py
243+
executor: central_deployment_agent
244+
start:
245+
implementation: terminal.cloudify_terminal.tasks.run
246+
inputs:
247+
terminal_auth: &terminal_auth
248+
user: { get_input: agent_user }
249+
ip: { get_attribute: [SELF, ip] }
250+
key_content: { get_input: agent_private_key }
251+
port: 22
252+
promt_check:
253+
- '$'
254+
calls:
255+
# network fix
256+
- action: sudo ip link set dev eth0 mtu 1400
257+
# space fix
258+
- action: sudo sudo xfs_growfs /
259+
# add additional/support tools
260+
- action: sudo yum install -y openssl-1.0.2k deltarpm nano
261+
# add libvirt dependencies
262+
- action: sudo yum install -y libvirt-devel libvirt libvirt-python
263+
- action: sudo service libvirtd restart
264+
- action: sudo groupadd libvirt
265+
- action: sudo usermod -a -G libvirt cfyuser
266+
- action: sudo usermod -a -G kvm cfyuser
267+
- action: sudo usermod -a -G qemu cfyuser
268+
# upload plugins
269+
- action: cfy profile use localhost -u admin -p admin -t default_tenant
270+
- action: cfy plugins bundle-upload
271+
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-utilities-plugin/releases/download/1.9.2/plugin.yaml http://repository.cloudifysource.org/cloudify/wagons/cloudify-utilities-plugin/1.9.2/cloudify_utilities_plugin-1.9.2-py27-none-linux_x86_64-centos-Core.wgn
272+
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.5.0/plugin.yaml https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.5.0/cloudify_libvirt_plugin-0.5.0-py27-none-linux_x86_64-centos-Core.wgn
273+
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.3.1/plugin.yaml https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.3.1/cloudify_kubernetes_plugin-2.3.1-py27-none-linux_x86_64-centos-Core.wgn
274+
# set secrets
275+
- action: sudo cfy secret create agent_key_private -u -f /etc/cloudify/kvm.key
276+
- action: sudo cfy secret create agent_key_public -u -f /etc/cloudify/kvm.key.pub
277+
- action: cfy secret create agent_use_public_ip -u -s "private"
278+
- action: {concat:["cfy secret create agent_user -u -s '", { get_input: agent_user }, "'"]}
279+
- action: cfy secret create bootstrap_hash -u -s "#"
280+
- action: cfy secret create bootstrap_token -u -s "#"
281+
- action: cfy secret create cfy_password -u -s admin
282+
- action: cfy secret create cfy_tenant -u -s default_tenant
283+
- action: cfy secret create cfy_user -u -s admin
284+
- action: cfy secret create kubernetes-admin_client_certificate_data -u -s "#"
285+
- action: cfy secret create kubernetes-admin_client_key_data -u -s "#"
286+
- action: cfy secret create kubernetes_certificate_authority_data -u -s "#"
287+
- action: cfy secret create kubernetes_master_ip -u -s "#"
288+
- action: cfy secret create kubernetes_master_port -u -s "#"
289+
- action: {concat:["cfy secret create libvirt_cluster_external_dev -u -s ", { get_input: external_dev }]}
290+
- action: {concat:["cfy secret create libvirt_cluster_external_ip -u -s '", { get_input: external_ip }, "'"]}
291+
- action: {concat:["cfy secret create libvirt_cluster_host -u -s ", { get_input: cluster_host }]}
292+
- action: {concat:["cfy secret create libvirt_cluster_key -u -s ", { get_input: cluster_key }]}
293+
- action: {concat:["cfy secret create libvirt_cluster_user -u -s ", { get_input: cluster_user }]}
294+
- action: {concat:["cfy secret create libvirt_common_network -u -s ", { get_input: libvirt_common_network }]}
295+
relationships:
296+
- target: base_vm
297+
type: cloudify.relationships.depends_on
298+
- target: floating_ip
299+
type: cloudify.relationships.depends_on
300+
221301
example_node:
222302
type: cloudify.nodes.WebServer
223303
interfaces:
224304
cloudify.interfaces.lifecycle:
225-
start:
226-
implementation: terminal.cloudify_terminal.tasks.run
227-
inputs:
228-
terminal_auth:
229-
user: { get_input: agent_user }
230-
key_content: { get_input: agent_private_key }
231-
ip: { get_attribute: [floating_ip, external_ip] }
232-
calls:
233-
- action: uname -a
305+
configure:
306+
implementation: scripts/vm_check.py
234307
relationships:
235-
- target: floating_ip
308+
- target: qemu_vm
236309
type: cloudify.relationships.contained_in
310+
311+
groups:
312+
313+
vm_scale:
314+
members:
315+
- disk_clone
316+
- base_vm
317+
- floating_ip
318+
- cloud_init
319+
- qemu_vm
320+
321+
policies:
322+
323+
vm_scaling_policy:
324+
type: cloudify.policies.scaling
325+
properties:
326+
default_instances: 1
327+
targets: [vm_scale]

0 commit comments

Comments
 (0)