blob: 9ff0d58a8003c2651ce8d7af96e81150bea60c38 [file] [log] [blame]
Jun Hu9e45abc2018-01-17 17:07:36 -05001# ============LICENSE_START==========================================
2# ===================================================================
Jun (Nicolas) Hu8cbcb302018-02-21 14:18:44 -05003# Copyright (c) 2017 AT&T
Jun Hu9e45abc2018-01-17 17:07:36 -05004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#============LICENSE_END============================================
17
18tosca_definitions_version: cloudify_dsl_1_3
19
20description: >
21 This blueprint creates a Kubernetes Cluster.
22 It is based on this documentation: https://kubernetes.io/docs/getting-started-guides/kubeadm/
23
24imports:
25 - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml
26 - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-openstack-plugin/2.2.0/plugin.yaml
27 - https://raw.githubusercontent.com/cloudify-incubator/cloudify-utilities-plugin/1.2.5/plugin.yaml
28 - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-fabric-plugin/1.5/plugin.yaml
29 - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-diamond-plugin/1.3.5/plugin.yaml
30 - imports/cloud-config.yaml
31 - imports/kubernetes.yaml
32
33inputs:
34
35 image:
36 description: Image to be used when launching agent VMs
37 default: { get_secret: centos_core_image }
38
39 flavor:
40 description: Flavor of the agent VMs
41 default: { get_secret: large_image_flavor }
42
43 agent_user:
44 description: >
45 User for connecting to agent VMs
46 default: centos
47
48dsl_definitions:
49
50 openstack_config: &openstack_config
51 username: { get_secret: keystone_username }
52 password: { get_secret: keystone_password }
53 tenant_name: { get_secret: keystone_tenant_name }
54 auth_url: { get_secret: keystone_url }
55 region: { get_secret: region }
56
57node_templates:
58
59 nfs_server:
60 type: cloudify.nodes.SoftwareComponent
61 properties:
62 interfaces:
63 cloudify.interfaces.lifecycle:
64 start:
65 implementation: fabric.fabric_plugin.tasks.run_script
66 inputs:
67 script_path: scripts/nfs.sh
68 use_sudo: true
69 process:
70 args:
71 fabric_env:
72 host_string: { get_attribute: [ kubernetes_master_host, ip ] }
73 user: { get_input: agent_user }
74 key: { get_secret: agent_key_private }
75 relationships:
76 - type: cloudify.relationships.contained_in
77 target: kubernetes_master_host
78
79 kubernetes_master_host:
80 type: cloudify.openstack.nodes.Server
81 properties:
82 openstack_config: *openstack_config
83 agent_config:
84 user: { get_input: agent_user }
85 install_method: remote
86 port: 22
87 key: { get_secret: agent_key_private }
88 server:
89 key_name: ''
90 image: ''
91 flavor: ''
92 management_network_name: { get_property: [ public_network, resource_id ] }
93 interfaces:
94 cloudify.interfaces.lifecycle:
95 create:
96 inputs:
97 args:
98 image: { get_input: image }
99 flavor: { get_input: flavor }
100 userdata: { get_attribute: [ cloudify_host_cloud_config, cloud_config ] }
101 relationships:
102 - target: kubernetes_master_port
103 type: cloudify.openstack.server_connected_to_port
104 - type: cloudify.relationships.depends_on
105 target: cloudify_host_cloud_config
106
107 kubernetes_node_host:
108 type: cloudify.openstack.nodes.Server
109 properties:
110 openstack_config: *openstack_config
111 agent_config:
112 user: { get_input: agent_user }
113 install_method: remote
114 port: 22
115 key: { get_secret: agent_key_private }
116 server:
117 key_name: ''
118 image: ''
119 flavor: ''
120 management_network_name: { get_property: [ private_network, resource_id ] }
121 relationships:
122 - type: cloudify.relationships.contained_in
123 target: k8s_node_scaling_tier
124 - target: kubernetes_node_port
125 type: cloudify.openstack.server_connected_to_port
126 interfaces:
127 cloudify.interfaces.lifecycle:
128 create:
129 inputs:
130 args:
131 image: { get_input: image }
132 flavor: { get_input: flavor }
133 userdata: { get_attribute: [ cloudify_host_cloud_config, cloud_config ] }
134 cloudify.interfaces.monitoring_agent:
135 install:
136 implementation: diamond.diamond_agent.tasks.install
137 inputs:
138 diamond_config:
139 interval: 1
140 start: diamond.diamond_agent.tasks.start
141 stop: diamond.diamond_agent.tasks.stop
142 uninstall: diamond.diamond_agent.tasks.uninstall
143 cloudify.interfaces.monitoring:
144 start:
145 implementation: diamond.diamond_agent.tasks.add_collectors
146 inputs:
147 collectors_config:
148 CPUCollector: {}
149 MemoryCollector: {}
150 LoadAverageCollector: {}
151 DiskUsageCollector:
152 config:
153 devices: x?vd[a-z]+[0-9]*$
154 NetworkCollector: {}
155 ProcessResourcesCollector:
156 config:
157 enabled: true
158 unit: B
159 measure_collector_time: true
160 cpu_interval: 0.5
161 process:
162 hyperkube:
163 name: hyperkube
164
165 kubernetes_security_group:
166 type: cloudify.openstack.nodes.SecurityGroup
167 properties:
168 openstack_config: *openstack_config
169 security_group:
170 name: kubernetes_security_group
171 description: kubernetes master security group
172 rules:
173 - remote_ip_prefix: 0.0.0.0/0
174 port_range_min: 1
175 port_range_max: 65535
176 protocol: tcp
177 direction: ingress
178 ethertype: IPv4
179 - remote_ip_prefix: 0.0.0.0/0
180 port_range_min: 1
181 port_range_max: 65535
182 protocol: tcp
183 direction: egress
184 ethertype: IPv4
185 - remote_ip_prefix: 0.0.0.0/0
186 port_range_min: 1
187 port_range_max: 65535
188 protocol: udp
189 direction: ingress
190 ethertype: IPv4
191 - remote_ip_prefix: 0.0.0.0/0
192 port_range_min: 1
193 port_range_max: 65535
194 protocol: udp
195 direction: egress
196 ethertype: IPv4
197
198 kubernetes_master_port:
199 type: cloudify.openstack.nodes.Port
200 properties:
201 openstack_config: *openstack_config
202 relationships:
203 - type: cloudify.relationships.contained_in
204 target: public_network
205 - type: cloudify.relationships.depends_on
206 target: public_subnet
207 - type: cloudify.openstack.port_connected_to_security_group
208 target: kubernetes_security_group
209 - type: cloudify.openstack.port_connected_to_floating_ip
210 target: kubernetes_master_ip
211
212 kubernetes_node_port:
213 type: cloudify.openstack.nodes.Port
214 properties:
215 openstack_config: *openstack_config
216 relationships:
217 - type: cloudify.relationships.contained_in
218 target: k8s_node_scaling_tier
219 - type: cloudify.relationships.connected_to
220 target: private_network
221 - type: cloudify.relationships.depends_on
222 target: private_subnet
223 - type: cloudify.openstack.port_connected_to_security_group
224 target: kubernetes_security_group
225
226 private_subnet:
227 type: cloudify.openstack.nodes.Subnet
228 properties:
229 openstack_config: *openstack_config
230 use_external_resource: true
231 resource_id: { get_secret: private_subnet_name }
232 relationships:
233 - target: private_network
234 type: cloudify.relationships.contained_in
235
236 private_network:
237 type: cloudify.openstack.nodes.Network
238 properties:
239 openstack_config: *openstack_config
240 use_external_resource: true
241 resource_id: { get_secret: private_network_name }
242
243 public_subnet:
244 type: cloudify.openstack.nodes.Subnet
245 properties:
246 openstack_config: *openstack_config
247 use_external_resource: true
248 resource_id: { get_secret: public_subnet_name }
249 relationships:
250 - target: public_network
251 type: cloudify.relationships.contained_in
252 - target: router
253 type: cloudify.openstack.subnet_connected_to_router
254
255 public_network:
256 type: cloudify.openstack.nodes.Network
257 properties:
258 openstack_config: *openstack_config
259 use_external_resource: true
260 resource_id: { get_secret: public_network_name }
261
262 router:
263 type: cloudify.openstack.nodes.Router
264 properties:
265 openstack_config: *openstack_config
266 use_external_resource: true
267 resource_id: { get_secret: router_name }
268 relationships:
269 - target: external_network
270 type: cloudify.relationships.connected_to
271
272 external_network:
273 type: cloudify.openstack.nodes.Network
274 properties:
275 openstack_config: *openstack_config
276 use_external_resource: true
277 resource_id: { get_secret: external_network_name }
278
279 k8s_node_scaling_tier:
280 type: cloudify.nodes.Root
281
282 kubernetes_master_ip:
283 type: cloudify.openstack.nodes.FloatingIP
284 properties:
285 openstack_config: *openstack_config
286 floatingip:
287 floating_network_name: { get_property: [ external_network, resource_id ] }
288
289groups:
290
291 k8s_node_group:
292 members:
293 - kubernetes_node_host
294 - kubernetes_node_port
295
296policies:
297
298 kubernetes_node_vms_scaling_policy:
299 type: cloudify.policies.scaling
300 properties:
301 default_instances: 6
302 targets: [k8s_node_group]
303
304outputs:
305
306 kubernetes_master_public_ip:
307 value: { get_attribute: [ kubernetes_master_ip, floating_ip_address ] }