The plugin is invoked by the component when the core component is used by one of the Pineapple clients. To trigger invocation by the core component the plugin needs to be configured.
Two steps are needed to configure the plugin:
For more info about configuration of plugins:
The plugin supports the operations:
For more information about the default operations, refer to the Operation and workflow reference.
When invoked with this operation the plugin will traverse the module model and validate that the Docker entities (e.g. images and containers) defined in the model exists at the targeted Docker host:
When invoked with this operation the plugin will ignore the module model, but create a report that lists all defined images and containers at the targeted Docker host.
When invoked with this operation the plugin will traverse the module model and create all the Docker entities (e.g. images and containers) defined in the model:
The result of this operation should be that the subsequent execution of the test operation should result in a 100% success (Otherwise you have found a bug in the plugin).
When invoked with this operation the plugin will traverse the module model and delete all the Docker entities (e.g. images and containers) defined in the model at the target Docker host:
The result of this operation should be that the subsequent execution of the test operation should result in a lot of failures since none of the resources should exist.
The purpose of defining a resource for this plugin is twofold:
To define a new resource, add a resource element to the target environment in the configuration file ${pineapple.home.dir}/conf/resources.xml:
<?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://pineapple.dev.java.net/ns/environment_1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <environments> <environment id="linux-vagrant" > <resources> <resource id="docker-node" plugin-id="com.alpha.pineapple.plugin.docker" /> <property value="192.168.34.10" key="host"/> <property value="8082" key="port"/> <property value="1000" key="timeout"/> </resource> </resources> </environment> </environments> </configuration>
For all the details about configuration of environments and resources, please visit the Environment Configuration Reference.
The semantics of the resource element is:
Identifies the resource uniquely in the current environment. This ID is referenced from models which intends to use the plugin.
A module defines the input used by Pineapple to execute operations. A module is defined by a directory layout. Part of a module is the model(s) which defines what happens when the module is invoked. A model is put together by one or more sub models from different plugins. Each plugin defines its own schema for its particular model
This plugin defines a schema named The Docker plugin schema which defines the http://pineapple.dev.java.net/ns/plugin/docker_1_0 namespace. For more information about where the schema can be found, refer to the Schema locations for plugins page.
The list of entities which should be processed when the plugin is invoked are defined in the module model files which are located at ${module-dir}/models/${environment}.xml where:
If the model file doesn't exist for an environment where the plugin should be used, then create the model file and name it after the target environment, e.g. linux-vagrant.xml for an environment named linux-vagrant.
Module model files are defined using the module model configuration schema which defines the http://pineapple.dev.java.net/ns/module_model_1_0 namespace. Since module model files contain elements from multiple namespaces all the elements and attributes should be qualified. The header and root element should be defined as (look in the Modules configuration document for more details):
This example shows definition of the minimal model file for linux-vagrant:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" />
The next step is to include the The Docker plugin schema to get access to the entities defined by the schema:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:dkp="http://pineapple.dev.java.net/ns/plugin/docker_1_0" />
Now we have a minimal module model file with three namespaces:
Add a new model stanza with a target-resource attribute. The value of the target-resource should match the id of the resource which was defined previously in the section Define resource, e.g. docker-node:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:dkp="http://pineapple.dev.java.net/ns/plugin/docker_1_0" /> <mmd:model target-resource="docker-node"> <mmd:content /> </mmd:model> </mmd:models>
Add content to the model which uses the plugin through the docker-node reference:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:dkp="http://pineapple.dev.java.net/ns/plugin/docker_1_0" /> <mmd:model target-resource="docker-node"> <mmd:content> <dkp:docker> </dkp:docker> </mmd:content> </mmd:model> </mmd:models>
Define a sequence of entities which should be processed when Pineapple is invoked with the model:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:dkp="http://pineapple.dev.java.net/ns/plugin/docker_1_0" /> <mmd:model target-resource="docker-node"> <mmd:content> <dkp:docker> <dkp:image repository="centos" tag="latest" /> <dkp:taggedImage> <dkp:sourceImage repository="centos" tag="latest" /> <dkp:targetImage repository="pineapple/centos" tag="latest" /> <dkp:taggedImage> </dkp:docker> </mmd:content> </mmd:model> </mmd:models>
Defines a Docker image and supports its creation and deletion. An image is defined through a Docker repository and image tag:
<dkp:image repository="centos" tag="latest" />
Operation semantics:
The semantics of the attributes are:
Defines a tagged Docker image and supports its creation and deletion:
<dkp:taggedImage> <dkp:sourceImage repository="centos" tag="latest" /> <dkp:targetImage repository="pineapple/centos" tag="latest" /> <dkp:taggedImage>
Operation semantics:
The semantics of the elements and attributes are:
Mandatory attribute. Defines the source image where the tagged image is created from.
Mandatory attribute. Defines the repository where the tagged image is create from.
Example of official repository name is ubuntu which holds Ubuntu images. Example of user repository (which has the name format user/repo) is mrpono/pineapple.
Optional attribute. Defines the tag of the source image. Default value is latest.
Example of image tags are: latest and 12.10.
Defines a tagged Docker image and supports its creation and deletion from a Dockerfile:
<dkp:image-from-dockerfile source-directory="modulepath:dockersrc" pull-image="false" > <dkp:target-image repository="pineapple/httpd" tag="1.0" /> </dkp:image-from-dockerfile>
Operation semantics:
The semantics of the elements and attributes are:
Mandatory attribute. Defines source directory which must contain a Dockerfile in the root. The source directory can contain other file resources referenced and used by the Dockerfile. Other file resources will be packed into a TAR archive along with the Dockerfile and uploaded to the Docker daemon to be used at input for creation of the image.
The element supports the usage of the modulepath: prefix which is resolved to the absolute directory where the model is defined.
Mandatory attribute. Defines the repository for the tagged image.
Example of official repository name is ubuntu which holds Ubuntu images. Example of user repository (which has the name format user/repo) is mrpono/pineapple.
Defines a named Docker container and supports its creation and deletion:
<dkp:container name="alpha01" > <dkp:image repository="pineapple/httpd" tag="1.0" /> <dkp:configuration> <dkp:exposed-ports> <dkp:port value="8080" type="tcp" /> </dkp:exposed-ports> </dkp:configuration> </dkp:container>
Operation semantics:
The semantics of the elements and attributes are:
Mandatory attribute. Defines the name of container. The name of the container must be unique within the Docker daemon.
By default containers are primarily identified by an ID in Docker, but since Pineapple is stateless, there is no way for Pineapple to maintain the container ID across invocation of a model. Usage of a container name solves that problem.
Optional attribute. Defines which state the container should enter as part of its creation, i.e then the model is invoked with the deploy-configuration operation. The default value is running, e.g. the container created and started.
The supported states are:
When the model is invoked with a undeploy-configuration operation then a container handled a bit differently depending on its state:
Mandatory attribute. Defines the repository for the image.
Example of official repository name is ubuntu which holds Ubuntu images. Example of user repository (which has the name format user/repo) is mrpono/pineapple.
Optional element. Supports detailed (embedded) configuration of the container.
Optional attribute. Defines reference to reusable container configuration in model. The purpose of supporting referenced container configurations it to enable reuse of container properties which is defined for multiple container within a model, and thus reducing the amount of XML:
<dkp:container-configuration id="my-container-config"> <dkp:exposed-ports> <dkp:port value="8080" type="tcp" /> </dkp:exposed-ports> </dkp:container-configuration> <dkp:container name="alpha02" > <dkp:image repository="pineapple/httpd" tag="1.0" /> <dkp:configuration ref="my-container-config" /> </dkp:container>
A referenced container configuration is defined using the container-configuration element.
If a reference isn't valid, i.e. the referenced container configuration doesn't exist within the model, then the reference is just ignored.
The container configuration within the container takes precedence over a refereced container configuration. Example #1: If property A is defined with value V within the container and property A is also defined in a referenced configuration with value R, then the value of A is resolved to V when the container is created.
Example #2: If property A isn't defined within the container and property A is defined in a referenced configuration with value R, then the value of A is resolved to R when the container is created.
Example #3: If property A isn't defined within the container and the reference to the referenced configuration is invalid, then the value of A is resolved to the default value D when the container is created.
Optional attributes. The container configuration supports these Docker properties defined as attributes on the configuration element with simple types:
The container configuration supports these Docker container properties as object based structures:
These properties are described in detail below.
Optional element. Defines a command to run specified as a string or an array of strings. The command is specificed as a string. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
<dkp:container> <dkp:cmd>date</dkp:cmd> </dkp:container>
Multiple commands (e.g. parameters) are defined within the same cmd element with a space in between:
<dkp:configuration> <dkp:cmd>/bin/sh date</dkp:cmd> </dkp:configuration>
Optional element. Defines the default command to execute at runtime, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
<dkp:container> <dkp:entrypoint>/bin/bash</dkp:entrypoint> </dkp:container>
Multiple commands (e.g. parameters) are defined within the same entrypoint element with a space in between:
<dkp:configuration> <dkp:entrypoint>/bin/sh date</dkp:entrypoint> </dkp:configuration>
Optional element. Defines a list of environment variables defined within the container. Each variable is defined with a variable element. A variable element defines a mandatory name attribute for the variable name and a mandatory value attribute for the variable value.
<dkp:container> <dkp:env> <dkp:variable name="PATH" value="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" /> </dkp:env> </dkp:container>
Optional element. Defines list of TCP and UDP ports exposed by the container. Each exposed port is defined with a port element. A port element defines a mandatory value attribute. Legal values are integers between 1 to 65535. A port element defines a mandatory type attribute. Legal values are tcp or udp.
If two ports with identical port numbers are added to the model, then only the first port is registered.
<dkp:container> <dkp:exposed-ports> <dkp:port value="8080" type="tcp" /> </dkp:exposed-ports> </dkp:container>
Optional element. Defines list of labels to register with the container. Each label is defined with a label element. A label element defines a mandatory key attribute for the label key and a mandatory value attribute for the label value.
If two labels with identical keys are added to the model, then only the first label is registered.
<dkp:container> <dkp:labels> <dkp:label key="com.example.vendor" value="Acme" /> <dkp:label key="com.example.license" value="GPL" /> <dkp:label key="com.example.version" value="1.0" /> </dkp:labels> </dkp:container>
Optional element.
Defines the command to be executed at a later time, when the image is used as the base for another build (see the Docker ONBUILD command reference). The command is specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
<dkp:container> <dkp:on-build>ADD . /app/src</dkp:on-build> </dkp:container>
Multiple commands (e.g. parameters) are defined within the same on-build element with a space in between.
Optional element. Defines list of volumes mounted by the container. Each volume is defined with a volume element. A volume element defines a mandatory mountpoint attribute. Legal values are string based path expressions.
If two volumes with identical mountpoints are added to the model, then only the first volume is registered.
<dkp:container> <dkp:volumes> <dkp:volume mountpoint="/tmp" /> <dkp:volume mountpoint="/opt" /> </dkp:volumes> </dkp:container>
Optional element. Defines the host specific container configuration. The host configuration is defined with a host-config element. The host configuration contains properties and objects.
<dkp:container> <dkp:host-config> <dkp:restart-policy maximum-retry-count="5" name="on-failure" /> <dkp:port-bindings> <dkp:bind container-port="8080" container-type="tcp" host-port="8080" /> <dkp:port-bindings> </dkp:host-config> </dkp:container>
The host config element supports these Docker properties defined as attributes:
The host config element supports these Docker container properties as object based structures:
These properties are described in detail below.
TODO: Complete documentation.
Optional element. Defines the XXXX, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
TODO: add example.
Multiple commands (e.g. XXX) are defined within the same binds element with a space in between.
Optional element. Defines the list of DNS servers for the container to use, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
<dkp:host-config> <dkp:dns>8.8.8.8 and 8.8.4.4</dkp:dns> </dkp:host-config>
Multiple servers are defined within the same dns element with a space in between.
TODO: Complete documentation.
Optional element. Defines the list of DNS search domains for the container to use, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
TODO: add example.
Multiple domains are defined within the same dns-search element with a space in between.
TODO: Complete documentation.
Optional element. Defines the list of host names/IP mappings to add to the container’s /etc/hosts file, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
TODO: add example.
Multiple host names are defined within the same extra-hosts element with a space in between.
TODO: Complete documentation.
Optional element. Defines the list of additional groups that the container process will run as, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
TODO: add example.
Multiple host names are defined within the same group-add element with a space in between.
Optional element. Defines the list of container network links that the container will create to other containers, specified as a string or an array of strings. Each space in the string is interpreted as a separator and will result in interpretation of the string as an array.
A link is defined by a container-name:dns:
<dkp:host-config> <dkp:links>backend01:httpd1 backend02:httpd2 backend03:httpd3 backend04:httpd4</dkp:links> </dkp:host-config>
Multiple links are defined within the same links element with a space in between.
TODO: Complete documentation. security-opt defines list of string values to customize labels for MLS systems, such as SELinux.
TODO: Complete documentation. volumes-from defines list of volumes to take from other container.
Optional element. Defines the list of port bindings for the container. Binds (and exposes) container ports at the host. A binding is defined with a bind element.
A bind element defines a mandatory container-port attribute which defines the container port which should be bound and exposed to the host. Legal values are 1 to 65535. A bind element defines a mandatory host-port attribute which defines to which host port the container port should be bound Legal values are 1 to 65535. A bind element defines a mandatory type attribute which defines type of the bound container port. Legal values are tcp or udp.
If two bindings with identical container ports are added to the model, then only the first binding is registered.
<dkp:container> <dkp:host-config> <dkp:port-bindings> <dkp:bind container-port="8080" host-port="8080" type="tcp" /> <dkp:port-bindings> </dkp:host-config> </dkp:container>
Optional element. Defines the restart policy for the container. The policy is defined with a restart-policy element. The policy defines a mandatory maximum-retry-count attribute which defines the number of times to retry before giving up. Legal values are 0 to 1000000. The policy defines a mandatory name attribute which defines the used policy. Legal values are always or on-failure.
<dkp:container> <dkp:host-config> <dkp:restart-policy maximum-retry-count="5" name="on-failure" /> </dkp:host-config> </dkp:container>
Defines a named Docker container configuration which can be referenced from containers within the model during creation:
<dkp:container-configuration id="my-container-config"> <dkp:exposed-ports> <dkp:port value="8080" type="tcp" /> </dkp:exposed-ports> </dkp:container-configuration> <dkp:container name="alpha02" > <dkp:image repository="pineapple/httpd" tag="1.0" /> <dkp:configuration ref="my-container-config" /> </dkp:container>
Operation semantics:
The semantics of the elements and attributes are: