Skip to content

About

a clickhouse plugin for dokku

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

27 stars

Watchers

3 watching

Forks

Latest commit

 

History

538 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dokku clickhouse Build Status IRC Network

Official clickhouse plugin for dokku. Currently defaults to installing clickhouse/clickhouse-server 26.10.3.7.

Sponsors

The clickhouse plugin was generously sponsored by the following:

Requirements

  • dokku 0.35.x+
  • docker 1.8.x

Installation

# on 0.35.x+
sudo dokku plugin:install https://github.com/dokku/dokku-clickhouse.git --name clickhouse

Commands

clickhouse:app-links [<app>]                       # list all Clickhouse service links for a given app
clickhouse:backup <service> <bucket-name> [--id <id>] [-u|--use-iam] [--all-databases] # create a backup of the Clickhouse service to an existing s3 bucket
clickhouse:backup-auth <service> <aws-access-key-id> <aws-secret-access-key> <aws-default-region> <aws-signature-version> <endpoint-url> [--id <id>] # set up authentication for backups on the Clickhouse service
clickhouse:backup-deauth <service> [--id <id>]     # remove backup authentication for the Clickhouse service
clickhouse:backup-logs <service> [-t|--tail [<tail-num>]] # print the most recent output of the scheduled backups of the service
clickhouse:backup-schedule <service> <schedule> <bucket-name> [--id <id>] [-u|--use-iam] # schedule a backup of the Clickhouse service
clickhouse:backup-schedule-cat <service> [--id <id>] # cat the crontab line of a scheduled backup for the service
clickhouse:backup-set-encryption <service> <passphrase> [--id <id>] # set encryption for all future backups of Clickhouse service
clickhouse:backup-set-public-key-encryption <service> <public-key-id> [--id <id>] # set GPG Public Key encryption for all future backups of Clickhouse service
clickhouse:backup-unschedule <service> [--id <id>|--all] # unschedule the backup of the Clickhouse service
clickhouse:backup-unset-encryption <service> [--id <id>] # unset encryption for future backups of the Clickhouse service
clickhouse:backup-unset-public-key-encryption <service> [--id <id>] # unset GPG Public Key encryption for future backups of the Clickhouse service
clickhouse:clone <service> <new-service> [--clone-flags...] # create container <new-name> then copy data from <name> into <new-name>
clickhouse:connect <service> [--database <database>] [--user <user>] # connect to the service via the clickhouse connection tool
clickhouse:create <service> [--create-flags...]    # create a Clickhouse service
clickhouse:create-database <service> <database>    # create a database in the Clickhouse service
clickhouse:create-user <service> <user> [<password>] # create a user in the Clickhouse service
clickhouse:destroy <service> [-f|--force]          # delete the Clickhouse service/data/container if there are no links left
clickhouse:destroy-database <service> <database> [-f|--force] # destroy a database created in the Clickhouse service
clickhouse:destroy-user <service> <user> [-f|--force] # destroy a user created in the Clickhouse service
clickhouse:enter <service>                         # enter or run a command in a running Clickhouse service container
clickhouse:exists <service>                        # check if the Clickhouse service exists
clickhouse:export <service> [-f|--file <path>] [--force] [--all-databases] [--database <database>] # export a dump of the Clickhouse service database
clickhouse:expose <service> <ports...>             # expose a Clickhouse service on custom host:port if provided (random port on the 0.0.0.0 interface if otherwise unspecified)
clickhouse:import <service> [-f|--file <path>] [--all-databases] [--database <database>] # import a dump into the Clickhouse service database
clickhouse:info [<service>] [--info-flags...]      # print the service information
clickhouse:label <service> <key=value>...          # add docker labels to the service container
clickhouse:link <service> [<app>] [--link-flags...] # link the Clickhouse service to the app
clickhouse:link-migrate <service> [<app>]          # move apps linked to the Clickhouse service off the deprecated docker link and onto a network
clickhouse:linked <service> [<app>]                # check if the Clickhouse service is linked to an app
clickhouse:links <service>                         # list all apps linked to the Clickhouse service
clickhouse:list                                    # list all Clickhouse services
clickhouse:logs <service> [-t|--tail [<tail-num>]] # print the most recent log(s) for this service
clickhouse:mount [--replace] <service> <source:container-dir[:options]>... # mount a host path or docker volume into the service container
clickhouse:pause <service>                         # pause a running Clickhouse service
clickhouse:promote <service> [<app>]               # promote service <service> as CLICKHOUSE_URL in <app>
clickhouse:reexpose <service>                      # reexpose a Clickhouse service, applying its expose settings
clickhouse:reset <service> [-f|--force] [--database <database>] # delete all data in the Clickhouse service, keeping the service and its links
clickhouse:restart <service>                       # graceful shutdown and restart of the Clickhouse service container
clickhouse:set <service> <key> [<value>] [--id <id>] # set or clear a property for a service
clickhouse:set-user-password <service> <user> [<password>] [-n|--no-restart] # change the password of a user created in the Clickhouse service
clickhouse:start <service>                         # start a previously stopped Clickhouse service
clickhouse:stop <service>                          # stop a running Clickhouse service
clickhouse:unexpose <service>                      # unexpose a previously exposed Clickhouse service
clickhouse:unlabel [--all] <service> [<key>...]    # remove one or all docker labels from the service container
clickhouse:unlink <service> [<app>] [-n|--no-restart] # unlink the Clickhouse service from the app
clickhouse:unmount [--all] <service> [<source:container-dir>...] # remove one or all mounts from the service container
clickhouse:upgrade <service> [--upgrade-flags...]  # upgrade service <service> to the specified versions

Usage

Help for any commands can be displayed by specifying the command as an argument to clickhouse:help. Plugin help output in conjunction with any files in the docs/ folder is used to generate the plugin documentation. Please consult the clickhouse:help command for any undocumented commands.

Basic Usage

create a Clickhouse service

# usage
dokku clickhouse:create <service> [--create-flags...]

flags:

  • --backend <string>: the execution backend to create the service with, docker or compose (default: docker)
  • -c|--config-options <string>: extra arguments for the process the service container runs, not docker flags; use mount for mounts
  • -C|--custom-env <string>: semi-colon delimited environment variables to start the service with
  • --definition <string>: the definition to run the service on, instead of the one its image and version resolve to
  • -i|--image <string>: the image name to start the service with
  • -I|--image-version <string>: the image version to start the service with
  • -N|--initial-network <string>: the initial network to attach the service to
  • --label <stringArray>: a docker label to put on the service container, as =, repeatable
  • --log-driver <string>: the docker logging driver to run the service container with (default: the daemon's own)
  • --log-opt <strings>: a comma-separated list of key=value docker log options for the service container
  • -m|--memory <int>: container memory limit in megabytes (default: unlimited)
  • -p|--password <string>: override the user-level service password, for datastores that have one
  • -P|--post-create-network <strings>: a comma-separated list of networks to attach the service container to after service creation
  • -S|--post-start-network <strings>: a comma-separated list of networks to attach the service container to after service start
  • --restart <string>: the docker restart policy to run the service container with (default: always)
  • -r|--root-password <string>: override the root-level service password, for datastores that have one
  • --service-memory <string>: memory in megabytes the datastore itself is told to use, such as a cache size or a heap, for datastores that support it (default: the datastore's own)
  • -s|--shm-size <string>: override shared memory size for the service docker container
  • --volume <stringArray>: a host path or docker volume to mount into the service container, as :[:], repeatable
  • --volume-target <stringArray>: mount one of the definition's volumes at another container path, as =, repeatable
  • --wait-timeout <string>: seconds to wait for the service to become ready (default: the datastore's own)

Create a clickhouse service named lollipop:

dokku clickhouse:create lollipop

You can also specify the image and image version to use for the service. It must be compatible with the clickhouse/clickhouse-server image.

dokku clickhouse:create lollipop --image "clickhouse/clickhouse-server" --image-version "26.10.3.7"

An image other than clickhouse/clickhouse-server has no version to fall back on, because the version this plugin pins belongs to clickhouse/clickhouse-server, so name one alongside it.

dokku clickhouse:create lollipop --image <image> --image-version <version>

You can also specify custom environment variables to start the clickhouse service in semicolon-separated form.

dokku clickhouse:create lollipop --custom-env "USER=alpha;HOST=beta"

The container log is bounded by whatever dokku logs:set --global max-size says, and by dokku's own default where it says nothing, which a service may override for itself.

dokku clickhouse:create lollipop --log-opt max-size=20m,max-file=3

The container is restarted by docker whenever it stops, which a service may change for itself.

dokku clickhouse:create lollipop --restart unless-stopped

The container carries a docker label for each --label, which may be repeated, beyond the ones dokku puts on it. Keys starting with dokku. or com.dokku. are dokku's own and are refused.

dokku clickhouse:create lollipop --label traefik.enable=true --label com.example.team=data

The service is waited on until it answers, for as long as the datastore's own default, which a slow host may raise for every service with dokku clickhouse:set --global wait-timeout or a service may raise for itself.

dokku clickhouse:create lollipop --wait-timeout 120

The config options are handed to the process the container runs, not to docker, so a host path or docker volume is mounted with --volume, which may be repeated.

dokku clickhouse:create lollipop --volume /var/lib/dokku/data/storage/lollipop:/opt/extra:ro

The definition's own volumes can be mounted at another path in the container, for an image that keeps its data somewhere else, with --volume-target, which may be repeated.

dokku clickhouse:create lollipop --volume-target data=/srv/clickhouse

The service passwords are generated unless they are given. A datastore without a root password refuses --root-password rather than dropping it.

dokku clickhouse:create lollipop --password <password> --root-password <root-password>

delete the Clickhouse service/data/container if there are no links left

# usage
dokku clickhouse:destroy <service> [-f|--force]

flags:

  • -f|--force: force the destruction of the service

Destroy the service, it's data, and the running container:

dokku clickhouse:destroy lollipop

A service that is still linked to an app is not destroyed, and the apps it is linked to are named. Unlink them first.

print the service information

# usage
dokku clickhouse:info [<service>] [--info-flags...]

flags:

  • --backend: show the execution backend the service was created with
  • --backup-access-key-id-fingerprint: show a sha256 fingerprint of the stored backup access key id
  • --backup-all-databases: show whether backups hold every database in the service rather than only the one named for it
  • --backup-auth-fingerprint: show a sha256 fingerprint of the stored backup access key id and secret
  • --backup-authenticated: show whether backup credentials are stored for the service
  • --backup-bucket: show the bucket scheduled backups are shipped to
  • --backup-default-region: show the region backups authenticate against
  • --backup-encrypted: show whether scheduled backups are encrypted with a passphrase
  • --backup-encryption-fingerprint: show a sha256 fingerprint of the stored backup passphrase
  • --backup-endpoint-url: show the s3-compatible endpoint backups are shipped to
  • --backup-keyserver: show the keyserver backup public keys are fetched from
  • --backup-mailto: show who cron mails the output of scheduled backups to in place of the global MAILTO
  • --backup-object-name: show the name backups are uploaded under in place of the default
  • --backup-public-key-id: show the gpg public key id backups are encrypted with
  • --backup-schedule: show the cron schedule backups run on
  • --backup-schedules: show every scheduled backup, as id, schedule, bucket and use-iam
  • --backup-secret-access-key-fingerprint: show a sha256 fingerprint of the stored backup secret access key
  • --backup-signature-version: show the signature version backups authenticate with
  • --backup-storage-class: show the s3 storage class backups are uploaded with
  • --backup-timestamp: show whether backups are uploaded under a key ending in the time they started
  • --backup-use-iam: show whether scheduled backups authenticate with an instance role
  • --config-dir: show the service configuration directory
  • --config-options: show the config options the service container is run with
  • --custom-env: show the custom environment the service container is run with
  • --data-dir: show the service data directory
  • --database-name: show the name of the database inside the service
  • --databases: show the databases an app can be linked to in the service, space separated
  • --definition: show the definition the service was created with
  • --dsn: show the service DSN
  • --export-args: show the extra arguments every export of the service is run with
  • --expose-host: show the host the exposed DSN names
  • --expose-mode: show whether exposed ports are published through an ambassador or directly by the service container
  • --exposed-dsn: show the DSN the service is reached at through its exposed ports
  • --exposed-ports: show service exposed ports
  • --id: show the service container id
  • --image: show the image the service runs
  • --image-version: show the image version the service was created with
  • --import-args: show the extra arguments every import into the service is run with
  • --initial-network: show the initial network being connected to
  • --internal-ip: show the service internal ip
  • --labels: show the docker labels the service container is made with beyond dokku's own, as a json object
  • --links: show the service app links
  • --log-driver: show the docker logging driver the service container is run with
  • --log-opt: show the docker log options the service container is run with
  • --memory: show the memory limit the service container is run with
  • --mounts: show the host paths and docker volumes mounted into the service container
  • --password-fingerprint: show a sha256 fingerprint of the service password
  • --port-bind-address: show the address exposed ports without one of their own are bound on
  • --port-source-range: show the only range of client addresses the exposed ports accept
  • --post-create-network: show the networks to attach to after service container creation
  • --post-start-network: show the networks to attach to after service container start
  • --restart-policy: show the restart policy the service container is run with
  • --root-password-fingerprint: show a sha256 fingerprint of the service root password
  • --service: show the name of the service
  • --service-memory: show the memory in megabytes the datastore itself is told to use
  • --service-root: show the service root directory
  • --shm-size: show the shared memory size the service container is run with
  • --status: show the service running status
  • --users: show the users an app can be linked as in the service, space separated
  • --version: show the service image version
  • --volume-targets: show the container paths the service's volumes are mounted at in place of the definition's
  • --wait-timeout: show the seconds the service is waited on to become ready

Get connection information as follows:

dokku clickhouse:info lollipop

Alongside the connection information this reports the properties set on the service, the state it was created with, and its backup settings. A property that was never set, or that was unset, reports as empty. Omit the service to report on every clickhouse service:

dokku clickhouse:info

The information can be read by machine, one json object per service:

dokku clickhouse:info lollipop --format json

You can also retrieve a specific piece of service info via a flag, which prints it on its own:

dokku clickhouse:info lollipop --dsn
dokku clickhouse:info lollipop --status
dokku clickhouse:info lollipop --internal-ip
dokku clickhouse:info lollipop --initial-network
dokku clickhouse:info lollipop --databases
dokku clickhouse:info lollipop --users

NOTE: a flag cannot be combined with --format, and only one may be given

The exposed dsn is the one a client off the host connects with. It names the expose-host, or the first global domain without one, and is empty until the service is exposed and there is a host to name:

dokku clickhouse:info lollipop --exposed-dsn

The properties clickhouse:set writes are reported under the names it takes, so a value read here can be written back:

dokku clickhouse:set lollipop initial-network my-network

The stored backup credentials and passphrase are never printed. Each is reported as a lowercase hex sha256 fingerprint of that stored value, with surrounding whitespace trimmed, so a copy of one value can be compared against it:

dokku clickhouse:info lollipop --backup-access-key-id-fingerprint
dokku clickhouse:info lollipop --backup-secret-access-key-fingerprint
dokku clickhouse:info lollipop --backup-encryption-fingerprint

A fingerprint is empty when that value is not stored. The access key id and the secret are also reported as one fingerprint of the pair, which is empty until both are stored and is what backup-auth writes in one call:

dokku clickhouse:info lollipop --backup-auth-fingerprint

The service's passwords are reported the same way, and are empty for a password the datastore does not have:

dokku clickhouse:info lollipop --password-fingerprint

The same fingerprints can be computed from the values that were passed to set, backup-auth and backup-set-encryption:

printf '%s' "$AWS_ACCESS_KEY_ID" | sha256sum
printf '%s' "$AWS_SECRET_ACCESS_KEY" | sha256sum
printf '%s\n%s' "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" | sha256sum
printf '%s' "$PASSPHRASE" | sha256sum
printf '%s' "$PASSWORD" | sha256sum

list all Clickhouse services

# usage
dokku clickhouse:list

List all services:

dokku clickhouse:list

print the most recent log(s) for this service

# usage
dokku clickhouse:logs <service> [-t|--tail [<tail-num>]]

flags:

  • -t|--tail <int>: tail the logs, optionally showing this many lines

You can tail logs for a particular service:

dokku clickhouse:logs lollipop

By default, logs will not be tailed, but you can do this with the --tail flag:

dokku clickhouse:logs lollipop --tail

By default the last 100 lines are shown, but a different count can be specified:

dokku clickhouse:logs lollipop --tail=5

link the Clickhouse service to the app

# usage
dokku clickhouse:link <service> [<app>] [--link-flags...]

flags:

  • -a|--alias <string>: the prefix of the config variable the service url is set as on the app, which is suffixed with _URL
  • --database <string>: the database in the service to link the app to, in place of the one named for the service
  • -e|--env-var <string>: the full name of the config variable the service url is set as on the app, used instead of an alias and not suffixed with _URL
  • -n|--no-restart: whether to skip restarting the app
  • -q|--querystring <string>: ampersand delimited querystring arguments to append to the service url after a ?
  • --user <string>: the user in the service to link the app as, in place of the one the service was created with

A clickhouse service can be linked to a container. The app and the service are put on a private docker network made for that link alone, so the app reaches the service as dokku-clickhouse-lollipop, and two apps linked to the same service cannot reach each other through it. The app's running containers join it straight away, and the containers it is built, deployed and run in from then on join it when they are made. Here we link it to our playground app.

NOTE: this will restart your app

dokku clickhouse:link lollipop playground

The following will be set on the linked application by default:

CLICKHOUSE_URL=clickhouse://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000

The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the expose subcommand. Earlier versions of the plugin linked an app with a docker link, which docker has deprecated, and which set DOKKU_CLICKHOUSE_LOLLIPOP_PORT style variables on the app's containers. Docker 29 no longer sets them, so an app reading them should read CLICKHOUSE_URL instead. An app linked that way keeps its docker link, and updating the plugin warns about it, until it is moved onto a network with clickhouse:link-migrate.

NOTE: every link uses a docker network of its own. docker's default address pools hold about 31 networks, so a server with many links may need a larger default-address-pools setting in /etc/docker/daemon.json, which only applies once docker is restarted. A link that cannot get a network fails and says what to change, and nothing is set on the app.

Another service can be linked to your app:

dokku clickhouse:link other_service playground

The url can be set under another name with the --alias flag. The value given is the prefix of the config variable, which is suffixed with _URL and holds the same url:

dokku clickhouse:link lollipop playground --alias BLUE_CLICKHOUSE

This will set the following on the linked application instead of CLICKHOUSE_URL:

BLUE_CLICKHOUSE_URL=clickhouse://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000

An alias whose variable is already set on the app is refused, and unlink removes the variable whatever alias it was set under. An app that expects the url under a name that does not end in _URL can be given that name in full with the --env-var flag, which cannot be combined with --alias:

dokku clickhouse:link lollipop playground --env-var MB_DB_CONNECTION_URI

This will set the following on the linked application instead of CLICKHOUSE_URL:

MB_DB_CONNECTION_URI=clickhouse://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000

A name already set on the app is refused. Arguments can be appended to the url as a querystring with the --querystring flag:

dokku clickhouse:link lollipop playground --querystring "foo=bar&baz=qux"

This will cause CLICKHOUSE_URL to be set as:

clickhouse://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000?foo=bar&baz=qux

It is possible to change the protocol for CLICKHOUSE_URL by setting the environment variable CLICKHOUSE_DATABASE_SCHEME on the app. Link records the variable it set, so unlink still removes it after the scheme or querystring on it changes. A link made by an earlier version of the plugin is recorded the next time link or promote runs for it, and until then we advise you to unlink before changing the scheme.

dokku config:set playground CLICKHOUSE_DATABASE_SCHEME=clickhouse2
dokku clickhouse:link lollipop playground

This will cause CLICKHOUSE_URL to be set as:

clickhouse2://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000

An app can be linked to a database made with create-database rather than the one named for the service with the --database flag:

dokku clickhouse:link lollipop playground --database paintshop

An app can be linked as a user made with create-user rather than as the service's own with the --user flag, which can be combined with the --database flag:

dokku clickhouse:link lollipop playground --user painter

The database and user a link was made on are recorded, so unlink, promote and a password change find the url they gave the app. An app that is already linked has to be unlinked and linked again to move it to another database or user.

move apps linked to the Clickhouse service off the deprecated docker link and onto a network

# usage
dokku clickhouse:link-migrate <service> [<app>]

Earlier versions of the plugin, and the bash plugins before them, linked an app with a docker link, which docker 30.0 removes. Such a link keeps working until it is moved, and updating the plugin and deploying the app warn about it. Move every app linked to the lollipop clickhouse service onto the network of its link:

dokku clickhouse:link-migrate lollipop

Move only the playground app:

dokku clickhouse:link-migrate lollipop playground

The network is made and the app's running containers join it before the docker link is removed, so nothing is restarted, and the app's config is not changed, since the service answers to the same host on the network. An app that cannot be moved keeps its docker link, the error says why, and the other apps are still moved. An app that was already moved is put back on its network, which repairs a network that went missing.

NOTE: every link uses a docker network of its own. a host that runs out of docker's address pools is told the default-address-pools setting to add to /etc/docker/daemon.json. it only applies once docker is restarted, as a reload does not apply it, and then the command can be run again.

unlink the Clickhouse service from the app

# usage
dokku clickhouse:unlink <service> [<app>] [-n|--no-restart]

flags:

  • -n|--no-restart: whether to skip restarting the app

You can unlink a clickhouse service:

NOTE: this will restart your app and unset related environment variables

dokku clickhouse:unlink lollipop playground

The network the link ran over is removed straight away, so the app's running containers can no longer reach the service, even with --no-restart. An app is still linked after its CLICKHOUSE_URL is changed to point elsewhere, and is unlinked the same way. The variable it now holds is not the service's, so it is left alone, nothing is unset, the app is not restarted, and a warning says so. A variable link set that has only had its scheme or querystring changed still points at the service, and is unset.

set or clear a property for a service

# usage
dokku clickhouse:set <service> <key> [<value>] [--id <id>]

flags:

  • --allow-restart: restart or reexpose the service when the property only takes effect that way and its value changed
  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property
  • --global: set the property for every service of the datastore, taking [] with no service name
  • --id <string>: record the property on this backup schedule instead of on the service
  • --no-restart: do not restart the linked apps when a password change updates the url they hold

Set the network to attach after the service container is started:

dokku clickhouse:set lollipop post-create-network custom-network

Set multiple networks:

dokku clickhouse:set lollipop post-create-network custom-network,other-network

Unset the post-create-network value:

dokku clickhouse:set lollipop post-create-network

Limit the container to 512 megabytes of memory, or go back to no limit with 0:

dokku clickhouse:set lollipop memory 512

Give the container a shared memory size of its own:

dokku clickhouse:set lollipop shm-size 256m

Start the container with semi-colon delimited environment variables of your own:

dokku clickhouse:set lollipop custom-env "TZ=UTC;LANG=C.UTF-8"

Pass extra arguments to the process the service container runs. These are not docker flags, so use mount for mounts. The value follows -- so that its leading dash is not read as a flag:

dokku clickhouse:set lollipop config-options -- "<config-options...>"

Go back to running the process with the datastore's own arguments alone:

dokku clickhouse:set lollipop config-options

Change the password in the datastore and in the url every linked app holds, restarting the apps. The value is never printed back, and info reports a fingerprint of it:

dokku clickhouse:set --allow-restart lollipop password "<new-password>"

Give the linked apps the new url without restarting them:

dokku clickhouse:set --allow-restart --no-restart lollipop password "<new-password>"

Change one of the settings backup-auth stores, such as the endpoint of an s3 compatible service, without passing the rest again:

dokku clickhouse:set lollipop backup-endpoint-url https://nyc3.digitaloceanspaces.com

Rotate the credentials backups are shipped with one at a time. The value is never printed back, and info reports a fingerprint of that value:

dokku clickhouse:set lollipop backup-access-key-id AKIAIOSFODNN7EXAMPLE
dokku clickhouse:set lollipop backup-secret-access-key "<secret-access-key>"

Encrypt backups with a passphrase, or with a gpg public key:

dokku clickhouse:set lollipop backup-encryption-passphrase "<passphrase>"
dokku clickhouse:set lollipop backup-public-key-id "<public-key-id>"

Ship the default scheduled backup to another bucket, or have it authenticate with an instance role, when that is the only schedule. Both rewrite the crontab entry. With more than one schedule, change a schedule with backup-schedule --id:

dokku clickhouse:set lollipop backup-bucket other-bucket
dokku clickhouse:set lollipop backup-use-iam true

Record a backup setting on one schedule. An empty value clears that schedule's own value and leaves the service's. The bucket and the instance role cannot be set this way:

dokku clickhouse:set lollipop backup-storage-class STANDARD_IA --id monthly

Give one schedule its own endpoint. The access key and the secret are set with backup-auth --id, and set rotates one of them once both are stored:

dokku clickhouse:set lollipop backup-endpoint-url https://nyc3.digitaloceanspaces.com --id monthly

Set the keyserver a public key for backup encryption is fetched from:

dokku clickhouse:set lollipop backup-keyserver hkp://keys.example.com

Set the s3 storage class backups are uploaded with, one of STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE or GLACIER_IR:

dokku clickhouse:set lollipop backup-storage-class STANDARD_IA

Go back to uploading backups with the bucket's default storage class:

dokku clickhouse:set lollipop backup-storage-class

Upload backups under a name of your own rather than clickhouse-lollipop:

dokku clickhouse:set lollipop backup-object-name db/latest

Upload every backup to the same key, without a timestamp, so bucket versioning and lifecycle rules can keep and rotate them:

dokku clickhouse:set lollipop backup-timestamp false

Go back to timestamped backups:

dokku clickhouse:set lollipop backup-timestamp

Mail the output of scheduled backups to a comma-separated list of email addresses or local users rather than to the global cron MAILTO. Requires a dokku version that reads json entries from the cron-entries plugin trigger, and a mail transfer agent on the host:

dokku clickhouse:set lollipop backup-mailto ops@example.com,dba@example.com

Go back to mailing scheduled backup output to the global cron MAILTO:

dokku clickhouse:set lollipop backup-mailto

Cap the container log at a size of your own rather than the one it inherits:

dokku clickhouse:set lollipop log-opt max-size=20m,max-file=3

Keep the log unbounded, which is what a service had before there was anything to say here:

dokku clickhouse:set lollipop log-opt max-size=unlimited

Send the container log somewhere other than the daemon's own driver:

dokku clickhouse:set lollipop log-driver journald

Restart the container unless it was stopped on purpose, including across a docker restart:

dokku clickhouse:set lollipop restart-policy unless-stopped

Go back to always restarting the container:

dokku clickhouse:set lollipop restart-policy

Wait up to two minutes for the service to answer, used the next time it is started:

dokku clickhouse:set lollipop wait-timeout 120

Go back to the wait timeout the host or the datastore sets:

dokku clickhouse:set lollipop wait-timeout

Publish exposed ports that have no address of their own on one address rather than on every interface:

dokku clickhouse:set lollipop port-bind-address 10.0.0.5

Only accept connections to the exposed ports from clients in one IP address or CIDR:

dokku clickhouse:set lollipop port-source-range 10.0.0.0/8

Go back to accepting every client:

dokku clickhouse:set lollipop port-source-range

Name the host the exposed dsn points clients at, when they reach the server by a name or address other than its global domain. It does not change where the ports are bound:

dokku clickhouse:set lollipop expose-host db.example.com

Go back to naming the first global domain:

dokku clickhouse:set lollipop expose-host

Publish the exposed ports on the service container itself rather than through an ambassador container, which relays every connection. A port-source-range cannot be used with it:

dokku clickhouse:set lollipop expose-mode direct

Go back to publishing the exposed ports through an ambassador container:

dokku clickhouse:set lollipop expose-mode

Mount one of the definition's volumes at another path in the container, for an image that keeps its data somewhere else. Each volume is named by where it lives in the service directory (config, data), and several are separated by spaces:

dokku clickhouse:set lollipop volume-targets data=/srv/clickhouse

Go back to mounting every volume where the definition does:

dokku clickhouse:set lollipop volume-targets

NOTE: a network, a log setting, a restart policy, a volume target, the config options, the custom environment, the memory limit or the shared memory size reaches the container the next time one is built, and set warns that it does. clickhouse:restart keeps the container it has, so use clickhouse:stop and then clickhouse:start on a service that is already running. NOTE: a port-bind-address or port-source-range reaches an exposed service with clickhouse:reexpose, which replaces the container publishing its ports and leaves the service container running. NOTE: an expose-mode, or a port-bind-address for a service exposed directly, reaches an exposed service with clickhouse:reexpose, which stops and starts a running service after asking. It also reaches the service the next time it is restarted, or stopped and started.

mount a host path or docker volume into the service container

# usage
dokku clickhouse:mount [--replace] <service> <source:container-dir[:options]>...

flags:

  • --replace: replace the service's entire set of mounts with the ones given
  • --volume-chown <string>: who to hand the mounted directory to, for a host path inside the service's directory; not valid with --replace
  • --volume-options <string>: comma-separated docker mount options, such as z or nocopy; not valid with --replace
  • --volume-readonly: mount the volume read only; not valid with --replace
  • --volume-subpath <string>: a subpath within the source to mount rather than the source itself; not valid with --replace

Mount a host directory into the service container:

dokku clickhouse:mount lollipop /var/lib/dokku/data/storage/lollipop:/opt/extra

The source is an absolute host path, which must already exist, or the name of a docker volume. Options follow a second colon: ro or rw, docker's own mount options, volume-subpath= and volume-chown=:

dokku clickhouse:mount lollipop /var/lib/dokku/data/storage/lollipop:/opt/extra:ro,z

A subpath mounts a directory within the source rather than the source itself. A docker volume mounted from a subpath needs Docker Engine 26.0 or newer, and takes no mount option but nocopy.

dokku clickhouse:mount lollipop my-volume:/opt/extra:volume-subpath=uploads

A chown hands the mounted directory to a user before the container is made: herokuish, heroku, paketo, root or a uid. It is only taken for a host path inside the service's own directory.

dokku clickhouse:mount lollipop /var/lib/dokku/services/clickhouse/lollipop/extra:/opt/extra:volume-chown=heroku

The same can be said with flags instead:

dokku clickhouse:mount lollipop /var/lib/dokku/data/storage/lollipop:/opt/extra --volume-readonly --volume-options z

Mounting the same source at the same directory again rewrites its options:

dokku clickhouse:mount lollipop /var/lib/dokku/data/storage/lollipop:/opt/extra

Replace every mount the service has with the ones given:

dokku clickhouse:mount --replace lollipop /srv/a:/opt/a:ro /srv/b:/opt/b

NOTE: a mount cannot land where one of the definition's volumes is mounted, which for a volume moved with the volume-targets property is where it was moved to. NOTE: a mount reaches the container the next time one is built. clickhouse:restart keeps the container it has, so use clickhouse:stop and then clickhouse:start on a service that is already running.

remove one or all mounts from the service container

# usage
dokku clickhouse:unmount [--all] <service> [<source:container-dir>...]

flags:

  • --all: remove every mount the service has

Remove a mount, naming it the way it was mounted:

dokku clickhouse:unmount lollipop /var/lib/dokku/data/storage/lollipop:/opt/extra

Remove every mount the service has:

dokku clickhouse:unmount --all lollipop

NOTE: the mount is removed from the container the next time one is built. clickhouse:restart keeps the container it has, so use clickhouse:stop and then clickhouse:start on a service that is already running.

add docker labels to the service container

# usage
dokku clickhouse:label <service> <key=value>...

Add a label to the service container:

dokku clickhouse:label lollipop traefik.enable=true

Several may be given at once, and a value may hold commas and spaces:

dokku clickhouse:label lollipop com.example.team=data "traefik.http.routers.lollipop.middlewares=auth,compress"

Labelling a key the service already has replaces its value. Keys starting with dokku. or com.dokku. are dokku's own and are refused.

NOTE: a label reaches the container the next time one is built. clickhouse:restart keeps the container it has, so use clickhouse:stop and then clickhouse:start on a service that is already running.

remove one or all docker labels from the service container

# usage
dokku clickhouse:unlabel [--all] <service> [<key>...]

flags:

  • --all: remove every label the service has

Remove a label, naming it by its key:

dokku clickhouse:unlabel lollipop traefik.enable

Remove every label the service was given:

dokku clickhouse:unlabel --all lollipop

NOTE: the label is removed from the container the next time one is built. clickhouse:restart keeps the container it has, so use clickhouse:stop and then clickhouse:start on a service that is already running.

Service Lifecycle

The lifecycle of each service can be managed through the following commands:

connect to the service via the clickhouse connection tool

# usage
dokku clickhouse:connect <service> [--database <database>] [--user <user>]

flags:

  • --database <string>: the database in the service to connect to, in place of the one named for the service
  • --user <string>: the user in the service to connect as, in place of the one the service was created with

Connect to the service via the clickhouse connection tool:

NOTE: disconnecting from ssh while running this command may leave zombie processes due to moby/moby#9098

dokku clickhouse:connect lollipop

The connection tool only shows a prompt when it is given a terminal, which ssh allocates when run with -t. Without a terminal, statements are read from stdin instead.

dokku clickhouse:connect lollipop < statements.txt

Connect to a database made with create-database rather than the one the service was created with:

dokku clickhouse:connect lollipop --database paintshop

Connect as a user made with create-user rather than as the service's own:

dokku clickhouse:connect lollipop --user painter

enter or run a command in a running Clickhouse service container

# usage
dokku clickhouse:enter <service>

A shell can be opened against a running service. Filesystem changes will not be saved to disk.

NOTE: disconnecting from ssh while running this command may leave zombie processes due to moby/moby#9098

dokku clickhouse:enter lollipop

You may also run a command directly against the service. Filesystem changes will not be saved to disk.

dokku clickhouse:enter lollipop touch /tmp/test

expose a Clickhouse service on custom host:port if provided (random port on the 0.0.0.0 interface if otherwise unspecified)

# usage
dokku clickhouse:expose <service> <ports...>

flags:

  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property
  • -f|--force: stop and start a running service without asking when its container has to publish other ports

Expose the service on the service's normal ports, allowing access to it from the public interface (0.0.0.0):

dokku clickhouse:expose lollipop 9000 8123

Expose the service on the service's normal ports, with the first on a specified ip address (127.0.0.1):

dokku clickhouse:expose lollipop 127.0.0.1:9000 8123

Expose the service on random ports on a single address, and only to clients in one network:

dokku clickhouse:set lollipop port-bind-address 10.0.0.5
dokku clickhouse:set lollipop port-source-range 10.0.0.0/8
dokku clickhouse:expose lollipop

Expose the service by publishing its ports on the service container itself rather than through an ambassador container. A running service is stopped and started to publish them, after asking, or without asking when --force is given:

dokku clickhouse:set lollipop expose-mode direct
dokku clickhouse:expose lollipop --force

Expose the service through an ambassador made from another image:

dokku clickhouse:expose lollipop --ambassador-image dokku/ambassador:0.8.4

Print the dsn a client off the host connects with, which names the expose-host or the first global domain:

dokku clickhouse:info lollipop --exposed-dsn

unexpose a previously exposed Clickhouse service

# usage
dokku clickhouse:unexpose <service>

flags:

  • -f|--force: stop and start a running service without asking when its container has to publish other ports

Unexpose the service, removing access to it from the public interface (0.0.0.0):

dokku clickhouse:unexpose lollipop

Unexpose a running service exposed directly, stopping and starting it without asking so that its container stops publishing the ports:

dokku clickhouse:unexpose lollipop --force

reexpose a Clickhouse service, applying its expose settings

# usage
dokku clickhouse:reexpose <service>

flags:

  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property
  • -f|--force: stop and start a running service without asking when its container has to publish other ports

Apply a changed port-bind-address or port-source-range to an exposed service, on the ports it is already exposed on:

dokku clickhouse:set lollipop port-source-range 10.0.0.0/8
dokku clickhouse:reexpose lollipop

Move an exposed service between being published through an ambassador and directly, stopping and starting it without asking:

dokku clickhouse:set lollipop expose-mode direct
dokku clickhouse:reexpose lollipop --force

Replace the ambassador with one made from another image. --ambassador-image wins over PLUGIN_AMBASSADOR_IMAGE, which wins over the ambassador-image global property:

dokku clickhouse:reexpose lollipop --ambassador-image dokku/ambassador:0.8.4
dokku clickhouse:set --global ambassador-image dokku/ambassador:0.8.4

NOTE: a service published through an ambassador only has the ambassador replaced, so the service keeps running, though connections made through the exposed ports are dropped. An ambassador that already matches the service's settings and is publishing is left alone. NOTE: a service whose container has to publish other ports, because it is exposed directly or is being moved between expose modes, is stopped and started. A running service is asked about first, and nothing is changed if the answer is no. NOTE: A service that is not exposed is refused, as is one published through an ambassador that is not running.

promote service as CLICKHOUSE_URL in

# usage
dokku clickhouse:promote <service> [<app>]

If you have a clickhouse service linked to an app and try to link another clickhouse service another link environment variable will be generated automatically:

DOKKU_CLICKHOUSE_AQUA_URL=clickhouse://:ANOTHER_PASSWORD@dokku-clickhouse-other-service:9000/other_service

You can promote the new service to be the primary one:

NOTE: this will restart your app

dokku clickhouse:promote other_service playground

This will replace CLICKHOUSE_URL with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example:

CLICKHOUSE_URL=clickhouse://:ANOTHER_PASSWORD@dokku-clickhouse-other-service:9000/other_service
DOKKU_CLICKHOUSE_AQUA_URL=clickhouse://:ANOTHER_PASSWORD@dokku-clickhouse-other-service:9000/other_service
DOKKU_CLICKHOUSE_BLACK_URL=clickhouse://:SOME_PASSWORD@dokku-clickhouse-lollipop:9000/lollipop

start a previously stopped Clickhouse service

# usage
dokku clickhouse:start <service>

flags:

  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property

Start the service:

dokku clickhouse:start lollipop

A service comes back on the version it was created with, or was last upgraded to, whatever version the plugin ships now. The image is fetched if the host no longer has it. A service that has never recorded a version and has no container left to read one from cannot be placed, and is reported rather than started on a guess. Use clickhouse:upgrade to say which version it should run.

stop a running Clickhouse service

# usage
dokku clickhouse:stop <service>

Stop the service and removes the running container:

dokku clickhouse:stop lollipop

pause a running Clickhouse service

# usage
dokku clickhouse:pause <service>

Pause the running container for the service:

dokku clickhouse:pause lollipop

graceful shutdown and restart of the Clickhouse service container

# usage
dokku clickhouse:restart <service>

flags:

  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property

Restart the service:

dokku clickhouse:restart lollipop

upgrade service to the specified versions

# usage
dokku clickhouse:upgrade <service> [--upgrade-flags...]

flags:

  • --ambassador-image <string>: the image to make the ambassador from, with a tag or digest, overriding PLUGIN_AMBASSADOR_IMAGE and the ambassador-image global property
  • -c|--config-options <string>: extra arguments for the process the service container runs, not docker flags; use mount for mounts
  • -C|--custom-env <string>: semi-colon delimited environment variables to start the service with
  • --definition <string>: the definition to move the service onto, instead of the one its image and version resolve to
  • -i|--image <string>: the image to upgrade the service to
  • -I|--image-version <string>: the image version to upgrade the service to
  • -N|--initial-network <string>: the initial network to attach the service to
  • --label <stringArray>: a docker label to put on the service container, as =, repeatable; replaces every label the service has
  • --log-driver <string>: the docker logging driver to run the service container with (default: the daemon's own)
  • --log-opt <strings>: a comma-separated list of key=value docker log options for the service container
  • -m|--memory <int>: container memory limit in megabytes, 0 for unlimited
  • --no-migrate: place the service on the --definition named with its data left where it is, for a service whose data that definition already reads
  • -P|--post-create-network <strings>: a comma-separated list of networks to attach the service container to after service creation
  • -S|--post-start-network <strings>: a comma-separated list of networks to attach the service container to after service start
  • --restart <string>: the docker restart policy to run the service container with (default: always)
  • -R|--restart-apps: whether to stop and start the linked apps around the upgrade, required for one that migrates the data
  • --service-memory <string>: memory in megabytes the datastore itself is told to use, such as a cache size or a heap, empty for the datastore's own
  • -s|--shm-size <string>: override shared memory size for the service docker container
  • --volume <stringArray>: a host path or docker volume to mount into the service container, as :[:], repeatable
  • --volume-target <stringArray>: mount one of the definition's volumes at another container path, as =, repeatable
  • --wait-timeout <string>: seconds to wait for the service to become ready (default: the datastore's own)

You can upgrade an existing service to a new image or image-version:

dokku clickhouse:upgrade lollipop

This is the only command that changes the version a service runs. With no version named it moves to the newest the service's own major version ships, which leaves the data where it is.

dokku clickhouse:upgrade lollipop --image-version 1.2.3

Moving across a major version has to be asked for by name, because it is not a tag change: the data is mounted somewhere different under the new one, and pointing the version back does not undo it. A service keeps the mounts it has unless --volume is passed, which replaces them, and each one is checked against the new container before the old one is taken away.

dokku clickhouse:upgrade lollipop --volume /var/lib/dokku/data/storage/lollipop:/opt/extra:ro

A service keeps the volume targets it has unless --volume-target is passed, which replaces them, and an upgrade onto a definition that does not mount a volume the service moved is refused before the old container is taken away. --volume-target "" puts every volume back where the new definition mounts it.

dokku clickhouse:upgrade lollipop --volume-target ""

A service keeps its memory limit unless --memory is passed, and --memory 0 removes it.

dokku clickhouse:upgrade lollipop --memory 512

Service Automation

Service scripting can be executed using the following commands:

list all Clickhouse service links for a given app

# usage
dokku clickhouse:app-links [<app>]

List all clickhouse services that are linked to the playground app.

dokku clickhouse:app-links playground

create container then copy data from into

# usage
dokku clickhouse:clone <service> <new-service> [--clone-flags...]

flags:

  • -c|--config-options <string>: extra arguments for the process the service container runs, not docker flags; use mount for mounts
  • -C|--custom-env <string>: semi-colon delimited environment variables to start the service with
  • -i|--image <string>: the image name to start the service with (default: the source's)
  • -I|--image-version <string>: the image version to start the service with (default: the source's)
  • -N|--initial-network <string>: the initial network to attach the service to
  • --label <stringArray>: a docker label to put on the service container, as =, repeatable; replaces every label the source has
  • --log-driver <string>: the docker logging driver to run the service container with (default: the daemon's own)
  • --log-opt <strings>: a comma-separated list of key=value docker log options for the service container
  • -m|--memory <int>: container memory limit in megabytes (default: unlimited)
  • -p|--password <string>: override the user-level service password, for datastores that have one
  • -P|--post-create-network <strings>: a comma-separated list of networks to attach the service container to after service creation
  • -S|--post-start-network <strings>: a comma-separated list of networks to attach the service container to after service start
  • --restart <string>: the docker restart policy to run the service container with (default: always)
  • -r|--root-password <string>: override the root-level service password, for datastores that have one
  • --service-memory <string>: memory in megabytes the datastore itself is told to use, such as a cache size or a heap (default: the source's)
  • -s|--shm-size <string>: override shared memory size for the service docker container
  • --volume <stringArray>: a host path or docker volume to mount into the service container, as :[:], repeatable
  • --volume-target <stringArray>: mount one of the definition's volumes at another container path, as =, repeatable
  • --wait-timeout <string>: seconds to wait for the service to become ready (default: the datastore's own)

You can clone an existing service to a new one:

dokku clickhouse:clone lollipop lollipop-2

The new service starts from the settings of the one it copies: its config options, custom env, memory, service memory, shm size, networks, log driver, log options, restart policy, labels, mounts, volume targets, backup keyserver, backup storage class and backup timestamp. A flag passed to clone overrides that one setting, and a flag passed empty clears it:

dokku clickhouse:clone lollipop lollipop-2 --restart no --custom-env ""

The new service runs the image and image version of the one it copies unless --image or --image-version say otherwise. These cannot be cleared, and an --image other than the one the definition ships needs an --image-version as well. An image that would run on another definition than the source's, such as another major version, is refused; upgrade the source onto it first:

dokku clickhouse:clone lollipop lollipop-2 --image-version <version>

The password, exposed ports, links and backup credentials, schedule, encryption and object name are not copied. The clone's passwords are generated unless they are given.

dokku clickhouse:clone lollipop lollipop-2 --password <password>

check if the Clickhouse service exists

# usage
dokku clickhouse:exists <service>

Here we check if the lollipop clickhouse service exists.

dokku clickhouse:exists lollipop

check if the Clickhouse service is linked to an app

# usage
dokku clickhouse:linked <service> [<app>]

Here we check if the lollipop clickhouse service is linked to the playground app.

dokku clickhouse:linked lollipop playground

list all apps linked to the Clickhouse service

# usage
dokku clickhouse:links <service>

List all apps linked to the lollipop clickhouse service.

dokku clickhouse:links lollipop

Renaming an app moves its link onto the new name, and cloning an app links the clone as well as the original.

Data Management

The underlying service data can be imported and exported with the following commands:

import a dump into the Clickhouse service database

# usage
dokku clickhouse:import <service> [-f|--file <path>] [--all-databases] [--database <database>]

flags:

  • --all-databases: load a dump of every database in the service, as written by export --all-databases or backup --all-databases
  • --database <string>: the database in the service to import into, in place of the one named for the service
  • -f|--file <string>: a file on the dokku host to import instead of reading stdin

Import a datastore dump:

dokku clickhouse:import lollipop < data.dump

A dump that is already on the dokku host can be imported with --file. The path is on the dokku host, not on the machine running ssh.

dokku clickhouse:import lollipop --file /var/lib/dokku/data/storage/data.dump

A dump of every database, as written by export --all-databases or backup --all-databases, is imported with --all-databases. Each database in the dump is replaced under the name it was exported from, and any other database is left alone.

dokku clickhouse:import lollipop --all-databases < all.dump

A dump is imported into a database made with create-database with --database in place of the one named for the service:

dokku clickhouse:import lollipop --database paintshop < paintshop.dump

export a dump of the Clickhouse service database

# usage
dokku clickhouse:export <service> [-f|--file <path>] [--force] [--all-databases] [--database <database>]

flags:

  • --all-databases: export every database in the service rather than only the one named for it
  • --database <string>: the database in the service to export, in place of the one named for the service
  • -f|--file <string>: a file on the dokku host to export to instead of writing stdout
  • --force: replace the file named with --file if it already exists

By default, datastore output is exported to stdout:

dokku clickhouse:export lollipop

You can redirect this output to a file:

dokku clickhouse:export lollipop > data.dump

A dump can be written to a file on the dokku host with --file. The path is on the dokku host, not on the machine running ssh.

dokku clickhouse:export lollipop --file /var/lib/dokku/data/storage/data.dump

A file that already exists is not overwritten unless --force is given:

dokku clickhouse:export lollipop --file /var/lib/dokku/data/storage/data.dump --force

Only the database named for the service is exported unless --all-databases is given, which exports every database in the service, leaving out the ones the server keeps for itself. It is imported again with import --all-databases, into the databases it was exported from.

dokku clickhouse:export lollipop --all-databases > all.dump

A database made with create-database is exported with --database in place of the one named for the service:

dokku clickhouse:export lollipop --database paintshop > paintshop.dump

delete all data in the Clickhouse service, keeping the service and its links

# usage
dokku clickhouse:reset <service> [-f|--force] [--database <database>]

flags:

  • --database <string>: the database in the service to reset, in place of the one named for the service
  • -f|--force: reset the service without asking for its name first

Delete all data in the service, leaving it as empty as a newly created one. The service, its credentials, and the apps it is linked to are kept, so linked apps do not need to be relinked. Connections the apps hold open may be closed.

dokku clickhouse:reset lollipop

The service name is asked for before anything is deleted, unless --force is given:

dokku clickhouse:reset lollipop --force

Only the database named for the service is reset unless another is named with --database, which resets a database made with create-database and leaves every other alone:

dokku clickhouse:reset lollipop --database paintshop

Databases and Users

A service runs in a container of its own. Several apps can share one service, and the memory its container uses, by each being linked to a database or user of its own within it, made with the following commands. Every user made in a service can use every database in it.

create a database in the Clickhouse service

# usage
dokku clickhouse:create-database <service> <database>

Create a database named paintshop in the running lollipop service, beside the one it was created with:

dokku clickhouse:create-database lollipop paintshop

Every user the service holds is given access to it. A database name may only contain lowercase letters, digits and _, start with a letter or _, and be at most 32 characters long. Link an app to it with the --database flag:

dokku clickhouse:link lollipop playground --database paintshop

destroy a database created in the Clickhouse service

# usage
dokku clickhouse:destroy-database <service> <database> [-f|--force]

flags:

  • -f|--force: destroy it without asking for confirmation

Destroy the paintshop database made in the running lollipop service, along with all of its data:

dokku clickhouse:destroy-database lollipop paintshop

The database name is asked for before anything is deleted, unless --force is given. A database an app is still linked to is refused, and the one the service was created with is only removed with the service.

dokku clickhouse:destroy-database lollipop paintshop --force

create a user in the Clickhouse service

# usage
dokku clickhouse:create-user <service> <user> [<password>]

Create a user named painter in the running lollipop service, with a generated password:

dokku clickhouse:create-user lollipop painter

The user is given access to every database the service holds, and to every database made in it later. A password of your own may be given instead. It may only contain letters, digits, ., _, ~ and -.

dokku clickhouse:create-user lollipop painter SOME_PASSWORD

A user name may only contain lowercase letters, digits and _, start with a letter or _, and be at most 32 characters long. Link an app as the user with the --user flag, which hands it the password in its url:

dokku clickhouse:link lollipop playground --user painter

destroy a user created in the Clickhouse service

# usage
dokku clickhouse:destroy-user <service> <user> [-f|--force]

flags:

  • -f|--force: destroy it without asking for confirmation

Destroy the painter user made in the running lollipop service:

dokku clickhouse:destroy-user lollipop painter

The user name is asked for before it is destroyed, unless --force is given. A user an app is still linked as is refused, and the one the service was created with is only removed with the service.

dokku clickhouse:destroy-user lollipop painter --force

change the password of a user created in the Clickhouse service

# usage
dokku clickhouse:set-user-password <service> <user> [<password>] [-n|--no-restart]

flags:

  • -n|--no-restart: whether to skip restarting the apps linked as the user

Give the painter user made in the running lollipop service a generated password:

dokku clickhouse:set-user-password lollipop painter

Or a password of your own:

dokku clickhouse:set-user-password lollipop painter SOME_PASSWORD

Every app linked as the user is given the new url and restarted, unless --no-restart is given, and the apps linked as any other user are left alone.

dokku clickhouse:set-user-password lollipop painter --no-restart

The password of the user the service was created with is changed with set instead:

dokku clickhouse:set lollipop password SOME_PASSWORD

Backups

Datastore backups are supported via AWS S3 and S3 compatible services like minio and DigitalOcean Spaces.

The endpoint of an S3 compatible service is passed as the endpoint-url argument of backup-auth, such as https://nyc3.digitaloceanspaces.com, and must not include the bucket. The bucket is passed to backup and backup-schedule by its name alone, such as my-s3-bucket rather than s3://my-s3-bucket, and must follow the S3 bucket naming rules.

You may skip the backup-auth step if your dokku install is running within EC2 and has access to the bucket via an IAM profile. In that case, use the --use-iam option with the backup command.

If both passphrase and public key forms of encryption are set, the public key encryption will take precedence.

Each setting backup-auth, backup-set-encryption and backup-set-public-key-encryption store can also be changed on its own with the set command, as can the bucket and IAM setting of the schedule made without --id, when that is the only schedule. The keys are listed under Service properties.

Backups are uploaded with the bucket's default storage class unless the service sets the backup-storage-class property with the set command. A schedule may set its own value with set <key> <value> --id <id>.

Backups are uploaded to <prefix>-<service>-<timestamp>.tgz. The service may name the key with the backup-object-name property and drop the timestamp by setting the backup-timestamp property to false, so that every backup is uploaded to the same key and bucket versioning and lifecycle rules can keep and rotate them. The bucket name may end in a path to upload under, such as my-s3-bucket/backups. A schedule may set either for itself.

The underlying core backup script is present here.

A service has one scheduled backup, made with backup-schedule and replaced by calling it again. Further schedules are added with --id <name>, each with its own cron expression and bucket, so a service can ship a frequent backup and a monthly backup to different buckets. backup-schedule-cat lists every schedule. backup-unschedule removes the only schedule; with several it removes the one named by --id, or every schedule with --all.

backup-auth and backup-deauth take the same --id. A schedule is created first, then given its own access key and secret. A schedule with both uses that pair. A schedule with neither uses the service's credentials, unless the backup is run with --use-iam. A region, signature version or endpoint set on the schedule is used for that schedule, and one left unset is the service's.

Scheduled backups are added to the dokku crontab, and are listed by dokku cron:list --global. Each service's scheduled backups append their output to a log of its own, /var/log/dokku/<prefix>.<service>.backup.log, which the backup-logs command shows. The output of a service's scheduled backups can be mailed to specific recipients by setting the backup-mailto property with the set command, on dokku versions that support a per-entry MAILTO. The service value applies to every schedule that has not set its own.

Backups can be performed using the backup commands:

set up authentication for backups on the Clickhouse service

# usage
dokku clickhouse:backup-auth <service> <aws-access-key-id> <aws-secret-access-key> <aws-default-region> <aws-signature-version> <endpoint-url> [--id <id>]

flags:

  • --id <string>: record the credentials on this backup schedule

Setup s3 backup authentication:

NOTE: each call replaces the stored credentials as a whole, so a region, signature version or endpoint url that is not passed is removed

dokku clickhouse:backup-auth lollipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY

Setup s3 backup authentication with different region:

dokku clickhouse:backup-auth lollipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION

Setup s3 backup authentication with different signature version and endpoint:

dokku clickhouse:backup-auth lollipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_SIGNATURE_VERSION ENDPOINT_URL

More specific example for minio auth:

dokku clickhouse:backup-auth lollipop MINIO_ACCESS_KEY_ID MINIO_SECRET_ACCESS_KEY us-east-1 s3v4 https://YOURMINIOSERVICE

More specific example for digitalocean spaces auth, where the endpoint does not include the space name:

dokku clickhouse:backup-auth lollipop SPACES_ACCESS_KEY SPACES_SECRET_KEY nyc3 s3v4 https://nyc3.digitaloceanspaces.com

Record credentials on one schedule. The schedule is created first with backup-schedule --id. A region, signature version or endpoint url that is not passed is cleared on that schedule, so it inherits the service's value:

dokku clickhouse:backup-auth lollipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY us-east-1 --id monthly

remove backup authentication for the Clickhouse service

# usage
dokku clickhouse:backup-deauth <service> [--id <id>]

flags:

  • --id <string>: clear the credentials recorded on this backup schedule

Remove s3 authentication:

dokku clickhouse:backup-deauth lollipop

Remove the credentials recorded on one schedule. The service's credentials stay, and that schedule uses them again:

dokku clickhouse:backup-deauth lollipop --id monthly

create a backup of the Clickhouse service to an existing s3 bucket

# usage
dokku clickhouse:backup <service> <bucket-name> [--id <id>] [-u|--use-iam] [--all-databases]

flags:

  • --all-databases: back up every database in the service rather than only the one named for it, in place of the backup-all-databases property
  • --id <string>: run with the settings of this schedule
  • -u|--use-iam: use the IAM profile associated with the current server

Backup the lollipop service to the my-s3-bucket bucket on AWS:

once a backup ends, scheduled or not, the service-action plugin trigger is fired with "post-backup clickhouse <success|failure>", and a trigger that fails is only warned about

dokku clickhouse:backup lollipop my-s3-bucket --use-iam

Backup with the settings recorded on one schedule. The bucket and --use-iam still come from this command:

dokku clickhouse:backup lollipop my-s3-bucket --id monthly

Backup the lollipop service under a path in the bucket:

dokku clickhouse:backup lollipop my-s3-bucket/clickhouse-backups

A backup holds the database named for the service, in the format export writes, and is restored without --all-databases (assuming it was extracted via tar -xf backup.tgz):

dokku clickhouse:import lollipop < backup-folder/export

Backup every database in the service rather than only the one named for it. The backup-all-databases property does the same for every backup, scheduled ones included, and --all-databases=false overrides it:

dokku clickhouse:backup lollipop my-s3-bucket --all-databases

A backup of every database, including one made by a version of the plugin that always backed up every database, is restored with --all-databases:

dokku clickhouse:import lollipop --all-databases < backup-folder/export

set encryption for all future backups of Clickhouse service

# usage
dokku clickhouse:backup-set-encryption <service> <passphrase> [--id <id>]

flags:

  • --id <string>: record the passphrase on this backup schedule

Set the GPG-compatible passphrase for encrypting backups for backups:

dokku clickhouse:backup-set-encryption lollipop

Public key encryption will take precendence over the passphrase encryption if both types are set. Record the passphrase on one schedule. It replaces the service's passphrase and public key for that schedule:

dokku clickhouse:backup-set-encryption lollipop --id monthly

set GPG Public Key encryption for all future backups of Clickhouse service

# usage
dokku clickhouse:backup-set-public-key-encryption <service> <public-key-id> [--id <id>]

flags:

  • --id <string>: record the public key on this backup schedule

Set the GPG Public Key for encrypting backups:

dokku clickhouse:backup-set-public-key-encryption lollipop

The is fetched from keyserver.ubuntu.com, unless the service names another one with the backup-keyserver property:

dokku clickhouse:set lollipop backup-keyserver hkp://keys.example.com

Record the public key on one schedule:

dokku clickhouse:backup-set-public-key-encryption lollipop --id monthly

unset encryption for future backups of the Clickhouse service

# usage
dokku clickhouse:backup-unset-encryption <service> [--id <id>]

flags:

  • --id <string>: clear the passphrase recorded on this backup schedule

Unset the GPG encryption passphrase for backups:

dokku clickhouse:backup-unset-encryption lollipop

Clear the passphrase recorded on one schedule, so that schedule inherits the service's encryption again:

dokku clickhouse:backup-unset-encryption lollipop --id monthly

unset GPG Public Key encryption for future backups of the Clickhouse service

# usage
dokku clickhouse:backup-unset-public-key-encryption <service> [--id <id>]

flags:

  • --id <string>: clear the public key recorded on this backup schedule

Unset the GPG Public Key encryption for backups:

dokku clickhouse:backup-unset-public-key-encryption lollipop

Clear the public key recorded on one schedule:

dokku clickhouse:backup-unset-public-key-encryption lollipop --id monthly

schedule a backup of the Clickhouse service

# usage
dokku clickhouse:backup-schedule <service> <schedule> <bucket-name> [--id <id>] [-u|--use-iam]

flags:

  • --id <string>: the schedule to record, in place of the default schedule
  • -u|--use-iam: use the IAM profile associated with the current server

Schedule a backup:

'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am, or a descriptor such as "@daily". A schedule cron cannot run is refused. the backup is added to the dokku crontab through the cron-entries plugin trigger, so it is listed by "dokku cron:list --global" and its output is appended to /var/log/dokku/clickhouse..backup.log, which "dokku clickhouse:backup-logs " prints each scheduled backup fires the same service-action post-backup trigger as "dokku clickhouse:backup", so a plugin can report whether it succeeded NOTE: dokku only writes a crontab when the global scheduler or at least one app uses the docker-local scheduler, so a scheduled backup does not run on a host that only uses k3s or null calling it again without --id replaces that schedule's cron expression, bucket and instance role, and leaves every other schedule in place --id names another schedule, or replaces the one that id already names. --id default is the schedule made without --id

dokku clickhouse:backup-schedule lollipop "0 3 * * *" my-s3-bucket

Schedule a backup and authenticate via iam:

dokku clickhouse:backup-schedule lollipop "0 3 * * *" my-s3-bucket --use-iam

Schedule a second backup under its own id:

dokku clickhouse:backup-schedule lollipop "0 3 1 * *" my-s3-bucket --id monthly

cat the crontab line of a scheduled backup for the service

# usage
dokku clickhouse:backup-schedule-cat <service> [--id <id>]

flags:

  • --id <string>: the schedule to print

Cat the crontab line of the scheduled backup for the service. With more than one schedule, each line is preceded by its id:

dokku clickhouse:backup-schedule-cat lollipop

Cat one schedule:

dokku clickhouse:backup-schedule-cat lollipop --id monthly

unschedule the backup of the Clickhouse service

# usage
dokku clickhouse:backup-unschedule <service> [--id <id>|--all]

flags:

  • --all: remove every scheduled backup
  • --id <string>: the schedule to remove

Remove the scheduled backup from the dokku crontab. With one schedule, that schedule is removed. With several, name one with --id, or pass --all:

dokku clickhouse:backup-unschedule lollipop

Remove one schedule:

dokku clickhouse:backup-unschedule lollipop --id monthly

Remove every schedule:

dokku clickhouse:backup-unschedule lollipop --all

print the most recent output of the scheduled backups of the service

# usage
dokku clickhouse:backup-logs <service> [-t|--tail [<tail-num>]]

flags:

  • -t|--tail <int>: follow the log, optionally showing this many lines

Print the most recent output of the scheduled backups of the service:

each service's scheduled backups append their output to /var/log/dokku/clickhouse..backup.log, or to the same file under DOKKU_LOGS_DIR when dokku keeps its logs elsewhere. Every run starts and ends with a line marked with the time in utc.

dokku clickhouse:backup-logs lollipop

By default, the log will not be tailed, but you can do this with the --tail flag:

dokku clickhouse:backup-logs lollipop --tail

By default the last 100 lines are shown, but a different count can be specified:

dokku clickhouse:backup-logs lollipop --tail=5

Service properties

Every setting a service has after it is created, other than its image, its mounts, its labels and its backup schedule, each of which has a command of its own, is changed with dokku clickhouse:set lollipop <key> <value>, and cleared by giving no value. dokku clickhouse:info lollipop reports each of them, with a credential reported as a fingerprint rather than its value. A setting the container is made with only reaches it once the container is built again, and set warns when that is the case: dokku clickhouse:restart keeps the container the service has, so use dokku clickhouse:stop and then dokku clickhouse:start. Passing --allow-restart to set does that, or the reexpose an expose setting takes, whenever the value changed, and leaves the service alone when it did not.

Property Description Takes effect
initial-network the network the service container is attached to when it is made after clickhouse:stop and clickhouse:start
post-create-network a comma-separated list of networks the container is attached to once it is made after clickhouse:stop and clickhouse:start
post-start-network a comma-separated list of networks the container is attached to once it is started after clickhouse:stop and clickhouse:start
backup-keyserver the keyserver a public key for backup encryption is fetched from immediately
backup-storage-class the s3 storage class backups are uploaded with immediately
backup-object-name the name backups are uploaded under immediately
backup-timestamp false to upload every backup to the same key, without a timestamp immediately
backup-all-databases true to back up every database in the service rather than only the one named for it immediately
backup-mailto who cron mails the output of scheduled backups to immediately
backup-access-key-id the access key id backups authenticate with immediately
backup-secret-access-key the secret access key backups authenticate with immediately
backup-default-region the region backups authenticate against immediately
backup-signature-version the signature version backups authenticate with immediately
backup-endpoint-url the endpoint of an s3 compatible service backups are shipped to immediately
backup-encryption-passphrase the passphrase backups are encrypted with immediately
backup-public-key-id the gpg public key id backups are encrypted with immediately
backup-bucket the bucket the scheduled backup is shipped to immediately
backup-use-iam true to have the scheduled backup authenticate with an instance role immediately
log-driver the docker logging driver the container is run with after clickhouse:stop and clickhouse:start
log-opt a comma-separated list of docker log options the container is run with after clickhouse:stop and clickhouse:start
restart-policy the docker restart policy the container is run with after clickhouse:stop and clickhouse:start
wait-timeout the seconds the service is waited on to become ready immediately
port-bind-address the address exposed ports without one of their own are published on after clickhouse:reexpose
port-source-range the only IP address or CIDR the exposed ports accept clients from after clickhouse:reexpose
expose-host the host the exposed dsn names immediately
expose-mode direct to publish the exposed ports on the service container rather than through an ambassador after clickhouse:reexpose
volume-targets the container paths the definition's volumes are mounted at in place of its own after clickhouse:stop and clickhouse:start
config-options extra arguments for the process the service container runs after clickhouse:stop and clickhouse:start
custom-env semicolon-delimited environment variables the container is run with after clickhouse:stop and clickhouse:start
memory the container memory limit in megabytes, 0 for no limit after clickhouse:stop and clickhouse:start
shm-size the shared memory size of the container, such as 64m after clickhouse:stop and clickhouse:start
password the password the service and its linked apps use, changed in the datastore and in the url every linked app holds once set restarts the service, with --allow-restart

The password key is changed in the datastore as well as on disk, and every linked app is given the new url and restarted, unless --no-restart is passed. The datastore only reads the password as it starts, so changing it stops and starts the service, and set refuses to unless it is given --allow-restart. A password cannot be cleared, may only hold letters, digits, ., _, ~ and -, and is never printed back: info reports a fingerprint of it.

Limiting where and to whom a service is exposed

An exposed service's ports are published on every interface unless they are given an address of their own. To publish them on one address instead, set the service's port-bind-address property with dokku clickhouse:set, and to accept connections only from clients in one IP address or CIDR, set its port-source-range property. Either reaches a running service with dokku clickhouse:reexpose, which leaves the service running when its ports are published through an ambassador.

Only one source range can be given. The range is checked against the address a connection reaches the service from, which for a connection to the exposed port on the loopback interface, or an IPv6 connection to a service network without IPv6, is the docker network's gateway rather than the client, so with a range that leaves the gateway out, connecting to 127.0.0.1 from the dokku host itself is refused.

Exposing a service without an ambassador

An exposed service's ports are published by an ambassador, a container that relays every connection on to the service. The ambassador can be replaced without touching the service and can hold clients to a port-source-range, but relaying adds latency to every request.

To publish the ports on the service container itself instead, set the service's expose-mode property to direct with dokku clickhouse:set. Docker has no way of changing the ports a container publishes, so the container is made again whenever what it publishes changes: when the service is exposed or unexposed, when its port-bind-address changes, and when it moves between expose modes. For a running service, dokku clickhouse:expose, dokku clickhouse:unexpose and dokku clickhouse:reexpose ask before stopping and starting it, and change nothing if the answer is no. Pass --force to stop and start it without being asked. A change also reaches the service the next time it is restarted, or stopped and started.

A port-source-range cannot be enforced on a port the service container publishes itself, so it cannot be set on a service exposed directly, and a service with one cannot be exposed directly.

Choosing the ambassador image

The ambassador is made from dokku/ambassador:0.8.4 unless another image is named. Pass --ambassador-image to expose, reexpose, start, restart, upgrade or set to name one for that command, set the PLUGIN_AMBASSADOR_IMAGE environment variable, or set the ambassador-image global property with dokku clickhouse:set --global ambassador-image dokku/ambassador:0.8.4. The flag is used first, then the environment variable, then the global property. The environment variable only reaches the plugin where sudo keeps the caller's environment, which it does not on newer versions of ubuntu.

The image has to name a tag or a digest. A different image reaches an exposed service on its next start, restart, upgrade or dokku clickhouse:reexpose, which replace an ambassador made from another image. dokku/ambassador:0.8.4 or newer is needed for a udp port.

Connecting to an exposed service from outside the host

dokku clickhouse:info lollipop --exposed-dsn prints the dsn a client off the dokku host connects with. It is the dsn a linked app is handed, with the exposed ports in place of the container's and a public host in place of the service container's name, so it carries the same credentials. The host is the service's expose-host property, set with dokku clickhouse:set, or the first global domain when it has none. The port-bind-address, or an address given with a port, is never used as the host, since it is where the port is bound rather than where a client elsewhere reaches it. The dsn is empty until the service is exposed and there is a host to name.

Waiting for a service to become ready

A service is waited on until it answers on its port after it is created, cloned, started, restarted, upgraded or exposed. If it takes longer than that to start - on a slow host, or with an image that does more on its first boot - the command fails with ERROR: unable to connect.

To wait longer for every clickhouse service on the host, set the wait-timeout global property to a number of seconds with dokku clickhouse:set --global wait-timeout 120. To wait longer for a single service, set its wait-timeout property with dokku clickhouse:set or pass --wait-timeout to create, clone or upgrade. The service's own setting is used first, then the global property, then the datastore's default.

Moving where a service's volumes are mounted

Each volume a service mounts is named by the directory it lives in under the service's own directory, and is mounted where the datastore's definition says. To mount one somewhere else in the container, for an image that keeps its data at another path, set the service's volume-targets property with dokku clickhouse:set, or pass --volume-target to create, clone or upgrade. Each is written as <volume>=<container-path>, several separated by spaces, and dokku clickhouse:info lollipop --volume-targets shows the ones a service moved.

Definition Volume Mounted at
clickhouse config /etc/clickhouse-server
clickhouse data /var/lib/clickhouse

Moving a volume changes where it is mounted, not where the image reads and writes. The datastore's own commands and the paths it is started with follow the volume, but an image that keeps writing to its own path writes into the container rather than into the volume, and what it writes is lost when the container is rebuilt, so only move a volume to where the image expects its data. The data stays in the same directory on the host, and a move reaches the container the next time one is built, so use dokku clickhouse:stop and then dokku clickhouse:start on a running service. An upgrade onto a definition that does not mount a volume the service moved is refused until the move is cleared or replaced.

Reserved service names

A service's database is named after the service, with hyphens replaced by underscores. So that an app is never handed a database Clickhouse keeps for itself, dokku clickhouse:create and dokku clickhouse:clone refuse a name that is, or whose database would be, one of information_schema, system, in any case. A service that already has such a name is not affected.

Disabling docker image pull calls

If you wish to disable the docker image pull calls that the plugin triggers, you may set the disable-pull global property to true with dokku clickhouse:set --global disable-pull true. Once disabled, you will need to pull the service image you wish to deploy as shown in the stderr output.

Please ensure the proper images are in place when docker image pull is disabled.

About

a clickhouse plugin for dokku

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

27 stars

Watchers

3 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages