-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcluster.yaml
More file actions
333 lines (305 loc) · 12.2 KB
/
cluster.yaml
File metadata and controls
333 lines (305 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
tosca_definitions_version: cloudify_dsl_1_3
imports:
- http://www.getcloudify.org/spec/cloudify/4.6/types.yaml
- http://www.getcloudify.org/spec/fabric-plugin/1.5.1/plugin.yaml
- https://raw.githubusercontent.com/cloudify-incubator/cloudify-utilities-plugin/1.15.3/plugin.yaml
- https://raw.githubusercontent.com/cloudify-incubator/cloudify-libvirt-plugin/0.8.1/plugin.yaml
inputs:
# agent settings
agent_user:
default: { get_secret: agent_user }
# you should use such key for kvm host
agent_public_key:
default: { get_secret: agent_key_public }
agent_key_private:
default: { get_secret: agent_key_private }
disk_size:
default: 80GB
# cluster(kvm) settings
cluster_user:
type: string
description: >
Cluster user name.
default: { get_secret: libvirt_cluster_user }
cluster_key:
type: string
description: >
SSH key for cluster user.
default: { get_secret: libvirt_cluster_key }
cluster_host:
type: string
description: >
LibVirt computer ip address.
default: { get_secret: libvirt_cluster_host }
external_ip:
type: string
description: >
List external ip's separated by comma.
default: { get_secret: libvirt_cluster_external_ip }
external_dev:
type: string
description: >
Device with external access (same device as used for cluster_host ip)
default: { get_secret: libvirt_cluster_external_dev }
libvirt_common_network:
type: string
description: >
Manager common network
default: { get_secret: libvirt_common_network }
relationships:
vm_connected_to_storage:
derived_from: cloudify.relationships.contained_in
target_interfaces:
cloudify.interfaces.relationship_lifecycle:
preconfigure:
implementation: scripts/vm_preconfigure.py
executor: central_deployment_agent
inputs: {}
node_types:
agent_domain:
derived_from: cloudify.nodes.Compute
properties:
use_public_ip:
default: false
node_templates:
vm_download:
type: cloudify.nodes.WebServer
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: &fab_env
user: { get_input: cluster_user }
key_filename: { get_input: cluster_key }
host_string: { get_input: cluster_host }
script_path: cluster/libvirt_install.sh
configure:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: *fab_env
script_path: scripts/download_vm.sh
CATALOG_URL: http://repository.cloudifysource.org/cloudify/4.4.0/ga-release
DISK: cloudify-manager-4.4ga.qcow2
manager_network:
type: cloudify.libvirt.network
properties:
libvirt_auth: &libvirt_auth
concat:
- "qemu+ssh://"
- { get_input: cluster_user }
- "@"
- { get_input: cluster_host }
- "/system?sshauth=privkey&keyfile="
- { get_input: cluster_key }
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
params:
name: manager_network
dev: virbr9
forwards:
- mode: nat
ips:
- address: 192.168.149.1
netmask: 255.255.255.0
dhcp:
start: 192.168.149.2
end: 192.168.149.254
relationships:
- target: vm_download
type: cloudify.relationships.depends_on
cloud_init:
type: cloudify.nodes.CloudInit.CloudConfig
properties:
resource_config:
groups:
- { get_input: agent_user }
users:
- name: { get_input: agent_user }
# group with same name as username required for agent running
primary_group: { get_input: agent_user }
groups: wheel
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- { get_input: agent_public_key }
write_files:
- path: /etc/cloudify/kvm.key
owner: cfyuser:cfyuser
permissions: '0400'
content: { get_input: agent_key_private }
- path: /etc/cloudify/kvm.key.pub
owner: cfyuser:cfyuser
permissions: '0400'
content: { get_input: agent_public_key }
disk_clone:
type: cloudify.nodes.ApplicationServer
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: scripts/disk_prepere.py
executor: central_deployment_agent
inputs:
disk_image: { get_attribute: [vm_download, vm_image] }
cloud_init: { get_attribute: [cloud_init, cloud_config ] }
disk_size: { get_input: disk_size }
configure:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: *fab_env
script_path: scripts/copy_disk.py
delete:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: *fab_env
script_path: scripts/remove_disk.sh
relationships:
- target: vm_download
type: cloudify.relationships.depends_on
- target: cloud_init
type: cloudify.relationships.depends_on
base_vm:
type: cloudify.libvirt.domain
properties:
libvirt_auth: *libvirt_auth
agent_config:
install_method: none
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
params:
vcpu: 2
memory_size: 8388608 # 8Gb in Kb
domain_type: kvm
networks:
- network: { get_attribute: [manager_network, resource_id] }
dev: vnet0
relationships:
- target: manager_network
type: cloudify.libvirt.relationships.connected_to
- target: disk_clone
type: vm_connected_to_storage
floating_ip:
type: cloudify.nodes.VirtualIP
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: *fab_env
EXTERNAL_INTERFACE: { get_input: external_dev }
EXTERNAL_IP: { get_input: external_ip }
INTERNAL_IP: { get_attribute: [base_vm, ip] }
script_path: cluster/floating_ip.py
delete:
implementation: fabric.fabric_plugin.tasks.run_script
inputs:
fabric_env: *fab_env
script_path: cluster/floating_ip_delete.py
relationships:
- target: base_vm
type: cloudify.relationships.connected_to
qemu_vm:
type: agent_domain
properties:
use_public_ip: true
agent_config:
user: { get_input: agent_user }
key: { get_input: agent_key_private }
install_method: remote
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: scripts/vm_fillip.py
executor: central_deployment_agent
start:
implementation: terminal.cloudify_terminal.tasks.run
inputs:
terminal_auth: &terminal_auth
user: { get_input: agent_user }
ip: { get_attribute: [SELF, ip] }
key_content: { get_input: agent_key_private }
port: 22
promt_check:
- '$'
calls:
# network fix
- action: sudo ip link set dev eth0 mtu 1400
# space fix
- action: sudo sudo xfs_growfs /
# add additional/support tools
- action: sudo yum install -y openssl-1.0.2k deltarpm nano
# add libvirt dependencies
- action: sudo yum install -y libvirt-devel libvirt libvirt-python
- action: sudo service libvirtd restart
- action: sudo groupadd libvirt
- action: sudo usermod -a -G libvirt cfyuser
- action: sudo usermod -a -G kvm cfyuser
- action: sudo usermod -a -G qemu cfyuser
# enable ssh connect
- action: sudo mkdir -p /etc/cloudify/.ssh/
# enable write for current user, will fix on next step
- action: sudo chmod 777 -R /etc/cloudify/.ssh
# dump ssh key to known_hsot
- action: {concat:["sudo ssh-keyscan -H ", { get_input: cluster_host }, " >> /etc/cloudify/.ssh/known_hosts"]}
- action: sudo chmod 700 /etc/cloudify/.ssh
- action: sudo chmod 600 /etc/cloudify/.ssh/known_hosts
- action: sudo chown cfyuser:cfyuser -R /etc/cloudify/.ssh
# upload plugins
- action: cfy profile use localhost -u admin -p admin -t default_tenant
- action: cfy plugins bundle-upload
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-utilities-plugin/releases/download/1.15.3/plugin.yaml http://repository.cloudifysource.org/cloudify/wagons/cloudify-utilities-plugin/1.15.3/cloudify_utilities_plugin-1.15.3-py27-none-linux_x86_64-centos-Core.wgn
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.8.1/plugin.yaml https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.8.1/cloudify_libvirt_plugin-0.8.1-py27-none-linux_x86_64-centos-Core.wgn
- action: cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.5.0/plugin.yaml https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.5.0/cloudify_kubernetes_plugin-2.5.0-py27-none-linux_x86_64-centos-Core.wgn
# set secrets
- action: sudo cfy secret create agent_key_private -u -f /etc/cloudify/kvm.key
- action: sudo cfy secret create agent_key_public -u -f /etc/cloudify/kvm.key.pub
- action: cfy secret create agent_use_public_ip -u -s "private"
- action: {concat:["cfy secret create agent_user -u -s '", { get_input: agent_user }, "'"]}
- action: cfy secret create bootstrap_hash -u -s "#"
- action: cfy secret create bootstrap_token -u -s "#"
- action: cfy secret create cfy_password -u -s admin
- action: cfy secret create cfy_tenant -u -s default_tenant
- action: cfy secret create cfy_user -u -s admin
- action: cfy secret create kubernetes-admin_client_certificate_data -u -s "#"
- action: cfy secret create kubernetes-admin_client_key_data -u -s "#"
- action: cfy secret create kubernetes_certificate_authority_data -u -s "#"
- action: cfy secret create kubernetes_master_ip -u -s "#"
- action: cfy secret create kubernetes_master_port -u -s "#"
- action: {concat:["cfy secret create libvirt_cluster_external_dev -u -s ", { get_input: external_dev }]}
- action: {concat:["cfy secret create libvirt_cluster_external_ip -u -s '", { get_input: external_ip }, "'"]}
- action: {concat:["cfy secret create libvirt_cluster_host -u -s ", { get_input: cluster_host }]}
- action: {concat:["cfy secret create libvirt_cluster_key -u -s ", { get_input: cluster_key }]}
- action: {concat:["cfy secret create libvirt_cluster_user -u -s ", { get_input: cluster_user }]}
- action: {concat:["cfy secret create libvirt_common_network -u -s ", { get_input: libvirt_common_network }]}
relationships:
- target: base_vm
type: cloudify.relationships.depends_on
- target: floating_ip
type: cloudify.relationships.depends_on
example_node:
type: cloudify.nodes.WebServer
interfaces:
cloudify.interfaces.lifecycle:
configure:
implementation: scripts/vm_check.py
relationships:
- target: qemu_vm
type: cloudify.relationships.contained_in
groups:
vm_scale:
members:
- disk_clone
- base_vm
- floating_ip
- cloud_init
- qemu_vm
policies:
vm_scaling_policy:
type: cloudify.policies.scaling
properties:
default_instances: 1
targets: [vm_scale]