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