Replica Scaling of Policy Container
[oom.git] / message-router-blueprint.yaml
1 tosca_definitions_version: cloudify_dsl_1_3
2
3 description: >
4   This example deploys the OOM Message Router application. Each service/deployment pair is associated with a single Kubernetes node.
5   Node template naming convention: PROVISIONINGAPI_RESOURCETYPE_APPLICATIONCOMPONENT
6   The following resources are created:
7   - Security Group
8   - openstack_port_zookeeper - NIC that connects to the Openstack Server
9   - openstack_port_kafka - NIC that connects to the Openstack Server
10   - openstack_port_dmaap - NIC that connects to the Openstack Server
11   - openstack_server_zookeeper - a VM that a Kubernetes Node is installed on.
12   - openstack_server_kafka - a VM that a Kubernetes Node is installed on.
13   - openstack_server_dmaap - a VM that a Kubernetes Node is installed on.
14   - kubernetes_node_zookeeper - a Kubernetes node that will join the Kubernetes cluster.
15   - kubernetes_node_kafka - a Kubernetes node that will join the Kubernetes cluster.
16   - kubernetes_node_dmaap - a Kubernetes node that will join the Kubernetes cluster.
17   - kubernetes_deployment_zookeeper - a Kubernetes deployment.
18   - kubernetes_deployment_kafka - a Kubernetes deployment.
19   - kubernetes_deployment_dmaap - a Kubernetes deployment.
20   - kubernetes_service_zookeeper - a Kubernetes service.
21   - kubernetes_service_kafka - a Kubernetes service.
22   - kubernetes_service_dmaap - a Kubernetes service.
23   The following pre-setup steps are assumed, but not required:
24   - Create Cloudify Example Environment: https://github.com/cloudify-examples/cloudify-environment-setup.
25   - Create Kubernetes Cluster: https://github.com/cloudify-examples/simple-kubernetes-blueprint.
26
27 imports:
28   - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml
29   # Plugin required: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/releases/download/2.2.0/cloudify_openstack_plugin-2.2.0-py27-none-linux_x86_64-centos-Core.wgn
30   - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-openstack-plugin/2.2.0/plugin.yaml
31   # Plugin required: https://github.com/cloudify-incubator/cloudify-utilities-plugin/releases/download/1.2.5/cloudify_utilities_plugin-1.2.5-py27-none-linux_x86_64-centos-Core.wgn
32   - https://raw.githubusercontent.com/cloudify-incubator/cloudify-utilities-plugin/1.2.5/plugin.yaml
33   # Plugin required: https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/1.2.0/cloudify_kubernetes_plugin-1.2.0-py27-none-linux_x86_64-centos-Core.wgn
34   - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.0/plugin.yaml
35   # Plugin required: http://repository.cloudifysource.org/cloudify/wagons/cloudify-diamond-plugin/1.3.5/cloudify_diamond_plugin-1.3.5-py27-none-linux_x86_64-centos-Core.wgn
36   - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-diamond-plugin/1.3.5/plugin.yaml
37   # Plugin required: http://repository.cloudifysource.org/cloudify/wagons/cloudify-fabric-plugin/1.5/cloudify_fabric_plugin-1.5-py27-none-linux_x86_64-centos-Core.wgn
38   - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-fabric-plugin/1.5/plugin.yaml
39   - cloudify/types/kubernetes.yaml
40
41 inputs:
42
43   configuration_file_content:
44     type: string
45
46   NS:
47     default: oom
48
49   image:
50     description: Image to be used when launching agent VMs
51     default: { get_secret: centos_core_image }
52
53   flavor:
54     description: Flavor of the agent VMs
55     default: { get_secret: large_image_flavor }
56
57   agent_user:
58     description: >
59       User for connecting to agent VMs
60     default: centos
61
62   app_name:
63     default: message-router
64
65   security_group:
66     default: { concat: [ 'secgrp_', { get_input: app_name } ] }
67
68 dsl_definitions:
69
70   openstack_config: &openstack_config
71     username: { get_secret: keystone_username }
72     password: { get_secret: keystone_password }
73     tenant_name: { get_secret: keystone_tenant_name }
74     auth_url: { get_secret: keystone_url }
75     region: { get_secret: region }
76
77 groups:
78
79   openstack_server_port_group_zookeeper:
80     members:
81       - openstack_server_zookeeper
82       - openstack_port_zookeeper
83
84   openstack_server_port_group_kafka:
85     members:
86       - openstack_server_kafka
87       - openstack_port_kafka
88
89   openstack_server_port_group_dmaap:
90     members:
91       - openstack_server_dmaap
92       - openstack_port_dmaap
93
94 policies:
95
96   openstack_server_port_policies_scaling:
97     type: cloudify.policies.scaling
98     properties:
99       default_instances:  1
100     targets:
101     - openstack_server_port_group_zookeeper
102     - openstack_server_port_group_kafka
103     - openstack_server_port_group_dmaap
104
105 node_templates:
106
107   kubernetes_service_zookeeper:
108     type: cloudify.kubernetes.resources.Service
109     properties:
110       definition:
111         apiVersion: v1
112         kind: Service
113         metadata:
114           name: zookeeper
115           labels:
116             app: zookeeper
117         spec:
118           ports:
119           - name: zookeeper1
120             port: 2181
121           selector:
122             app: zookeeper
123           clusterIP: None
124     relationships:
125       - type: cloudify.kubernetes.relationships.managed_by_master
126         target: k8s
127       - type: cloudify.relationships.depends_on
128         target: kubernetes_deployment_zookeeper
129
130   kubernetes_deployment_zookeeper:
131     type: cloudify.kubernetes.resources.Deployment
132     properties:
133       definition:
134         file:
135           resource_path: kubernetes/message-router/message-router-zookeeper.yaml
136     relationships:
137       - type: cloudify.kubernetes.relationships.managed_by_master
138         target: k8s
139       - type: cloudify.relationships.depends_on
140         target: kubernetes_node_zookeeper
141
142   kubernetes_node_zookeeper:
143     type: cloudify.nodes.Kubernetes.Node
144     relationships:
145       - type: cloudify.relationships.contained_in
146         target: openstack_server_zookeeper
147     interfaces:
148       cloudify.interfaces.lifecycle:
149         start:
150           implementation: fabric.fabric_plugin.tasks.run_task
151           inputs:
152             task_properties:
153               hostname: { get_attribute: [ SELF, hostname ] }
154               labels:
155                 app: zookeeper
156
157   openstack_server_zookeeper:
158     type: cloudify.openstack.nodes.Server
159     properties: &openstack_server_properties
160       openstack_config: *openstack_config
161       agent_config:
162           user: { get_input: agent_user }
163           install_method: remote
164           port: 22
165           key: { get_secret: agent_key_private }
166       server:
167         key_name: ''
168         image: ''
169         flavor: ''
170       management_network_name: { get_property: [ private_network, resource_id ] }
171     relationships:
172       - type: cloudify.relationships.contained_in
173         target: k8s_node_scaling_tier
174       - target: openstack_port_zookeeper
175         type: cloudify.openstack.server_connected_to_port
176       - type: cloudify.relationships.depends_on
177         target: cloud_init_openstack_server
178     interfaces: &openstack_server_interfaces
179       cloudify.interfaces.lifecycle:
180         create:
181           inputs:
182             args:
183               image: { get_input: image }
184               flavor: { get_input: flavor }
185               userdata: { get_attribute: [ cloud_init_openstack_server, cloud_config ] }
186       cloudify.interfaces.monitoring_agent:
187           install:
188             implementation: diamond.diamond_agent.tasks.install
189             inputs:
190               diamond_config:
191                 interval: 1
192           start: diamond.diamond_agent.tasks.start
193           stop: diamond.diamond_agent.tasks.stop
194           uninstall: diamond.diamond_agent.tasks.uninstall
195       cloudify.interfaces.monitoring:
196           start:
197             implementation: diamond.diamond_agent.tasks.add_collectors
198             inputs:
199               collectors_config:
200                 CPUCollector: {}
201                 MemoryCollector: {}
202                 LoadAverageCollector: {}
203                 DiskUsageCollector:
204                   config:
205                     devices: x?vd[a-z]+[0-9]*$
206                 NetworkCollector: {}
207                 ProcessResourcesCollector:
208                   config:
209                     enabled: true
210                     unit: B
211                     measure_collector_time: true
212                     cpu_interval: 0.5
213                     process:
214                       hyperkube:
215                         name: hyperkube
216
217   openstack_port_zookeeper:
218     type: cloudify.openstack.nodes.Port
219     properties:
220       openstack_config: *openstack_config
221     relationships: &openstack_port_relationships
222       - type: cloudify.relationships.contained_in
223         target: k8s_node_scaling_tier
224       - type: cloudify.relationships.connected_to
225         target: private_network
226       - type: cloudify.relationships.depends_on
227         target: private_subnet
228       - type: cloudify.openstack.port_connected_to_security_group
229         target: security_group
230
231   kubernetes_service_kafka:
232     type: cloudify.kubernetes.resources.Service
233     properties:
234       definition:
235         apiVersion: v1
236         kind: Service
237         metadata:
238           name: global-kafka
239           labels:
240             app: global-kafka
241         spec:
242           ports:
243           - name: kafka1
244             port: 9092
245           selector:
246             app: global-kafka
247           clusterIP: None
248     relationships:
249       - type: cloudify.kubernetes.relationships.managed_by_master
250         target: k8s
251       - type: cloudify.relationships.depends_on
252         target: kubernetes_deployment_kafka
253
254   kubernetes_deployment_kafka:
255     type: cloudify.kubernetes.resources.Deployment
256     properties:
257       definition:
258         file:
259           resource_path: kubernetes/message-router/message-router-kafka.yaml
260     relationships:
261       - type: cloudify.kubernetes.relationships.managed_by_master
262         target: k8s
263       - type: cloudify.relationships.depends_on
264         target: kubernetes_node_kafka
265       - type: cloudify.relationships.depends_on
266         target: kubernetes_deployment_zookeeper
267
268   kubernetes_node_kafka:
269     type: cloudify.nodes.Kubernetes.Node
270     relationships:
271       - type: cloudify.relationships.contained_in
272         target: openstack_server_kafka
273     interfaces:
274       cloudify.interfaces.lifecycle:
275         start:
276           implementation: fabric.fabric_plugin.tasks.run_task
277           inputs:
278             task_properties:
279               hostname: { get_attribute: [ SELF, hostname ] }
280               labels:
281                 app: global-kafka
282
283   openstack_server_kafka:
284     type: cloudify.openstack.nodes.Server
285     properties: *openstack_server_properties
286     relationships:
287       - type: cloudify.relationships.contained_in
288         target: k8s_node_scaling_tier
289       - target: openstack_port_kafka
290         type: cloudify.openstack.server_connected_to_port
291       - type: cloudify.relationships.depends_on
292         target: cloud_init_openstack_server
293     interfaces: *openstack_server_interfaces
294
295   openstack_port_kafka:
296     type: cloudify.openstack.nodes.Port
297     properties:
298       openstack_config: *openstack_config
299     relationships: *openstack_port_relationships
300
301   kubernetes_service_dmaap:
302     type: cloudify.kubernetes.resources.Service
303     properties:
304       definition:
305         apiVersion: v1
306         kind: Service
307         metadata:
308           name: dmaap
309           labels:
310             app: dmaap
311             version: 1.0.0
312         spec:
313           ports:
314           - name: mr1
315             port: 3904
316             nodePort: 30227
317           - name: mr2
318             port: 3905
319             nodePort: 30226
320           selector:
321             app: dmaap
322           type: NodePort
323     relationships:
324       - type: cloudify.kubernetes.relationships.managed_by_master
325         target: k8s
326       - type: cloudify.relationships.depends_on
327         target: kubernetes_deployment_dmaap
328
329   kubernetes_deployment_dmaap:
330     type: cloudify.kubernetes.resources.Deployment
331     properties:
332       definition:
333         file:
334           resource_path: kubernetes/message-router/message-router-dmaap.yaml
335     relationships:
336       - type: cloudify.kubernetes.relationships.managed_by_master
337         target: k8s
338       - type: cloudify.relationships.depends_on
339         target: kubernetes_node_dmaap
340       - type: cloudify.relationships.depends_on
341         target: kubernetes_deployment_zookeeper
342
343   kubernetes_node_dmaap:
344     type: cloudify.nodes.Kubernetes.Node
345     relationships:
346       - type: cloudify.relationships.contained_in
347         target: openstack_server_dmaap
348     interfaces:
349       cloudify.interfaces.lifecycle:
350         start:
351           implementation: fabric.fabric_plugin.tasks.run_task
352           inputs:
353             task_properties:
354               hostname: { get_attribute: [ SELF, hostname ] }
355               labels:
356                 app: global-dmaap
357
358   openstack_server_dmaap:
359     type: cloudify.openstack.nodes.Server
360     properties: *openstack_server_properties
361     relationships:
362       - type: cloudify.relationships.contained_in
363         target: k8s_node_scaling_tier
364       - target: openstack_port_dmaap
365         type: cloudify.openstack.server_connected_to_port
366       - type: cloudify.relationships.depends_on
367         target: cloud_init_openstack_server
368     interfaces: *openstack_server_interfaces
369
370   openstack_port_dmaap:
371     type: cloudify.openstack.nodes.Port
372     properties:
373       openstack_config: *openstack_config
374     relationships: *openstack_port_relationships
375
376   security_group:
377     type: cloudify.openstack.nodes.SecurityGroup
378     properties:
379       openstack_config: *openstack_config
380       security_group:
381         name: { get_input: security_group }
382         description: kubernetes master security group
383       rules:
384       rules:
385       - remote_ip_prefix: 0.0.0.0/0
386         port: 22
387       - remote_ip_prefix: 0.0.0.0/0
388         port: 53
389       - remote_ip_prefix: 0.0.0.0/0
390         port: 53
391         protocol: udp
392       - remote_ip_prefix: 0.0.0.0/0
393         port: 80
394       - remote_ip_prefix: 0.0.0.0/0
395         port: 443
396       - remote_ip_prefix: 0.0.0.0/0
397         port: 2379
398       - remote_ip_prefix: 0.0.0.0/0
399         port: 4001
400       - remote_ip_prefix: 0.0.0.0/0
401         port: 4789
402       - remote_ip_prefix: 0.0.0.0/0
403         port: 6443
404       - remote_ip_prefix: 0.0.0.0/0
405         port: 6783
406         protocol: tcp
407       - remote_ip_prefix: 0.0.0.0/0
408         port: 6783
409         protocol: udp
410       - remote_ip_prefix: 0.0.0.0/0
411         port: 6784
412         protocol: tcp
413       - remote_ip_prefix: 0.0.0.0/0
414         port: 6784
415         protocol: udp
416       - remote_ip_prefix: 0.0.0.0/0
417         port: 8000
418       - remote_ip_prefix: 0.0.0.0/0
419         port: 8080
420       - remote_ip_prefix: 0.0.0.0/0
421         port: 9090
422       - remote_ip_prefix: 0.0.0.0/0
423         port: 10250
424       - remote_ip_prefix: 0.0.0.0/0
425         port: 2181
426       - remote_ip_prefix: 0.0.0.0/0
427         port: 9092
428       - remote_ip_prefix: 0.0.0.0/0
429         port: 3904
430       - remote_ip_prefix: 0.0.0.0/0
431         port: 30227
432       - remote_ip_prefix: 0.0.0.0/0
433         port: 3905
434       - remote_ip_prefix: 0.0.0.0/0
435         port: 30226
436
437   private_subnet:
438     type: cloudify.openstack.nodes.Subnet
439     properties:
440       openstack_config: *openstack_config
441       use_external_resource: true
442       resource_id: { get_secret: private_subnet_name }
443     relationships:
444       - target: private_network
445         type: cloudify.relationships.contained_in
446
447   private_network:
448     type: cloudify.openstack.nodes.Network
449     properties:
450       openstack_config: *openstack_config
451       use_external_resource: true
452       resource_id: { get_secret: private_network_name }
453
454   external_network:
455     type: cloudify.openstack.nodes.Network
456     properties:
457       openstack_config: *openstack_config
458       use_external_resource: true
459       resource_id: { get_secret: external_network_name }
460
461   cloud_init_openstack_server:
462     type: cloudify.nodes.CloudInit.CloudConfig
463     properties:
464       resource_config:
465         groups:
466         - docker
467         users:
468         - name: { get_input: agent_user }
469           primary-group: wheel
470           groups: docker
471           shell: /bin/bash
472           sudo: ['ALL=(ALL) NOPASSWD:ALL']
473           ssh-authorized-keys:
474             - { get_secret: agent_key_public }
475         write_files:
476         - path: /etc/yum.repos.d/kubernetes.repo
477           owner: root:root
478           permissions: '0444'
479           content: |
480             # installed by cloud-init
481             [kubernetes]
482             name=Kubernetes
483             baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
484             enabled=1
485             gpgcheck=1
486             repo_gpgcheck=1
487             gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
488                    https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
489         packages:
490         - [epel-release]
491         - [gcc]
492         - [python-dev]
493         - [python-wheel]
494         - [python-setuptools]
495         - [libffi-devel]
496         - [python-devel]
497         - [openssl-devel]
498         - [docker, 1.12.6-28.git1398f24.el7.centos]
499         - [kubelet, 1.6.4-0]
500         - [kubeadm, 1.6.4-0]
501         - [kubectl, 1.6.4-0]
502         - [kubernetes-cni, 0.5.1-0]
503         - [git]
504         - [wget]
505         runcmd:
506         - systemctl enable docker
507         - systemctl start docker
508         - systemctl enable kubelet
509         - systemctl start kubelet
510         - yum install -y python-pip
511         - pip install --upgrade pip
512         - pip install docker-compose
513         - pip install backports.ssl_match_hostname --upgrade
514         - mkdir -p /tmp/oom/
515         - git clone https://gerrit.onap.org/r/oom.git /tmp/oom
516         - sleep 15
517         - chmod 755 /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/deploy.sh
518         - sed -i -e "s/\.\/docker_files/\/tmp\/oom\/kubernetes\/config\/docker\/init\/src\/config\/message-router\/dcae-startup-vm-message-router\/docker_files/g" /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/deploy.sh
519         - sed -i -e "s/\/opt\/docker\/docker-compose/\/bin\/docker-compose/g" /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/deploy.sh
520         - mv /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/docker_files/__docker-compose.yml /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/docker_files/docker-compose.yml
521         - mv /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/docker_files/__MsgRtrApi.properties /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/docker_files/MsgRtrApi.properties
522         - sh -c /tmp/oom/kubernetes/config/docker/init/src/config/message-router/dcae-startup-vm-message-router/deploy.sh
523
524   k8s_node_scaling_tier:
525     type: cloudify.nodes.Root
526
527   k8s:
528     type: cloudify.kubernetes.nodes.Master
529     properties:
530       configuration:
531         file_content: { get_input: configuration_file_content }
532