Customizing Presto Docker Images#

Custom Bootstrap Script#

Adding a bootstrap script to the Presto pods allows you to perform custom actions prior to the Presto startup. The script is executed after Presto configuration setup, but before starting the Presto server.

The custom bootstrap script is added via the additionalBootstrapScriptVolume in the Presto resource. The property needs to be a YAML fragment that defines a volume. Any Kubernetes volume type.

The volume is required to have a bootstrap.sh file, and additional files are allowed and provide further resources. The volume is mounted in all the Presto pods.

The script is passed the string literal coordinator or worker when executed. This allows you to use the same script to program different behavior:

if [ "$1" = "coordinator" ]; then
  echo "Bootstrapping coordinator"

elif [ "$1" = "worker" ]; then
  echo "Bootstrapping worker"

fi

For example, the additionalBootstrapScriptVolume can be specified as a ConfigMap volume:

additionalBootstrapScriptVolume:
  configMap:
    name: my-bootstrap-script-volume

You can add the ConfigMap to the Kubernetes resource. The following example contains the bootstrap.sh script inlined in the YAML syntax as multi-line string.

kind: ConfigMap
apiVersion: v1
metadata:
  name: my-bootstrap-script-volume
  namespace: <my-namespace>
data:
  bootstrap.sh: |-
    echo "Hello World." > /tmp/hello.txt

Note that it is also possible to mount multiple bootstrap script volumes via the additionalBootstrapScriptVolumes property:

additionalBootstrapScriptVolumes:
  - configMap:
      name: my-bootstrap-script-volume-1
  - configMap:
      name: my-bootstrap-script-volume-2

Bootstrap scripts are applied in the order they are defined in additionalBootstrapScriptVolumes. additionalBootstrapScriptVolume bootstrap script is applied before any of the scripts defined in additionalBootstrapScriptVolumes.

Building Custom Presto Docker Images#

The Custom Bootstrap Script script mechanism, is a lighter, built-in way to customize the default Presto pod, without the need to build a separate custom Presto Docker image, it should suffice for most extension needs.

If you need to do more extensive changes to the underlying node, it is possible to build custom Presto Docker images used by Presto cluster. This allows you to to extend Presto with additional features, which are not supported by default, or otherwise modify the Presto nodes.

In order to build a custom Presto Docker image you must create a Docker image that is based on the SEP Docker image, e.g.

FROM starburstdata/presto:340-e-k8s-0.34
LABEL maintainer="..."

# Your custom Docker image steps

Modify the /usr/local/bin/entrypoint.sh script, which is responsible for autoconfiguring and launching Presto, if you need changes to the startup. Your custom steps should be executed after Presto is autoconfigured by presto-autoconfigure program, in addition to, or instead of, the additional bootstrap script handling.

Once you have built your custom Presto Docker image and published it to your container registry, you can use it within the cluster by updating the image section of resource:

apiVersion: starburstdata.com/v1
kind: Presto
metadata:
  name: presto-cluster-name
spec:
  image:
    name: custom-org/custom-presto-image:tag
    pullPolicy: IfNotPresent
  ...