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
|
| 63 | 15s or 60s), but as stablility increases, so can these values, (eg
|
| 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 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 191 | +-----------------------+-----------------------+-----------------------+
|
| 192 | | Property Name | Type | Description |
|
| 193 | +=======================+=======================+=======================+
|
| 194 | | bind | string | path to the container |
|
| 195 | | | | volume |
|
| 196 | +-----------------------+-----------------------+-----------------------+
|
| 197 | | mode | string | “ro” - indicates |
|
| 198 | | | | read-only volume |
|
| 199 | +-----------------------+-----------------------+-----------------------+
|
| 200 | | | “” - indicates that |
|
| 201 | | | the contain can write |
|
| 202 | | | into the bind mount |
|
| 203 | +-----------------------+-----------------------+-----------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 204 |
|
| 205 | The ``host`` object contains:
|
| 206 |
|
| 207 | +---------------+--------+-------------------------+
|
| 208 | | Property Name | Type | Description |
|
| 209 | +===============+========+=========================+
|
| 210 | | path | string | path to the host volume |
|
| 211 | +---------------+--------+-------------------------+
|
| 212 |
|
| 213 | Here’s an example of the minimal JSON that must be provided as an input:
|
| 214 |
|
| 215 | .. code:: json
|
| 216 |
|
| 217 | "auxilary": {
|
| 218 | "volumes": [
|
| 219 | {
|
| 220 | "container": {
|
| 221 | "bind": "/tmp/docker.sock"
|
| 222 | },
|
| 223 | "host": {
|
| 224 | "path": "/var/run/docker.sock"
|
| 225 | }
|
| 226 | }
|
| 227 | ]
|
| 228 | }
|
| 229 |
|
| 230 | In the example above, the container volume “/tmp/docker.sock” maps to
|
| 231 | host volume “/var/run/docker.sock”.
|
| 232 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 233 |
|
| 234 | Policy (not yet supported)
|
| 235 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 236 |
|
| 237 | Policy changes made in the Policy UI will be provided to the Docker
|
| 238 | component by triggering a script that is defined here.
|
| 239 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 240 | +--------------------------------+---------+---------------------------+
|
| 241 | | Property Name | Type | Description |
|
| 242 | +================================+=========+===========================+
|
| 243 | | reconfigure_type | string | *Required*. Current value |
|
| 244 | | | | supported is ``policy`` |
|
| 245 | +--------------------------------+---------+---------------------------+
|
| 246 | | script_path | string | *Required*. Current value |
|
| 247 | | | | for ‘policy’ |
|
| 248 | | | | reconfigure_type must be |
|
| 249 | | | | “/opt/app/reconfigure.sh” |
|
| 250 | +--------------------------------+---------+---------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 251 |
|
| 252 | Example:
|
| 253 |
|
| 254 | .. code:: json
|
| 255 |
|
| 256 | "auxilary": {
|
| 257 | "policy": {
|
| 258 | "reconfigure_type": "policy",
|
| 259 | "script_path": "/opt/app/reconfigure.sh"
|
| 260 | }
|
| 261 | }
|
| 262 |
|
| 263 | The docker script interface is as follows: \`/opt/app/reconfigure.sh
|
| 264 | $reconfigure_type {“updated policies”: , “application config”: }
|
| 265 |
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 266 | +--------------+--------------+----------------------------------------+
|
| 267 | | Name | Type | Description |
|
| 268 | +==============+==============+========================================+
|
| 269 | | reconfigure_ | string | “policy” |
|
| 270 | | type | | |
|
| 271 | +--------------+--------------+----------------------------------------+
|
| 272 | | updated_poli | json | TBD |
|
| 273 | | cies | | |
|
| 274 | +--------------+--------------+----------------------------------------+
|
| 275 | | updated_appl | json | complete generated app_config, not |
|
| 276 | | _config | | fully-resolved, but ``policy-enabled`` |
|
| 277 | | | | parameters have been updated. In order |
|
| 278 | | | | to get the complete updated |
|
| 279 | | | | app_config, the component would have |
|
| 280 | | | | to call ``config-binding-service``. |
|
| 281 | +--------------+--------------+----------------------------------------+
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 282 |
|
| 283 | Docker Component Spec - Complete Example
|
| 284 | ----------------------------------------
|
| 285 |
|
| 286 | .. code:: json
|
| 287 |
|
| 288 | {
|
| 289 | "self": {
|
| 290 | "version": "1.0.0",
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 291 | "name": "yourapp.component.kpi_anomaly",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 292 | "description": "Classifies VNF KPI data as anomalous",
|
| 293 | "component_type": "docker"
|
| 294 | },
|
| 295 | "streams": {
|
| 296 | "subscribes": [{
|
| 297 | "format": "dcae.vnf.kpi",
|
| 298 | "version": "1.0.0",
|
| 299 | "route": "/data",
|
| 300 | "type": "http"
|
| 301 | }],
|
| 302 | "publishes": [{
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 303 | "format": "yourapp.format.integerClassification",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 304 | "version": "1.0.0",
|
| 305 | "config_key": "prediction",
|
| 306 | "type": "http"
|
| 307 | }]
|
| 308 | },
|
| 309 | "services": {
|
| 310 | "calls": [{
|
| 311 | "config_key": "vnf-db",
|
| 312 | "request": {
|
| 313 | "format": "dcae.vnf.meta",
|
| 314 | "version": "1.0.0"
|
| 315 | },
|
| 316 | "response": {
|
| 317 | "format": "dcae.vnf.kpi",
|
| 318 | "version": "1.0.0"
|
| 319 | }
|
| 320 | }],
|
| 321 | "provides": [{
|
| 322 | "route": "/score-vnf",
|
| 323 | "request": {
|
| 324 | "format": "dcae.vnf.meta",
|
| 325 | "version": "1.0.0"
|
| 326 | },
|
| 327 | "response": {
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 328 | "format": "yourapp.format.integerClassification",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 329 | "version": "1.0.0"
|
| 330 | }
|
| 331 | }]
|
| 332 | },
|
| 333 | "parameters": [
|
| 334 | {
|
| 335 | "name": "threshold",
|
| 336 | "value": 0.75,
|
| 337 | "description": "Probability threshold to exceed to be anomalous"
|
| 338 | }
|
| 339 | ],
|
| 340 | "auxilary": {
|
| 341 | "healthcheck": {
|
| 342 | "type": "http",
|
| 343 | "interval": "15s",
|
| 344 | "timeout": "1s",
|
| 345 | "endpoint": "/my-health"
|
| 346 | }
|
| 347 | },
|
| 348 | "artifacts": [{
|
Ralph Knag | d2cd31b | 2018-04-02 16:27:46 -0400 | [diff] [blame^] | 349 | "uri": "fake.nexus.att.com/dcae/kpi_anomaly:1.0.0",
|
Ralph Knag | 1fca6ac | 2017-12-05 12:05:57 -0500 | [diff] [blame] | 350 | "type": "docker image"
|
| 351 | }]
|
| 352 | }
|