00f8c8dce81393825ffa7f26c865c99a472bfa27
[dcaegen2/platform/plugins.git] / k8s / k8s-node-type.yaml
1 # ================================================================================
2 # Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
16 #
17 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
18
19 tosca_definitions_version: cloudify_dsl_1_3
20
21 imports:
22     - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
23
24 plugins:
25   k8s:
26     executor: 'central_deployment_agent'
27     package_name: k8splugin
28     package_version: 1.2.0
29
30 data_types:
31
32   dcae.types.MSBRegistration:
33     description: >
34       Information for registering an HTTP service into MSB.  It's optional to do so,
35       but if MSB registration is desired at least the port property must be provided.
36       If 'port' property is not provided, the plugin will not do the registration.
37       (The properties all have to be declared as not required, otherwise the
38       'msb_registration' property on the node would also be required.)
39     properties:
40       port:
41         description: The container port at which the service is exposed
42         type: string
43         required: false
44       version:
45         description: The version identifier for the service
46         type: string
47         required: false
48       url_path:
49         description: The URL path (e.g., "/api", not the full URL) to the service endpoint
50         type: string
51         required: false
52       uses_ssl:
53         description: Set to true if service endpoint uses SSL (TLS)
54         type: boolean
55         required: false
56
57   dcae.types.LoggingInfo:
58     description: >
59       Information for setting up centralized logging via ELK using a "sidecar" container.
60       If 'log_directory' is not provided, the plugin will not set up ELK logging.
61       (The properties all have to be declared as not required, otherwise the
62       'log_info' property on the node would also be required.)
63     properties:
64       log_directory:
65         description: >
66           The path in the container where the component writes its logs.
67           If the component is following the EELF requirements, this would be
68           the directory where the four EELF files are being written.
69           (Other logs can be placed in the directory--if their names in '.log',
70           they'll also be sent into ELK.)
71         type: string
72         required: false
73       alternate_fb_path:
74         description: >
75           Hope not to use this.  By default, the plugin will mount the log volume
76           at /var/log/onap/<component_type> in the sidecar container's file system.
77           'alternate_fb_path' allows overriding the default.  Will affect how the log
78           data can be found in the ELK system.
79         type: string
80         required: false
81
82 node_types:
83     # The ContainerizedServiceComponent node type is to be used for DCAE service components that 
84     # are to be run in a Docker container.  This node type goes beyond that of a ordinary Docker
85     # plugin where it has DCAE platform specific functionality:
86     #
87     #   * Generation of the service component name
88     #   * Managing of service component configuration information
89     #
90     # The plugin deploys the container into a Kubernetes cluster with a very specific choice
91     # of Kubernetes elements that are deliberately not under the control of the blueprint author. 
92     # The idea is to deploy all service components in a consistent way, with the details abstracted
93     # away from the blueprint author.
94     dcae.nodes.ContainerizedServiceComponent:
95         derived_from: cloudify.nodes.Root
96         properties:
97             service_component_type:
98                 type: string
99                 description: Service component type of the application being run in the container
100
101             service_id:
102                 type: string
103                 description: >
104                   Unique id for this DCAE service instance this component belongs to. This value
105                   will be applied as a tag in the registration of this component with Consul.
106                 default: Null
107
108             location_id:
109                 type: string
110                 description: >
111                   Location id of where to run the container.  Not used by the plugin.  Here for backward compatibility.
112                 default: Null
113                 required: False
114
115             service_component_name_override:
116                 type: string
117                 description: >
118                     Manually override and set the name for this Docker container node. If this
119                     is set, then the name will not be auto-generated. Platform services are the
120                     specific use cases for using this parameter because they have static
121                     names for example the CDAP broker.
122                 default: Null
123
124             application_config:
125                 default: {}
126                 description: >
127                   Application configuration for this Docker component. The data structure is
128                   expected to be a complex map (native YAML) and to be constructed and filled
129                   by the creator of the blueprint.
130
131             docker_config:
132                 default: {}
133                 description: >
134                   This is what is the auxilary portion of the component spec that contains things
135                   like healthcheck definitions for the Docker component. Health checks are
136                   optional.
137
138             image:
139                 type: string
140                 description: Full uri of the Docker image
141
142             log_info:
143               type: dcae.types.LoggingInfo
144               description: >
145                 Information for setting up centralized logging via ELK.
146               required: false
147
148             replicas:
149               type: integer
150               description: >
151                 The number of instances of the component that should be launched initially
152               default: 1
153
154             always_pull_image:
155               type: boolean
156               description: >
157                 Set to true if the orchestrator should always pull a new copy of the image 
158                 before deploying.  By default the orchestrator pulls only if the image is
159                 not already present on the Docker host where the container is being launched.
160               default: false
161
162         interfaces:
163             cloudify.interfaces.lifecycle:
164                 create:
165                     # Generate service component name and populate config into Consul
166                     implementation: k8s.k8splugin.create_for_components
167                 start:
168                     # Create Docker container and start
169                     implementation: k8s.k8splugin.create_and_start_container_for_components
170                 stop:
171                     # Stop and remove Docker container
172                     implementation: k8s.k8splugin.stop_and_remove_container
173                 delete:
174                     # Delete configuration from Consul
175                     implementation: k8s.k8splugin.cleanup_discovery
176             dcae.interfaces.policy:
177                 # This is to be invoked by the policy handler upon policy updates
178                 policy_update:
179                     implementation: k8s.k8splugin.policy_update
180             dcae.interfaces.scale:
181                 scale:
182                     implementation: k8s.k8splugin.scale
183
184
185     # This node type is intended for DCAE service components that use DMaaP and must use the 
186     # DMaaP plugin.
187     dcae.nodes.ContainerizedServiceComponentUsingDmaap:
188         derived_from: dcae.nodes.ContainerizedServiceComponent
189         properties:
190             streams_publishes:
191                 description: >
192                   List of DMaaP streams used for publishing.
193
194                   Message router items look like:
195
196                     name: topic00
197                     location: mtc5
198                     client_role: XXXX
199                     type: message_router
200
201                   Data router items look like:
202
203                     name: feed00
204                     location: mtc5
205                     type: data_router
206
207                   This information is forwarded to the dmaap plugin to provision
208                 default: []
209             streams_subscribes:
210                 description: >
211                   List of DMaaP streams used for subscribing.
212
213                   Message router items look like:
214
215                     name: topic00
216                     location: mtc5
217                     client_role: XXXX
218                     type: message_router
219
220                   Data router items look like:
221
222                     name: feed00
223                     location: mtc5
224                     type: data_router
225                     username: king
226                     password: 123456
227                     route: some-path
228                     scheme: https
229
230                   Note that username and password is optional. If not provided or null then the
231                   plugin will generate them.
232
233                 default: []
234         interfaces:
235             cloudify.interfaces.lifecycle:
236                 create:
237                     # Generate service component name and populate config into Consul
238                     implementation: k8s.k8splugin.create_for_components_with_streams
239                 start:
240                     # Create Docker container and start
241                     implementation: k8s.k8splugin.create_and_start_container_for_components_with_streams
242
243
244     # ContainerizedPlatformComponent is intended for DCAE platform services.  Unlike the components,
245     # platform services have well-known names and well-known ports.
246     dcae.nodes.ContainerizedPlatformComponent:
247         derived_from: cloudify.nodes.Root
248         properties:
249             name:
250                 description: >
251                   Container name used to register with Consul
252             dns_name:
253                 required: false
254                 description: >
255                   Name to be registered in the DNS for the service provided by the container.  
256                   If not provided, the 'name' field is used.
257                   This is a work-around for the Kubernetes restriction on having '_' in a DNS name.
258                   Having this field allows a component to look up its configuration using a name that
259                   includes a '_' while providing a legal Kubernetes DNS name.
260
261             application_config:
262                 default: {}
263                 description: >
264                   Application configuration for this Docker component. The data strcture is
265                   expected to be a complex map (native YAML) and to be constructed and filled
266                   by the creator of the blueprint.
267
268             docker_config:
269                 default: {}
270                 description: >
271                   This is what is the auxilary portion of the component spec that contains things
272                   like healthcheck definitions for the Docker component. Health checks are
273                   optional.
274
275             image:
276                 type: string
277                 description: Full uri of the Docker image
278
279             host_port:
280                 type: integer
281                 description: >
282                   Network port that the platform service is expecting to expose on the host
283                 default: 0
284
285             container_port:
286                 type: integer
287                 description: >
288                   Network port that the platform service exposes in the container
289                 default: 0
290
291             msb_registration:
292               type: dcae.types.MSBRegistration
293               description: >
294                 Information for registering with MSB
295               required: false
296
297             log_info:
298               type: dcae.types.LoggingInfo
299               description: >
300                 Information for setting up centralized logging via ELK.
301               required: false
302
303             replicas:
304               type: integer
305               description: >
306                 The number of instances of the component that should be launched initially
307               default: 1
308
309             always_pull_image:
310               type: boolean
311               description: >
312                 Set to true if the orchestrator should always pull a new copy of the image 
313                 before deploying.  By default the orchestrator pulls only if the image is
314                 not already present on the Docker host where the container is being launched.
315               default: false
316
317         interfaces:
318             cloudify.interfaces.lifecycle:
319                 create:
320                     # Populate config into Consul
321                     implementation: k8s.k8splugin.create_for_platforms
322                 start:
323                     # Create Docker container and start
324                     implementation: k8s.k8splugin.create_and_start_container_for_platforms
325                 stop:
326                     # Stop and remove Docker container
327                     implementation: k8s.k8splugin.stop_and_remove_container
328                 delete:
329                     # Delete configuration from Consul
330                     implementation: k8s.k8splugin.cleanup_discovery
331             dcae.interfaces.scale:
332                 scale:
333                     implementation: k8s.k8splugin.tasks.scale
334
335     # ContainerizedApplication is intended to be more of an all-purpose Docker container node
336     # for non-componentized applications.
337     dcae.nodes.ContainerizedApplication:
338         derived_from: cloudify.nodes.Root
339         properties:
340             name:
341                 type: string
342                 description: Name of the Docker container to be given
343             image:
344                 type: string
345                 description: Full uri of the Docker image
346         interfaces:
347             cloudify.interfaces.lifecycle:
348                 start:
349                     # Create Docker container and start
350                     implementation: k8s.k8splugin.create_and_start_container
351                 stop:
352                     # Stop and remove Docker container
353                     implementation: k8s.k8splugin.stop_and_remove_container