3.2.2. Bundle extensions#

This section describes how to bundle various extensions in a Docker image so that Nubus for Kubernetes can load them.

  • For information about available extension types, see Plugin types.

  • For information about how to load an extension, see Load extensions.

This section assumes you have knowledge about how to build Docker images. Describing the single build steps, and how to publish a Docker image to a registry is beyond the scope of this document.

Nubus for Kubernetes uses Docker images to load custom extensions. The purpose of this Docker image is that the Kubernetes cluster starts the image as Docker container and runs the entry point script or binary. The script’s or binary’s only purpose is to copy your extension files to a defined target location depending on the extension type.

To bundle any extension documented in Extensions, use the steps in the following sections:

  1. Extension structure

  2. Bundle Dockerfile

  3. Extension loader

  4. Add plugins

3.2.2.1. Extension structure#

To start with an extension, you need to create the structure for the extension.

  1. Create an empty directory, for example extension-project.

    The directory contains the files of your extension, the script, and the Dockerfile.

  2. Create the subdirectory plugins for the actual plugins of your extension, for example extension-project/plugins.

  3. Create the empty Dockerfile. For the content, see Bundle Dockerfile.

  4. Create the empty loader.sh file. For the content, see Extension loader.

Your directory structure then looks similar to the directory structure in Listing 3.1.

Listing 3.1 Directory structure for Nubus extension#
extension-project/
├── Dockerfile
├── loader.sh
└── plugins
    ├── ldap-acls
    ├── ldap-schema
    ├── udm-handlers
    ├── udm-hooks.d
    ├── udm-modules
    ├── udm-syntax.d
    ├── umc-icons
    └── umc-modules

3.2.2.2. Bundle Dockerfile#

Create your Dockerfile. You can use any Docker image as base image. It must be able to run your script. Keep the image as slim as possible, because it reduces download and container startup time. See the example in Listing 3.2.

Listing 3.2 Example for Dockerfile#
ARG BASE_IMAGE_TAG=3.20
ARG BASE_IMAGE=docker.io/alpine
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}

WORKDIR /

# Copy plugins of the extensions to the Docker image
COPY plugins/ /plugins/
# Copy the plugin loader to the Docker image
COPY loader.sh /bin/loader

CMD ["/bin/loader"]

See also

Writing a Dockerfile | Docker Docs

for getting started with writing a Dockerfile for Docker images.

3.2.2.3. Extension loader#

The extension loader is a script or a binary that runs after the Docker container has started. The loader copies the plugin files of the extension to the /target/ directory, a predefined directory that Nubus for Kubernetes recognizes automatically. Nubus then copies the plugins to the respective Kubernetes pods depending on the plugin type.

For an example of a loader script, see the loader in the openDesk Nubus Customization.

3.2.2.4. Add plugins#

Copy your extension to the directory matching its type. The value for PLUGIN_TYPE comes from the respective plugin type section, see Plugin types.

$ export EXTENSIONS_PROJECT="ABSOLUTE_PATH_TO_YOUR_EXTENSION_PROJECT"
$ export PLUGIN_FILE="my-ldap.schema"

$ cp "$PLUGIN_FILE" "$EXTENSIONS_PROJECT"/plugins/"$PLUGIN_TYPE"/

3.2.2.5. Build and publish#

With the directory and file structure, the Dockerfile, the loader script, and the plugins, you have everything in place and are ready to build the Docker image. Follow the Docker documentation for building the Docker image.

Example
$ export REGISTRY_HOST="FQDN and optional port of your Docker registry"
$ export IMAGE_PATH="PATH to the image on the registry with trailing slash /, if any"
$ export IMAGE_NAME="Your name for the image"
$ export IMAGE_TAG="Your version tag or latest"

$ cd "$EXTENSIONS_PROJECT"
$ docker build -t "$IMAGE_NAME" -f Dockerfile .

# The build process takes some time.

$ docker image push "$REGISTRY_HOST"/"$IMAGE_PATH""$IMAGE_NAME":"$IMAGE_TAG"

See also

Build, tag, and publish an image | Docker Docs

for getting starting with building and tagging a Docker image.