Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License.
|
| 2 | .. http://creativecommons.org/licenses/by/4.0
|
| 3 |
|
| 4 | .. _docker-specification:
|
| 5 |
|
| 6 | Component specification (Docker)
|
| 7 | ================================
|
| 8 |
|
| 9 | The Docker component specification contains the following groups of
|
| 10 | information. Many of these are common to both Docker and CDAP components
|
| 11 | and are therefore described in the common specification.
|
| 12 |
|
| 13 | - :any:`Metadata <metadata>`
|
| 14 | - :any:`Interfaces <interfaces>` including the
|
| 15 | associated :any:`Data Formats <data-formats>`
|
| 16 | - :any:`Parameters <parameters>`
|
| 17 | - :any:`Auxiliary Details <docker-auxiliary-details>`
|
| 18 | - :any:`List of Artifacts <artifacts>`
|
| 19 |
|
| 20 | .. _docker-auxiliary-details:
|
| 21 |
|
| 22 | Auxiliary Details
|
| 23 | -----------------
|
| 24 |
|
| 25 | ``auxiliary`` contains Docker specific details like health check, port
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 26 | mapping, volume mapping and policy reconfiguration script details.
|
| 27 | (Policy reconfiguration is not yet supported).
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 28 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 29 | +--------------------------------+---------+---------------------------+
|
| 30 | | Name | Type | Description |
|
| 31 | +================================+=========+===========================+
|
| 32 | | healthcheck | JSON | *Required*. Health check |
|
| 33 | | | object | definition details |
|
| 34 | +--------------------------------+---------+---------------------------+
|
| 35 | | ports | JSON | each array item maps a |
|
| 36 | | | array | container port to the |
|
| 37 | | | | host port. See example |
|
| 38 | | | | below. |
|
| 39 | +--------------------------------+---------+---------------------------+
|
| 40 | | volume | JSON | each array item contains |
|
| 41 | | | array | a host and container |
|
| 42 | | | | object. See example |
|
| 43 | | | | below. |
|
| 44 | +--------------------------------+---------+---------------------------+
|
| 45 | | *Planned for 1806* | | |
|
| 46 | +--------------------------------+---------+---------------------------+
|
| 47 | | policy | JSON | *Required*. Policy |
|
| 48 | | | array | reconfiguration script |
|
| 49 | | | | details |
|
| 50 | +--------------------------------+---------+---------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 51 |
|
| 52 | Health Check Definition
|
| 53 | ~~~~~~~~~~~~~~~~~~~~~~~
|
| 54 |
|
| 55 | The platform uses Consul to perform periodic health check calls. Consul
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 56 | provides different types of `check
|
| 57 | definitions <https://www.consul.io/docs/agent/checks.html>`__. The
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 58 | platform currently supports http and docker health checks.
|
| 59 |
|
| 60 | When choosing a value for interval, consider that too frequent
|
| 61 | healthchecks will put unnecessary load on Consul and DCAE. If there is a
|
| 62 | problematic resource, then more frequent healthchecks are warranted (eg
|
Stanislav Chlebec | e7933a0 | 2018-11-15 10:08:31 +0100 | [diff] [blame] | 63 | 15s or 60s), but as stability increases, so can these values, (eg
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 64 | 300s).
|
| 65 |
|
| 66 | When choosing a value for timeout, consider that too small a number will
|
| 67 | result in increasing timeout failures, and too large a number will
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 68 | result in a delay in the notification of the resource problem. A
|
| 69 | suggestion is to start with 5s and work from there.
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 70 |
|
| 71 | http
|
| 72 | ^^^^
|
| 73 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 74 | +--------------------------------+---------+---------------------------+
|
| 75 | | Property Name | Type | Description |
|
| 76 | +================================+=========+===========================+
|
| 77 | | type | string | *Required*. ``http`` |
|
| 78 | +--------------------------------+---------+---------------------------+
|
| 79 | | interval | string | Interval duration in |
|
| 80 | | | | seconds i.e. ``60s`` |
|
| 81 | +--------------------------------+---------+---------------------------+
|
| 82 | | timeout | string | Timeout in seconds i.e. |
|
| 83 | | | | ``5s`` |
|
| 84 | +--------------------------------+---------+---------------------------+
|
| 85 | | endpoint | string | *Required*. GET endpoint |
|
| 86 | | | | provided by the component |
|
| 87 | | | | for Consul to call to |
|
| 88 | | | | check health |
|
| 89 | +--------------------------------+---------+---------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 90 |
|
| 91 | Example:
|
| 92 |
|
| 93 | .. code:: json
|
| 94 |
|
| 95 | "auxilary": {
|
| 96 | "healthcheck": {
|
| 97 | "type": "http",
|
| 98 | "interval": "15s",
|
| 99 | "timeout": "1s",
|
| 100 | "endpoint": "/my-health"
|
| 101 | }
|
| 102 | }
|
| 103 |
|
| 104 | docker script example
|
| 105 | ^^^^^^^^^^^^^^^^^^^^^
|
| 106 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 107 | +--------------------------------+---------+---------------------------+
|
| 108 | | Property Name | Type | Description |
|
| 109 | +================================+=========+===========================+
|
| 110 | | type | string | *Required*. ``docker`` |
|
| 111 | +--------------------------------+---------+---------------------------+
|
| 112 | | interval | string | Interval duration in |
|
| 113 | | | | seconds i.e. ``15s`` |
|
| 114 | +--------------------------------+---------+---------------------------+
|
| 115 | | timeout | string | Timeout in seconds i.e. |
|
| 116 | | | | ``1s`` |
|
| 117 | +--------------------------------+---------+---------------------------+
|
| 118 | | script | string | *Required*. Full path of |
|
| 119 | | | | script that exists in the |
|
| 120 | | | | Docker container to be |
|
| 121 | | | | executed |
|
| 122 | +--------------------------------+---------+---------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 123 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 124 | Consul will use the `Docker exec
|
| 125 | API <https://docs.docker.com/engine/api/v1.29/#tag/Exec>`__ to
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 126 | periodically call your script in your container. It will examine the
|
| 127 | script result to identify whether your component is healthy. Your
|
| 128 | component is considered healthy when the script returns ``0`` otherwise
|
| 129 | your component is considered not healthy.
|
| 130 |
|
| 131 | Example:
|
| 132 |
|
| 133 | .. code:: json
|
| 134 |
|
| 135 | "auxilary": {
|
| 136 | "healthcheck": {
|
| 137 | "type": "docker",
|
| 138 | "script": "/app/resources/check_health.py",
|
| 139 | "timeout": "30s",
|
| 140 | "interval": "180s"
|
| 141 | }
|
| 142 | }
|
| 143 |
|
| 144 | Ports
|
| 145 | ~~~~~
|
| 146 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 147 | This method of exposing/mapping a local port to a host port is NOT
|
| 148 | RECOMMENDED because of the possibility of port conflicts. If multiple
|
| 149 | instances of a docker container will be running, there definitely will
|
| 150 | be port conflicts. Use at your own risk. (The preferred way to expose a
|
| 151 | port is to do so in the Dockerfile as described
|
| 152 | :any:`here <dcae-cli-docker-ports>`).
|
| 153 |
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 154 | .. code:: json
|
| 155 |
|
| 156 | "auxilary": {
|
| 157 | "ports": ["8080:8000"]
|
| 158 | }
|
| 159 |
|
| 160 | In the example above, container port 8080 maps to host port 8000.
|
| 161 |
|
| 162 | Volume Mapping
|
| 163 | ~~~~~~~~~~~~~~
|
| 164 |
|
| 165 | .. code:: json
|
| 166 |
|
| 167 | "auxilary": {
|
| 168 | "volumes": [
|
| 169 | {
|
| 170 | "container": {
|
| 171 | "bind": "/tmp/docker.sock",
|
| 172 | "mode": "ro"
|
| 173 | },
|
| 174 | "host": {
|
| 175 | "path": "/var/run/docker.sock"
|
| 176 | }
|
| 177 | }
|
| 178 | ]
|
| 179 | }
|
| 180 |
|
| 181 | At the top-level:
|
| 182 |
|
| 183 | +---------------+-------+-------------------------------------+
|
| 184 | | Property Name | Type | Description |
|
| 185 | +===============+=======+=====================================+
|
| 186 | | volumes | array | Contains container and host objects |
|
| 187 | +---------------+-------+-------------------------------------+
|
| 188 |
|
| 189 | The ``container`` object contains:
|
| 190 |
|
Lusheng Ji | eaac78d | 2018-06-06 00:20:03 -0400 | [diff] [blame] | 191 |
|
| 192 | +-----------------------+-----------------------+-------------------------------+
|
| 193 | | Property Name | Type | Description |
|
| 194 | +=======================+=======================+===============================+
|
| 195 | | bind | string | path to the container |
|
| 196 | | | | volume |
|
| 197 | +-----------------------+-----------------------+-------------------------------+
|
| 198 | | mode | string | ro - indicates |
|
| 199 | | | | read-only volume |
|
| 200 | +-----------------------+-----------------------+-------------------------------+
|
| 201 | | | | w - indicates that |
|
| 202 | | | | the contain can write |
|
| 203 | | | | into the bind mount |
|
| 204 | +-----------------------+-----------------------+-------------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 205 |
|
| 206 | The ``host`` object contains:
|
| 207 |
|
| 208 | +---------------+--------+-------------------------+
|
| 209 | | Property Name | Type | Description |
|
| 210 | +===============+========+=========================+
|
| 211 | | path | string | path to the host volume |
|
| 212 | +---------------+--------+-------------------------+
|
| 213 |
|
| 214 | Here’s an example of the minimal JSON that must be provided as an input:
|
| 215 |
|
| 216 | .. code:: json
|
| 217 |
|
| 218 | "auxilary": {
|
| 219 | "volumes": [
|
| 220 | {
|
| 221 | "container": {
|
| 222 | "bind": "/tmp/docker.sock"
|
| 223 | },
|
| 224 | "host": {
|
| 225 | "path": "/var/run/docker.sock"
|
| 226 | }
|
| 227 | }
|
| 228 | ]
|
| 229 | }
|
| 230 |
|
| 231 | In the example above, the container volume “/tmp/docker.sock” maps to
|
| 232 | host volume “/var/run/docker.sock”.
|
| 233 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 234 |
|
| 235 | Policy (not yet supported)
|
| 236 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 237 |
|
| 238 | Policy changes made in the Policy UI will be provided to the Docker
|
| 239 | component by triggering a script that is defined here.
|
| 240 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 241 | +--------------------------------+---------+---------------------------+
|
| 242 | | Property Name | Type | Description |
|
| 243 | +================================+=========+===========================+
|
| 244 | | reconfigure_type | string | *Required*. Current value |
|
| 245 | | | | supported is ``policy`` |
|
| 246 | +--------------------------------+---------+---------------------------+
|
| 247 | | script_path | string | *Required*. Current value |
|
| 248 | | | | for ‘policy’ |
|
| 249 | | | | reconfigure_type must be |
|
| 250 | | | | “/opt/app/reconfigure.sh” |
|
| 251 | +--------------------------------+---------+---------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 252 |
|
| 253 | Example:
|
| 254 |
|
| 255 | .. code:: json
|
| 256 |
|
| 257 | "auxilary": {
|
| 258 | "policy": {
|
| 259 | "reconfigure_type": "policy",
|
| 260 | "script_path": "/opt/app/reconfigure.sh"
|
| 261 | }
|
| 262 | }
|
| 263 |
|
| 264 | The docker script interface is as follows: \`/opt/app/reconfigure.sh
|
| 265 | $reconfigure_type {“updated policies”: , “application config”: }
|
| 266 |
|
Lusheng Ji | eaac78d | 2018-06-06 00:20:03 -0400 | [diff] [blame] | 267 | +---------------------+--------------+----------------------------------------+
|
| 268 | | Name | Type | Description |
|
| 269 | +=====================+==============+========================================+
|
| 270 | | reconfigure_type | string | policy |
|
| 271 | +---------------------+--------------+----------------------------------------+
|
| 272 | | updated_policies | json | TBD |
|
| 273 | +---------------------+--------------+----------------------------------------+
|
| 274 | | updated_appl_config | json | complete generated app_config, not |
|
| 275 | | | | fully-resolved, but ``policy-enabled`` |
|
| 276 | | | | parameters have been updated. In order |
|
| 277 | | | | to get the complete updated |
|
| 278 | | | | app_config, the component would have |
|
| 279 | | | | to call ``config-binding-service``. |
|
| 280 | +---------------------+--------------+----------------------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 281 |
|
| 282 | Docker Component Spec - Complete Example
|
| 283 | ----------------------------------------
|
| 284 |
|
| 285 | .. code:: json
|
| 286 |
|
| 287 | {
|
| 288 | "self": {
|
| 289 | "version": "1.0.0",
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 290 | "name": "yourapp.component.kpi_anomaly",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 291 | "description": "Classifies VNF KPI data as anomalous",
|
| 292 | "component_type": "docker"
|
| 293 | },
|
| 294 | "streams": {
|
| 295 | "subscribes": [{
|
| 296 | "format": "dcae.vnf.kpi",
|
| 297 | "version": "1.0.0",
|
| 298 | "route": "/data",
|
| 299 | "type": "http"
|
| 300 | }],
|
| 301 | "publishes": [{
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 302 | "format": "yourapp.format.integerClassification",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 303 | "version": "1.0.0",
|
| 304 | "config_key": "prediction",
|
| 305 | "type": "http"
|
| 306 | }]
|
| 307 | },
|
| 308 | "services": {
|
| 309 | "calls": [{
|
| 310 | "config_key": "vnf-db",
|
| 311 | "request": {
|
| 312 | "format": "dcae.vnf.meta",
|
| 313 | "version": "1.0.0"
|
| 314 | },
|
| 315 | "response": {
|
| 316 | "format": "dcae.vnf.kpi",
|
| 317 | "version": "1.0.0"
|
| 318 | }
|
| 319 | }],
|
| 320 | "provides": [{
|
| 321 | "route": "/score-vnf",
|
| 322 | "request": {
|
| 323 | "format": "dcae.vnf.meta",
|
| 324 | "version": "1.0.0"
|
| 325 | },
|
| 326 | "response": {
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 327 | "format": "yourapp.format.integerClassification",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 328 | "version": "1.0.0"
|
| 329 | }
|
| 330 | }]
|
| 331 | },
|
| 332 | "parameters": [
|
| 333 | {
|
| 334 | "name": "threshold",
|
| 335 | "value": 0.75,
|
| 336 | "description": "Probability threshold to exceed to be anomalous"
|
| 337 | }
|
| 338 | ],
|
| 339 | "auxilary": {
|
| 340 | "healthcheck": {
|
| 341 | "type": "http",
|
| 342 | "interval": "15s",
|
| 343 | "timeout": "1s",
|
| 344 | "endpoint": "/my-health"
|
| 345 | }
|
| 346 | },
|
| 347 | "artifacts": [{
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame] | 348 | "uri": "fake.nexus.att.com/dcae/kpi_anomaly:1.0.0",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 349 | "type": "docker image"
|
| 350 | }]
|
| 351 | }
|