Installing Mercury DB (HgDB) on Kubernetes (Helm chart)
The page describes how to build a Kubernetes cluster (kubeadm), how to give it shared storage on NFS, and how to install Mercury DB (HgDB) 3.0 in it with one of the Helm charts from the repository mercury-docker: mercury-single-node (one node) or mercury-three-node-cluster (a cluster of three nodes). Names and addresses (k8s-master, 192.168.10.x, nexus.example.local) are examples; replace them with your own.
The charts are a new way of delivering the system and they start on PostgreSQL 17, so there is no data to migrate (see Upgrading PostgreSQL 14 to 17 for the installations on Docker).
The procedure was verified on clusters with Kubernetes 1.30, containerd, Flannel and an NFS server on the master (Ubuntu): the chart mercury-single-node on the master and two workers, the chart mercury-three-node-cluster on the master and four workers (three of them with 8 GB of RAM, one with 16 GB). The chart mercury-single-node installs one node of Mercury DB with PostgreSQL, Apache ActiveMQ, Ehcache Terracotta, OpenLDAP, the Excel server (POI) and the Nginx load balancer. The chart mercury-three-node-cluster installs three such nodes (see step 6).
| Step | What |
|---|---|
| 1 | Kubernetes cluster (kubeadm) and Helm |
| 2 | Shared storage: the NFS server and the clients |
| 3 | Persistent volumes on NFS |
| 4 | A non-default registry of images (example) |
| 5 | Namespace and installation of HgDB |
| 6 | A cluster of three nodes (chart mercury-three-node-cluster) |
1. Kubernetes cluster
Requirements
mercury-single-node (one node) | mercury-three-node-cluster (three nodes) | |
|---|---|---|
| Master | 4 GB of RAM | 4 GB of RAM |
| Workers | 2 workers, 8 GB of RAM each | at least 4 workers, 8 GB of RAM each |
| Disk of a worker | 64 GB | 64 GB |
| Disk of the master | the system disk and an additional disk of at least 256 GB for the NFS share (step 2) | the same |
- The workers do not need more than 64 GB of disk (128 GB is not necessary): the data lives on NFS, and a worker keeps only the system and the images of the containers.
- The size of the workers is decisive. The chart sets memory requests and limits for every container (the Excel server (POI) up to 5 GiB, a node of Mercury DB up to 6 GiB), and with smaller workers the Excel (POI) server has problems.
- The cluster of three nodes asks for about 24 GiB of memory (requests): three nodes of Mercury DB, three Terracotta servers and three Excel servers, plus PostgreSQL, ActiveMQ and OpenLDAP. Both charts together do not fit in a cluster of this size, so install one of them at a time (scale the other one down to zero or remove it).
Example machines
| Name | IP | vCPU | RAM | Disk |
|---|---|---|---|---|
k8s-master | 192.168.10.10 | 4 | 4 GB | 64 GB, and 256 GB for the NFS share |
k8s-worker1 | 192.168.10.11 | 4 | 8 GB | 64 GB |
k8s-worker2 | 192.168.10.12 | 4 | 8 GB | 64 GB |
k8s-worker3 | 192.168.10.13 | 4 | 8 GB | 64 GB |
k8s-worker4 | 192.168.10.14 | 4 | 8 GB | 64 GB |
The chart mercury-single-node needs the master and the first two workers. The chart mercury-three-node-cluster needs all four workers.
If the machines have more than one network interface (for example a second card in a separate network), decide which network the cluster and the storage use. Give the address of that network to kubeadm init (--apiserver-advertise-address) and use an address from the same network as the NFS server in the chart (see step 2). A volume mounted through another interface is refused by the NFS server (access denied by server).
Preparation of every node
-
Switch off the swap (Kubernetes requires it):
sudo swapoff -a
sudo sed -i '/\/swap\.img/s/^/#/' /etc/fstab -
Load the kernel modules of the container network:
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter -
Enable the IP routing (
sysctl):cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sudo sysctl --system -
Install containerd with
SystemdCgroup:sudo apt-get update
sudo apt-get install -y curl gnupg software-properties-common apt-transport-https ca-certificates containerd
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd -
Install
kubeadm,kubeletandkubectl(here version 1.30):sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
The master (k8s-master)
-
Initialize the cluster (the address is the address of the master in the network of the cluster):
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.10.10At the end the command prints
kubeadm join .... Copy it; the workers need it. -
Allow your user to manage the cluster:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config -
Install the network of the cluster (Flannel):
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
The workers
On every worker (k8s-worker1 and k8s-worker2, and for the cluster of three nodes also k8s-worker3 and k8s-worker4) run the copied command with sudo:
sudo kubeadm join 192.168.10.10:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>
If a node cannot join (for example the token has expired), generate a new token on the master and print the whole command again. Creating a token does not disturb the nodes that have already joined:
kubeadm token create --print-join-command
On the master check the nodes. After a minute all of them should be Ready:
kubectl get nodes
Helm
The chart needs Helm 3 on the machine from which you install (here the master). Download the binary of a chosen release and check its checksum:
V=v3.16.4
curl -fsSLO https://get.helm.sh/helm-$V-linux-amd64.tar.gz
curl -fsSL https://get.helm.sh/helm-$V-linux-amd64.tar.gz.sha256sum | sha256sum -c -
tar xzf helm-$V-linux-amd64.tar.gz
mkdir -p $HOME/bin && install -m 755 linux-amd64/helm $HOME/bin/helm
$HOME/bin/helm version --short
Add $HOME/bin to the PATH (for example in ~/.bashrc) or use the full path.
2. NFS server and clients
The chart keeps all the data (the database, the Lucene indexes, the files of the system) on NFS volumes. The simplest place for the server is the master (or any machine reachable from all the nodes).
-
Install the server on the machine that shares the files:
sudo apt-get update
sudo apt-get install -y nfs-kernel-server -
Create the shared directory:
sudo mkdir -p /srv/nfs/kubedata
sudo chown -R nobody:nogroup /srv/nfs/kubedata
sudo chmod 777 /srv/nfs/kubedata -
Export it to the network of the cluster. Add the line to
/etc/exports(the subnet must contain the addresses from which the nodes connect):/srv/nfs/kubedata 192.168.10.0/24(rw,sync,no_subtree_check,no_root_squash)sudo exportfs -ra
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
showmount -e localhostno_root_squashThe option
no_root_squashis needed: the containers (PostgreSQL, OpenLDAP) write asrootand change the owner of their files. Without it the database does not start. -
Install the NFS client on every worker (and on every node on which the pods can run):
sudo apt-get update
sudo apt-get install -y nfs-common -
Check the access from the cluster with a one-off pod. It mounts the share, writes a file and ends with
NFS-OK. Put the address of the NFS server inserver:nfs-test.yamlapiVersion: v1
kind: Pod
metadata:
name: nfs-test
spec:
restartPolicy: Never
containers:
- name: t
image: busybox:1.36
command: ["sh","-c","touch /data/nfs-test-ok && ls -la /data && echo NFS-OK"]
volumeMounts: [{name: d, mountPath: /data}]
volumes:
- name: d
nfs: {server: 192.168.10.10, path: /srv/nfs/kubedata}kubectl apply -f nfs-test.yaml
kubectl logs nfs-test
kubectl delete pod nfs-test
rm /srv/nfs/kubedata/nfs-test-okThe error
mount.nfs: access denied by servermeans that the address of the node is outside the subnet from/etc/exports.
3. Persistent volumes on NFS
The chart creates the persistent volumes (PV) and their claims (PVC) itself, from the section nfsVolumes of values.yaml. You only have to create the directories on the NFS server and give the chart the address of the server and the paths.
Create the directories (on the NFS server):
cd /srv/nfs/kubedata
mkdir -p postgres-db openldap slapd.d certificate_center nginx/conf nginx/html poi-server mercury-upload mercury-lucene
chmod -R 777 postgres-db openldap slapd.d certificate_center nginx poi-server mercury-upload mercury-lucene
Value in nfsVolumes | Directory in the example | Contents |
|---|---|---|
postgresDb.path | postgres-db | the data of PostgreSQL |
openldap.ldap.path, openldap.slapd.path | openldap, slapd.d | the data and the configuration of OpenLDAP |
certificateCenter.path | certificate_center | the certificates of the load balancer |
nginx.conf.path, nginx.html.path | nginx/conf, nginx/html | the configuration and the pages of Nginx |
poiServer.path | poi-server | the data of the Excel server |
mercury.upload.path, mercury.lucene.path | mercury-upload, mercury-lucene | the uploaded files and the Lucene index |
For every volume the chart generates a PV of this shape (the mount option nfsvers=4.2 is set by the chart):
apiVersion: v1
kind: PersistentVolume
metadata:
name: mercurysinglenode-postgres-db-vol1
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.10.10
path: "/srv/nfs/kubedata/postgres-db"
mountOptions:
- nfsvers=4.2
The size (storage) is only a declaration for the binding of the claim; NFS does not enforce it. The names of the PVs are fixed, so one release of the chart per cluster is possible.
4. A non-default registry of images
By default the chart pulls the images ibpm/mercury, ibpm/postgres, ibpm/activemq, ibpm/ehcache, ibpm/poi-server and ibpm/mercury-lb from Docker Hub (the secret docker-hub of the chart). The example below uses a private registry nexus.example.local:5000 that works over plain HTTP. Replace the address with your own; with a registry over HTTPS with a trusted certificate you only need the pull secret (point b).
a) Allow containerd on every node to use the registry over HTTP. The default config.toml has an empty config_path in the section of the CRI registry, so containerd ignores the directory certs.d. The script below sets it, adds the host file hosts.toml for the registry and restarts containerd. It can be run again without harm (it is idempotent), makes a copy of config.toml first, changes nothing outside of /etc/containerd and contains no credentials (the registry login is the job of the pull secret from point b).
Prepare the script containerd-nexus.sh on a node:
#!/bin/bash
# containerd configuration (a Kubernetes node): pulling images from the HTTP registry nexus.example.local:5000.
# Run ON EVERY NODE as root: sudo bash containerd-nexus.sh
# The script is idempotent. It copies config.toml, sets the config_path of the CRI registry to /etc/containerd/certs.d,
# creates hosts.toml for the registry (HTTP, pull/resolve) and restarts containerd.
# It changes nothing outside of /etc/containerd and has no credentials (imagePullSecret is used to log in to the registry).
set -eu
REGISTRY="${REGISTRY:-nexus.example.local:5000}"
CFG=/etc/containerd/config.toml
CERTS=/etc/containerd/certs.d
if [ "$(id -u)" -ne 0 ]; then
echo "Run as root: sudo bash $0"
exit 1
fi
[ -f "$CFG" ] || { echo "No $CFG"; exit 1; }
# 1. config_path in the section of the CRI registry (only if it is not set yet)
if grep -q "config_path = '$CERTS'" "$CFG"; then
echo "config_path is already set."
else
cp -a "$CFG" "$CFG.bak-$(date +%Y%m%d%H%M%S)"
sed -i "/\[plugins\.'io\.containerd\.cri\.v1\.images'\.registry\]/,/^\s*$/ s|config_path = ''|config_path = '$CERTS'|" "$CFG"
if ! grep -q "config_path = '$CERTS'" "$CFG"; then
echo "ERROR: config_path was not set (check the section [plugins.'io.containerd.cri.v1.images'.registry] in $CFG)."
exit 1
fi
echo "Set config_path = '$CERTS'."
fi
# 2. hosts.toml of the registry
mkdir -p "$CERTS/$REGISTRY"
cat > "$CERTS/$REGISTRY/hosts.toml" <<EOF
server = "http://$REGISTRY"
[host."http://$REGISTRY"]
capabilities = ["pull", "resolve"]
EOF
echo "Written $CERTS/$REGISTRY/hosts.toml"
# 3. restart of containerd (the containers keep running; their management stops for a moment)
systemctl restart containerd
sleep 3
systemctl is-active containerd
# 4. check
if crictl info 2>/dev/null | grep -q "$CERTS"; then
echo "OK: containerd reads $CERTS."
else
echo "WARNING: crictl info does not show $CERTS; check: crictl info | grep -i configPath"
fi
and run it (put your registry in REGISTRY if it differs from the example):
sudo REGISTRY=nexus.example.local:5000 bash containerd-nexus.sh
A node that has not been configured shows the pods in ImagePullBackOff and the event http: server gave HTTP response to HTTPS client. Run the script on that node (this happens for every new worker that joins the cluster later).
The sed pattern in the script fits containerd 2.x (the section io.containerd.cri.v1.images). On containerd 1.x the section is called [plugins."io.containerd.grpc.v1.cri".registry]; set the same config_path there. The name of the registry must resolve on every node (DNS or /etc/hosts).
b) Create the secret with the credentials of the registry in the namespace of the installation (see step 5). Do not store the password in files of a repository:
kubectl -n mercury create secret docker-registry registry-pull \
--docker-server=nexus.example.local:5000 \
--docker-username=<user> --docker-password=<password>
c) Point the chart at the registry in the values file (the section image):
image:
pullSecret: registry-pull
registry: nexus.example.local:5000/ibpm/ # with the ending slash
# mainTag: mercury-hgdb-3.0 # the tag of the auxiliary images
# hgdbTag: mercury-hgdb-3.0.4.45 # the tag of the server image
# activemqTag: mercury-hgdb-3.0-5.19.12 # the tag of the ActiveMQ image (the version of the broker)
# ehcacheTag: mercury-hgdb-3.0-3.10.8 # the tag of the Terracotta image (the version of the kit)
# openldap: nexus.example.local:5000/openldap:ubuntu-24.04 # a full name of the OpenLDAP image
The images must be in the registry under these names and tags (the server image has the tag of the server version, the ActiveMQ and Terracotta images the tags with the version of the product, the others mercury-hgdb-3.0). The OpenLDAP image is by default pulled from Docker Hub (scisoftware/openldap:ubuntu-24.04); set image.openldap if the cluster has no access to it.
From version 3.0.4.45 the server and the auxiliary images (ActiveMQ, Terracotta, POI Server) run on Java 17 (Eclipse Temurin). The server image carries its own JDK, so the workers need no Java. A Java 8 client of the web services does not need a change, but a program that uses the Java libraries of the server (mercury-lib) with the server version 3.0.4.45 or later is built with Java 8 or later (the libraries are compiled with release 8).
The Lucene index of an older version (Lucene 7) cannot be read by Lucene 9. After the upgrade the server builds the index again from the database when the index/Case directory is empty (the start script of the container runs mercury-cmd.sh gl Case). Move the old index directories aside before the first start. Backups of the index made with Lucene 7 cannot be restored.
5. Namespace and installation of HgDB
-
Get the chart (the directory
charts/mercury-single-nodeof the repositorymercury-docker) onto the machine withhelm:git clone https://github.com/SciSoftwareSlawomirCichy/mercury-docker.git
cd mercury-docker/charts -
Create the namespace and the pull secret (point b of step 4):
kubectl create namespace mercury
kubectl -n mercury create secret docker-registry registry-pull --docker-server=... --docker-username=... --docker-password=... -
Prepare the file of values
my-values.yaml; it overridesvalues.yamlof the chart, so the chart itself stays unchanged. The example matches the steps above:my-values.yamlimage:
pullSecret: registry-pull
registry: nexus.example.local:5000/ibpm/
url:
schema: https
host: 192.168.10.10 # the address under which the clients reach the system
port: 31443 # NodePort of the load balancer (30000-32767)
credentials: # change the default passwords
postgresqlPassword: <password>
hgdbUserPassword: <password>
mqAdminPassword: <password>
mqUserPassword: <password>
securityToken: <token>
ldap:
rootPassword: <password>
technicalUserPassword: <password>
nfsVolumes:
nginx:
server: 192.168.10.10
conf: {path: /srv/nfs/kubedata/nginx/conf}
html: {path: /srv/nfs/kubedata/nginx/html}
certificateCenter:
server: 192.168.10.10
path: /srv/nfs/kubedata/certificate_center
postgresDb:
server: 192.168.10.10
path: /srv/nfs/kubedata/postgres-db
openldap:
server: 192.168.10.10
ldap: {path: /srv/nfs/kubedata/openldap}
slapd: {path: /srv/nfs/kubedata/slapd.d}
poiServer:
server: 192.168.10.10
path: /srv/nfs/kubedata/poi-server
mercury:
server: 192.168.10.10
upload: {path: /srv/nfs/kubedata/mercury-upload}
lucene: {path: /srv/nfs/kubedata/mercury-lucene}The default passwords and the token in
values.yamlare public, so always change them. Store the file with the real values outside of the repository. -
Check what the chart generates (optional) and install it:
helm template mercury ./mercury-single-node -n mercury -f my-values.yaml | grep -n "image:\|server:"
helm install mercury ./mercury-single-node -n mercury -f my-values.yaml -
Watch the start. All the pods should become
Running:kubectl -n mercury get pods -wOrder of the startThe pods wait for their dependencies: the init container
wait-for-dependencieschecks the ports of PostgreSQL, ActiveMQ, Terracotta, OpenLDAP and the Excel server, so for a while the pods show the stateInit:0/1, and the Mercury node starts after its dependencies. When a pod stays in this state for a long time, check what it waits for (the log printswaiting for host:port):kubectl -n mercury logs <pod> -c wait-for-dependencies -
Check the system. The load balancer is published on the NodePort from
url.port, on every node of the cluster. The documentation of the API must answer200:curl -k -o /dev/null -w "%{http_code}\n" https://192.168.10.10:31443/mercury-ws-app/rest/openapi.jsonThe database is PostgreSQL 17:
kubectl -n mercury exec deploy/postgres-db -- psql -U postgres -tc "select version()"
6. Cluster of three nodes (chart mercury-three-node-cluster)
The chart mercury-three-node-cluster follows the composition of the same name from the repository mercury-docker. It installs:
- three nodes of Mercury DB:
mercury-node1(the roleMASTERof the Lucene index) andmercury-node2,mercury-node3(SLAVE), - for every node its own Terracotta server (
ehcache-nodeN), its own Excel server (poi-server-nodeN) and its own volumespoi-server-N,mercury-upload-Nandmercury-lucene-N, - shared by all nodes: PostgreSQL (
max_connections400), Apache ActiveMQ, OpenLDAP and the Nginx load balancer.
Steps 1 to 4 are the same as for one node. The differences:
-
Directories on NFS. The paths
poiServer.path,mercury.upload.pathandmercury.lucene.pathinnfsVolumesare bases: the volume of the nodeNhas the path<path>-N. Create three directories for each of them:cd /srv/nfs/kubedata
mkdir -p postgres-db openldap slapd.d certificate_center nginx/conf nginx/html
mkdir -p poi-server-{1,2,3} mercury-upload-{1,2,3} mercury-lucene-{1,2,3}
chmod -R 777 . -
Installation. The file of values is the same as in step 5 (the
nfsVolumespaths are the bases from point 1):helm install mercury ./mercury-three-node-cluster -n mercury-cluster -f my-values.yamlThe names of the persistent volumes start with
mercurythreenode-, so they do not collide with the volumes ofmercury-single-node(mercurysinglenode-). When both charts are installed, give them differenturl.port(the NodePort of the load balancer). -
Start. The nodes
mercury-node2andmercury-node3wait untilmercury-node1answers on HTTP (/mercury-ws-app/rest/openapi.json). Thanks to this the first node becomes theMASTER, and the two others start in parallel afterwards. A check of the open port is not enough: Tomcat opens the port 8080 long before the application is ready. -
Login sessions. The services of the nodes publish the port 4000 of the Tomcat Cluster. Without it the sessions are not replicated and the GUI asks for the login again after the change of the node (
?n=node2). See Login and HTTP sessions in the cluster. -
Check the cluster. All the nodes should be
ONLINE, and one of them theMASTER:curl -k -X POST -H 'Content-Type: application/json' -d '{}' \
https://192.168.10.10:31443/mercury-ws-app/monitor/NodeMonitorRest/loadThe load balancer spreads the requests over the nodes. A node in maintenance (for example during the restore of the Lucene index) answers
503withRetry-After, and the load balancer passes the request to another node.
Maintenance
- Health checks and restarts. Every component of the charts has
startupProbe,livenessProbeandreadinessProbe(a TCP check for PostgreSQL, ActiveMQ, OpenLDAP, Ehcache, POI and the load balancer; for a Mercury node the light service/mercury-ws-app/monitor/NodeMonitorRest/load), so a node whose JVM died (for example killed by the out-of-memory killer) is restarted by Kubernetes. A change of the ConfigMap changes the annotationchecksum/configof the Mercury nodes, sohelm upgraderestarts them (without it the pods keep reading the old configuration). - CMIS with Basic authentication uses the OAuth client
GIUPortalClientby default (a row of the tableMRC_LDAP_OAUTH_SERVICEcreated by the PostgreSQL init script and the parametersmercury.cmis.security.oauthClientIdandmercury.cmis.security.oauthClientSecretof the defaultmercury.properties; the valuescmisOauthClientIdandcmisOauthClientSecretof the chart can stay empty). Manage the clients and their secrets in the authentication administration panel. - Update of the images or of the values: change the tags or the values and run
helm upgrade mercury ./mercury-single-node -n mercury -f my-values.yaml(for the cluster:./mercury-three-node-cluster -n mercury-cluster). - Removal:
helm uninstall mercury -n mercuryremoves the pods, the claims and the persistent volumes of the chart, but leaves the data in the directories on NFS. To start from scratch delete the contents of those directories too (the files belong torootand to the users of the containers, so remove them withsudoon the NFS server or with a one-off pod that mounts the share). - Sessions of the login. The chart
mercury-single-nodeinstalls one node of Mercury, so the replication of HTTP sessions (Tomcat Cluster) is switched off there. It is needed only when several nodes serve the pages behind a load balancer with round-robin, so the chartmercury-three-node-clusterswitches it on, see Login and HTTP sessions in the cluster. - The load balancer: configuration and certificate. They are created only when the directories
nginx/confandcertificate_centeron NFS are empty. To change the name of the host in the certificate (sslCertificate.serverName,sslCertificate.domainName) orurl.host: scale the load balancer down to zero (kubectl -n <namespace> scale deploy/mercury --replicas=0), empty both directories on the NFS server asroot(a container that runs as the usermercurycannot delete the files of the load balancer), runhelm upgradeand scale the load balancer up again. - Restore of the Lucene index and the restart of the server: the node keeps the restored index after a restart, see Backup and restore of the Lucene index.
- Disk space. The NFS share holds the database, the indexes and the files of all the nodes, so the disk of the master (the NFS server) is the one that has to be large (256 GB or more).
- Limits of the connections to the database and the pools of the JDBC: see Database connection pools and the PostgreSQL connection limit. The chart sets
postgres.maxConnections(200 by default).