f63f82288262ed7eb83ccbd4e13692e77c5d3474
[dcaegen2/platform/plugins.git] / k8s / k8s-node-type.yaml
1 # ================================================================================
2 # Copyright (c) 2017-2019 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/4.2/types.yaml
23
24 plugins:
25   k8s:
26     executor: 'central_deployment_agent'
27     package_name: k8splugin
28     package_version: 1.4.6
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   dcae.types.TLSInfo:
83     description: >
84       Information for using TLS (HTTPS).  (The properties all have to be declared as not
85       required, otherwise the tls_info property on the node would also be required.)
86     properties:
87       cert_directory:
88         description: >
89           The path in the container where the component expects to find TLS-related data.
90         type: string
91         required: false
92       use_tls:
93         description: >
94           Flag indicating whether TLS (HTTPS) is to be used
95         type: boolean
96         required: false
97
98 node_types:
99     dcae.nodes.ContainerizedComponent:
100     # Bese type for all containerized components
101     # Captures common properties and interfaces
102         derived_from: cloudify.nodes.Root
103         properties:
104             image:
105                 type: string
106                 description: Full uri of the Docker image
107
108             application_config:
109                 default: {}
110                 description: >
111                   Application configuration for this Docker component. The data structure is
112                   expected to be a complex map (native YAML) and to be constructed and filled
113                   by the creator of the blueprint.
114
115             docker_config:
116                 default: {}
117                 description: >
118                   This is what is the auxilary portion of the component spec that contains things
119                   like healthcheck definitions for the Docker component. Health checks are
120                   optional.
121
122             resource_config:
123                 default: {}
124                 description: >
125                   This is used to specify the cpu and memory request and limit for container.
126                   Please specify "requests" property and/or a "limits" property, with subproproperties 
127                   for cpu and memory. (https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
128                    
129
130             log_info:
131               type: dcae.types.LoggingInfo
132               description: >
133                 Information for setting up centralized logging via ELK.
134               required: false
135
136             tls_info:
137               type: dcae.types.TLSInfo
138               description: >
139                 Information for setting up TLS (HTTPS).
140               required: false
141
142             replicas:
143               type: integer
144               description: >
145                 The number of instances of the component that should be launched initially
146               default: 1
147
148             always_pull_image:
149               type: boolean
150               description: >
151                 Set to true if the orchestrator should always pull a new copy of the image
152                 before deploying.  By default the orchestrator pulls only if the image is
153                 not already present on the Docker host where the container is being launched.
154               default: false
155
156         interfaces:
157             dcae.interfaces.update:
158                 scale:
159                     implementation: k8s.k8splugin.scale
160                 update_image:
161                     implementation: k8s.k8splugin.update_image
162
163     # The ContainerizedServiceComponent node type is to be used for DCAE service components that
164     # are to be run in a Docker container.  This node type goes beyond that of a ordinary Docker
165     # plugin where it has DCAE platform specific functionality:
166     #
167     #   * Generation of the service component name
168     #   * Managing of service component configuration information
169     #
170     # The plugin deploys the container into a Kubernetes cluster with a very specific choice
171     # of Kubernetes elements that are deliberately not under the control of the blueprint author.
172     # The idea is to deploy all service components in a consistent way, with the details abstracted
173     # away from the blueprint author.
174     dcae.nodes.ContainerizedServiceComponent:
175         derived_from: dcae.nodes.ContainerizedComponent
176         properties:
177             service_component_type:
178                 type: string
179                 description: Service component type of the application being run in the container
180
181             service_id:
182                 type: string
183                 description: >
184                   Unique id for this DCAE service instance this component belongs to. This value
185                   will be applied as a tag in the registration of this component with Consul.
186                 default: Null
187
188             location_id:
189                 type: string
190                 description: >
191                   Location id of where to run the container.  Not used by the plugin.  Here for backward compatibility.
192                 default: Null
193                 required: False
194
195             service_component_name_override:
196                 type: string
197                 description: >
198                     Manually override and set the name for this Docker container node. If this
199                     is set, then the name will not be auto-generated. Platform services are the
200                     specific use cases for using this parameter because they have static
201                     names for example the CDAP broker.
202                 default: Null
203
204         interfaces:
205             cloudify.interfaces.lifecycle:
206                 create:
207                     # Generate service component name and populate config into Consul
208                     implementation: k8s.k8splugin.create_for_components
209                 start:
210                     # Create Docker container and start
211                     implementation: k8s.k8splugin.create_and_start_container_for_components
212                 stop:
213                     # Stop and remove Docker container
214                     implementation: k8s.k8splugin.stop_and_remove_container
215                 delete:
216                     # Delete configuration from Consul
217                     implementation: k8s.k8splugin.cleanup_discovery
218             dcae.interfaces.policy:
219                 # This is to be invoked by the policy handler upon policy updates
220                 policy_update:
221                     implementation: k8s.k8splugin.policy_update
222
223     # This node type is intended for DCAE service components that use DMaaP and must use the
224     # DMaaP plugin.
225     dcae.nodes.ContainerizedServiceComponentUsingDmaap:
226         derived_from: dcae.nodes.ContainerizedServiceComponent
227         properties:
228             streams_publishes:
229                 description: >
230                   List of DMaaP streams used for publishing.
231
232                   Message router items look like:
233
234                     name: topic00
235                     location: mtc5
236                     client_role: XXXX
237                     type: message_router
238
239                   Data router items look like:
240
241                     name: feed00
242                     location: mtc5
243                     type: data_router
244
245                   This information is forwarded to the dmaap plugin to provision
246                 default: []
247             streams_subscribes:
248                 description: >
249                   List of DMaaP streams used for subscribing.
250
251                   Message router items look like:
252
253                     name: topic00
254                     location: mtc5
255                     client_role: XXXX
256                     type: message_router
257
258                   Data router items look like:
259
260                     name: feed00
261                     location: mtc5
262                     type: data_router
263                     username: king
264                     password: 123456
265                     route: some-path
266                     scheme: https
267
268                   Note that username and password is optional. If not provided or null then the
269                   plugin will generate them.
270
271                 default: []
272         interfaces:
273             cloudify.interfaces.lifecycle:
274                 create:
275                     # Generate service component name and populate config into Consul
276                     implementation: k8s.k8splugin.create_for_components_with_streams
277                 start:
278                     # Create Docker container and start
279                     implementation: k8s.k8splugin.create_and_start_container_for_components_with_streams
280
281     # ContainerizedPlatformComponent is intended for DCAE platform services.  Unlike the components,
282     # platform services have well-known names and well-known ports.
283     dcae.nodes.ContainerizedPlatformComponent:
284         derived_from: dcae.nodes.ContainerizedComponent
285         properties:
286             name:
287                 description: >
288                   Container name used to register with Consul
289             dns_name:
290                 required: false
291                 description: >
292                   Name to be registered in the DNS for the service provided by the container.
293                   If not provided, the 'name' field is used.
294                   This is a work-around for the Kubernetes restriction on having '_' in a DNS name.
295                   Having this field allows a component to look up its configuration using a name that
296                   includes a '_' while providing a legal Kubernetes DNS name.
297
298             host_port:
299                 type: integer
300                 description: >
301                   Network port that the platform service is expecting to expose on the host
302                 default: 0
303
304             container_port:
305                 type: integer
306                 description: >
307                   Network port that the platform service exposes in the container
308                 default: 0
309
310             msb_registration:
311               type: dcae.types.MSBRegistration
312               description: >
313                 Information for registering with MSB
314               required: false
315
316         interfaces:
317             cloudify.interfaces.lifecycle:
318                 create:
319                     # Populate config into Consul
320                     implementation: k8s.k8splugin.create_for_platforms
321                 start:
322                     # Create Docker container and start
323                     implementation: k8s.k8splugin.create_and_start_container_for_platforms
324                 stop:
325                     # Stop and remove Docker container
326                     implementation: k8s.k8splugin.stop_and_remove_container
327                 delete:
328                     # Delete configuration from Consul
329                     implementation: k8s.k8splugin.cleanup_discovery
330
331     # ContainerizedApplication is intended to be more of an all-purpose Docker container node
332     # for non-componentized applications.
333     dcae.nodes.ContainerizedApplication:
334         derived_from: cloudify.nodes.Root
335         properties:
336             name:
337                 type: string
338                 description: Name of the Docker container to be given
339             image:
340                 type: string
341                 description: Full uri of the Docker image
342         interfaces:
343             cloudify.interfaces.lifecycle:
344                 start:
345                     # Create Docker container and start
346                     implementation: k8s.k8splugin.create_and_start_container
347                 stop:
348                     # Stop and remove Docker container
349                     implementation: k8s.k8splugin.stop_and_remove_container
350             dcae.interfaces.scale:
351                 scale:
352                     implementation: k8s.k8splugin.scale
353             dcae.interfaces.update:
354                 update_image:
355                     implementation: k8s.k8splugin.update_image