c14623aaf528db68f6aa960a18c54c603a1f943d
[dcaegen2/platform/plugins.git] / k8s / k8s-node-type.yaml
1 # ================================================================================
2 # Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
3 # Copyright (c) 2020 Pantheon.tech. All rights reserved.
4 # ================================================================================
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 #
18 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
19
20 tosca_definitions_version: cloudify_dsl_1_3
21
22 plugins:
23   k8s:
24     executor: 'central_deployment_agent'
25     package_name: k8splugin
26     package_version: 2.0.0
27
28 data_types:
29
30   dcae.types.MSBRegistration:
31     description: >
32       Information for registering an HTTP service into MSB.  It's optional to do so,
33       but if MSB registration is desired at least the port property must be provided.
34       If 'port' property is not provided, the plugin will not do the registration.
35       (The properties all have to be declared as not required, otherwise the
36       'msb_registration' property on the node would also be required.)
37     properties:
38       port:
39         description: The container port at which the service is exposed
40         type: string
41         required: false
42       version:
43         description: The version identifier for the service
44         type: string
45         required: false
46       url_path:
47         description: The URL path (e.g., "/api", not the full URL) to the service endpoint
48         type: string
49         required: false
50       uses_ssl:
51         description: Set to true if service endpoint uses SSL (TLS)
52         type: boolean
53         required: false
54
55   dcae.types.LoggingInfo:
56     description: >
57       Information for setting up centralized logging via ELK using a "sidecar" container.
58       If 'log_directory' is not provided, the plugin will not set up ELK logging.
59       (The properties all have to be declared as not required, otherwise the
60       'log_info' property on the node would also be required.)
61     properties:
62       log_directory:
63         description: >
64           The path in the container where the component writes its logs.
65           If the component is following the EELF requirements, this would be
66           the directory where the four EELF files are being written.
67           (Other logs can be placed in the directory--if their names in '.log',
68           they'll also be sent into ELK.)
69         type: string
70         required: false
71       alternate_fb_path:
72         description: >
73           Hope not to use this.  By default, the plugin will mount the log volume
74           at /var/log/onap/<component_type> in the sidecar container's file system.
75           'alternate_fb_path' allows overriding the default.  Will affect how the log
76           data can be found in the ELK system.
77         type: string
78         required: false
79
80   dcae.types.TLSInfo:
81     description: >
82       Information for using TLS (HTTPS).  (The properties all have to be declared as not
83       required, otherwise the tls_info property on the node would also be required.)
84     properties:
85       cert_directory:
86         description: >
87           The path in the container where the component expects to find TLS-related data.
88         type: string
89         required: false
90       use_tls:
91         description: >
92           Flag indicating whether TLS (HTTPS) is to be used
93         type: boolean
94         required: false
95
96 node_types:
97     dcae.nodes.ContainerizedComponent:
98     # Base type for all containerized components
99     # Captures common properties and interfaces
100         derived_from: cloudify.nodes.Root
101         properties:
102             image:
103                 type: string
104                 description: Full uri of the Docker image
105
106             application_config:
107                 default: {}
108                 description: >
109                   Application configuration for this Docker component. The data structure is
110                   expected to be a complex map (native YAML) and to be constructed and filled
111                   by the creator of the blueprint.
112
113             docker_config:
114                 default: {}
115                 description: >
116                   Copied from the auxiliary portion of the component spec that contains things
117                   like healthcheck definitions for the Docker component. Health checks are
118                   optional.
119
120             resource_config:
121                 default: {}
122                 description: >
123                   This is used to specify the cpu and memory request and limit for container.
124                   Please specify "requests" property and/or a "limits" property, with subproproperties
125                   for cpu and memory. (https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
126
127             log_info:
128               type: dcae.types.LoggingInfo
129               description: >
130                 Information for setting up centralized logging via ELK.
131               required: false
132
133             tls_info:
134               type: dcae.types.TLSInfo
135               description: >
136                 Information for setting up TLS (HTTPS).
137               required: false
138
139             replicas:
140               type: integer
141               description: >
142                 The number of instances of the component that should be launched initially
143               default: 1
144
145             always_pull_image:
146               type: boolean
147               description: >
148                 Set to true if the orchestrator should always pull a new copy of the image
149                 before deploying.  By default the orchestrator pulls only if the image is
150                 not already present on the Docker host where the container is being launched.
151               default: false
152
153             location_id:
154               type: string
155               description: >
156                 The identifier for the location where the component is to be deployed.
157                 If absent, the plugin uses its configured default location, typically the location
158                 where the plugin is running (the central site).  Also used to supply a location to
159                 the DMaaP bus controller if the component is being provisioned as a publisher or
160                 subscriber to a DMaaP feed or topic.
161               required: false
162
163         interfaces:
164             dcae.interfaces.update:
165                 scale:
166                     implementation: k8s.k8splugin.scale
167                 update_image:
168                     implementation: k8s.k8splugin.update_image
169
170     # The ContainerizedServiceComponent node type is to be used for DCAE service components that
171     # are to be run in a Docker container.  This node type goes beyond that of a ordinary Docker
172     # plugin where it has DCAE platform specific functionality:
173     #
174     #   * Generation of the service component name
175     #   * Managing of service component configuration information
176     #
177     # The plugin deploys the container into a Kubernetes cluster with a very specific choice
178     # of Kubernetes elements that are deliberately not under the control of the blueprint author.
179     # The idea is to deploy all service components in a consistent way, with the details abstracted
180     # away from the blueprint author.
181     dcae.nodes.ContainerizedServiceComponent:
182         derived_from: dcae.nodes.ContainerizedComponent
183         properties:
184             service_component_type:
185                 type: string
186                 description: Service component type of the application being run in the container
187
188             service_id:
189                 type: string
190                 description: >
191                   Unique id for this DCAE service instance this component belongs to. This value
192                   will be applied as a tag in the registration of this component with Consul.
193                 default: Null
194
195             location_id:
196                 type: string
197                 description: >
198                   Location id of where to run the container.  Not used by the plugin.  Here for backward compatibility.
199                 default: Null
200                 required: False
201
202             service_component_name_override:
203                 type: string
204                 description: >
205                     Manually override and set the name for this Docker container node. If this
206                     is set, then the name will not be auto-generated.  Using this feature provides
207                     a service component with a fixed name that's known in advance, but care must be taken
208                     to avoid attempting to deploy two components with the same name.
209                 default: Null
210
211         interfaces:
212             cloudify.interfaces.lifecycle:
213                 create:
214                     # Generate service component name and populate config into Consul
215                     implementation: k8s.k8splugin.create_for_components
216                 start:
217                     # Create Docker container and start
218                     implementation: k8s.k8splugin.create_and_start_container_for_components
219                 stop:
220                     # Stop and remove Docker container
221                     implementation: k8s.k8splugin.stop_and_remove_container
222                 delete:
223                     # Delete configuration from Consul
224                     implementation: k8s.k8splugin.cleanup_discovery
225             dcae.interfaces.policy:
226                 # This is to be invoked by the policy handler upon policy updates
227                 policy_update:
228                     implementation: k8s.k8splugin.policy_update
229
230     # This node type is intended for DCAE service components that use DMaaP and must use the
231     # DMaaP plugin.
232     dcae.nodes.ContainerizedServiceComponentUsingDmaap:
233         derived_from: dcae.nodes.ContainerizedServiceComponent
234         properties:
235             streams_publishes:
236                 description: >
237                   List of DMaaP streams used for publishing.
238
239                   Message router items look like:
240
241                     name: topic00
242                     location: mtc5
243                     client_role: XXXX
244                     type: message_router
245
246                   Data router items look like:
247
248                     name: feed00
249                     location: mtc5
250                     type: data_router
251
252                   This information is forwarded to the dmaap plugin to provision
253                 default: []
254             streams_subscribes:
255                 description: >
256                   List of DMaaP streams used for subscribing.
257
258                   Message router items look like:
259
260                     name: topic00
261                     location: mtc5
262                     client_role: XXXX
263                     type: message_router
264
265                   Data router items look like:
266
267                     name: feed00
268                     location: mtc5
269                     type: data_router
270                     username: king
271                     password: 123456
272                     route: some-path
273                     scheme: https
274
275                   Note that username and password is optional. If not provided or null then the
276                   plugin will generate them.
277
278                 default: []
279         interfaces:
280             cloudify.interfaces.lifecycle:
281                 create:
282                     # Generate service component name, populate config into Consul, set up runtime properties for DMaaP plugin
283                     implementation: k8s.k8splugin.create_for_components_with_streams
284
285     # ContainerizedPlatformComponent is intended for DCAE platform services.  Unlike the components,
286     # platform services have well-known names and well-known ports.
287     dcae.nodes.ContainerizedPlatformComponent:
288         derived_from: dcae.nodes.ContainerizedComponent
289         properties:
290             name:
291                 description: >
292                   Container name used to register with Consul
293             dns_name:
294                 required: false
295                 description: >
296                   Name to be registered in the DNS for the service provided by the container.
297                   If not provided, the 'name' field is used.
298                   This is a work-around for the Kubernetes restriction on having '_' in a DNS name.
299                   Having this field allows a component to look up its configuration using a name that
300                   includes a '_' while providing a legal Kubernetes DNS name.
301
302             host_port:
303                 type: integer
304                 description: >
305                   Network port that the platform service is expecting to expose on the host
306                 default: 0
307
308             container_port:
309                 type: integer
310                 description: >
311                   Network port that the platform service exposes in the container
312                 default: 0
313
314             msb_registration:
315               type: dcae.types.MSBRegistration
316               description: >
317                 Information for registering with MSB
318               required: false
319
320         interfaces:
321             cloudify.interfaces.lifecycle:
322                 create:
323                     # Populate config into Consul
324                     implementation: k8s.k8splugin.create_for_platforms
325                 start:
326                     # Create Docker container and start
327                     implementation: k8s.k8splugin.create_and_start_container_for_platforms
328                 stop:
329                     # Stop and remove Docker container
330                     implementation: k8s.k8splugin.stop_and_remove_container
331                 delete:
332                     # Delete configuration from Consul
333                     implementation: k8s.k8splugin.cleanup_discovery
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
354             dcae.interfaces.scale:
355                 scale:
356                     implementation: k8s.k8splugin.scale
357             dcae.interfaces.update:
358                 update_image:
359                     implementation: k8s.k8splugin.update_image