Migrate from server to cloud
Move a Platforma installation from Single Server mode to a Kubernetes cluster on AWS, with all projects and results.
Other ways: Migrate between sign-in providers.
When you move to KubernetesKubernetes — A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster. Glossary, users keep all their projects and results, and their jobsjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary then run in the cluster, so many jobs can run at the same time. You move three things: the database as one backup file, the primary storageprimary storage — The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files. Glossary as a copy in the bucket of the cluster, and the master secret. The server keeps running without changes until you know that the cluster works.
The full procedure, with all commands and the AWS permissions, is in the migration guide. This page tells what happens and what you must know before you start.
Before you start
- The same version on both sides. The BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary on the cluster must have the same version (major and minor) as the Backend on the server. Upgrade after the migration: you can go directly to the most recent release (see Supported versions).
- A cluster that is ready. Install the cluster and its parts as for the Helm chart, but do not install Platforma in this step: see Install in custom infrastructure.
- An empty bucket for the primary storage of the cluster.
- Your license key. The restore and the cache cleanup run the Backend program in the cluster, and it needs the license.
- A time without users. From the backup of the database to the end of the migration, nobody may write to the server. Work that starts after the backup is lost.
Where the results are now
The database refers to the files in the primary storage by their path and by an ID of the storage, not by the name of the bucket or the folder. The files never change after the Backend writes them. Because of this, you can copy them to the new bucket with the same paths while users work, and stop the work only for a short time at the end.
| Primary storage of the server | How to copy it |
|---|---|
A folder (the default: <main-root>/primary, for example /data/platforma/primary) |
Copy the content of the folder to the root of the new bucket, or to its prefix, with the same paths: aws s3 sync /data/platforma/primary/ s3://<bucket>/<prefix>/. Run it on the server. |
| An S3 bucket | Copy the bucket to the new bucket. For several TiB, use S3 Batch Replication. For less data, use a sync tool such as aws s3 sync or s5cmd. |
Each new run of aws s3 sync copies only the files that are new, so the last run is short.
How the migration works
-
Copy the primary storage while users work. See Where the results are now. The first copy can take hours or days.
-
Stop all work on the server. Tell users to stop, and stop the programs that send work to Platforma.
-
Back up the server two times, and cancel the running BlocksBlock — A small application for one step of an analysis, for example the import of reads or clustering. It can combine several tools. Glossary between them.
- Make a safety backup of the database. It is your way back for the server.
- Stop the Backend and run it one time with
--cancel-running-blocks. Blocks that run now cannot continue on the cluster. Without this step, they stay “running” there forever. On Kubernetes, see Cancel running Blocks on Kubernetes. - Start the Backend again and make the migration backup. You restore this file in the cluster.
Make each backup on the server:
The BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary gives a copy of its database through its debug API. In Single Server modeSingle Server mode — The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster. Glossary, the debug API is off by default. To turn it on, add a line to the environment file of the service and restart the Backend. You do this one time:
Terminal window echo 'PL_DEBUG_ENABLED=true' | sudo tee -a /etc/platforma/platforma.env > /dev/nullsudo systemctl restart platformaThe option
--debug-enabledin the start command does the same. The debug API then listens on127.0.0.1:9091(the options--debug-ipand--debug-port), so run the next command on the server. The Backend continues to work during the copy.Terminal window curl -fsS http://127.0.0.1:9091/db/state_raw | gzip > backup-$(date +%F).tsv.gzWhen the Backend uses TLS (
--listen-tlsor--self-signed-tls), the debug API accepts only HTTPS. Then usecurl -fsSk https://127.0.0.1:9091/db/state_rawin the command: the certificate names the domain of the server, not127.0.0.1, and the connection does not go out of the server. -
Copy the last changes of the primary storage. Run the copy again, in the same stop as the migration backup: then the bucket has every file that the backup refers to.
-
Give the cluster the master secret of the server. The database keeps credentials and signatures that only this secret opens. Put it in the Secret
platforma-master-secret(keymaster-secret) before you install Platforma.-
If the server starts with
--master-secretor--master-secret-file, use that value. -
If the server has only a login token, the Backend makes the secret from the token. The token is in
PL_AUTH_TOKEN, or after the colon in<main-root>/token.htpasswd. Make the same secret:Terminal window printf '%s' '<token>' | openssl dgst -sha256 -binary | base64
-
-
Restore the database in the cluster. Make the database volume
platforma-databasebefore you install Platforma, with the Helm labels and annotations, so that the chart can use it:metadata:name: platforma-databasenamespace: platformalabels:app.kubernetes.io/managed-by: Helmannotations:meta.helm.sh/release-name: platformameta.helm.sh/release-namespace: platformaPut the backup file on the volume, and restore it with
platforma --restore-db=<file> --db-dir=/data/database --force. The pods must run as user and group1010, the user of the Helm chart: if not, the Backend cannot read the restored files. -
Install Platforma with the Helm chart, with the new bucket as primary storage. Use the same prefix as in the copy. The chart uses the volume that you made.
values.yaml (part) primaryStorage:s3:bucket: <bucket>region: <region>prefix: <prefix> -
Clean the caches. On the server, the tools ran directly on its disk. In the cluster, they run in containers. Stop the Backend and run it one time with
--invalidate-caches. The Backend then runs the tools again in the cluster when a project needs their results. Then start the Backend.
If you also change the sign-in providersign-in provider — A configured way for users to sign in to the Backend: single sign-on (SSO), LDAP or a static list of users. One Backend can have more than one. Glossary, for example from a static list of usersstatic list of users — A sign-in provider that is a file with the logins and the password hashes of the users, in the htpasswd format. The Backend reads it again when it changes. Glossary to single sign-onsingle sign-on — Sign-in through the identity service of the company, with the same account as for other company systems. Glossary, users can lose access to their projects: see Migrate between sign-in providers.
Cancel running Blocks on Kubernetes
When the installation that you move from runs on Kubernetes, run the Backend one time with
--cancel-running-blocks in a separate pod. The pod copies the full settings of the Backend, so
it reads the same database, license and storage. The Backend must be stopped: only one program at a
time can open the database.
-
Stop the Backend.
Terminal window kubectl scale deployment platforma -n platforma --replicas=0Check that the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary pod is gone. The filter leaves out the pods of the cleanup jobjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary, which have the same release label:
Terminal window kubectl get pods -n platforma -l 'app.kubernetes.io/instance=platforma,!app.kubernetes.io/component'Result:
No resources found in platforma namespace.If the list shows a pod, also in the stateTerminating, wait and run the command again. Do not continue while the pod exists: it can still write to the database. -
Start the pod. It runs the Backend with the extra option, without the health checks, and stops when the Blocks are cancelled. The command makes the pod with
jq: install it on your computer first.Terminal window kubectl get deployment platforma -n platforma -o json | jq '.spec.template.spec as $s| {apiVersion: "v1", kind: "Pod",metadata: {name: "platforma-cancel-blocks", namespace: .metadata.namespace},spec: ($s| .restartPolicy = "Never"| .containers = [.containers[]| select(.name == "platforma")| .args += ["--cancel-running-blocks"]| del(.startupProbe, .livenessProbe, .readinessProbe)])}' | kubectl apply -f - -
Wait until the pod stops, and read the result.
Terminal window kubectl get pod platforma-cancel-blocks -n platforma -wWhen the status is
CompletedorError, stop the command with Ctrl+C, and read the log:Terminal window kubectl logs platforma-cancel-blocks -n platforma -c platforma | grep 'running blocks'Result:
All running blocks were successfully cancelled. If the log showsFailed to cancel running blocks, keep the pod and send its log to MiLaboratories support. -
Delete the pod, and start the Backend.
Terminal window kubectl delete pod platforma-cancel-blocks -n platformakubectl scale deployment platforma -n platforma --replicas=1
Check the result
- The database volume is
Boundand not empty, and the Backend pod isReady. - The number of objects in the new bucket is the same as in the source.
- In the Desktop AppDesktop App — The program that each user installs on their own computer to work with Platforma. It is a client of the Backend. Glossary, connected to the cluster, your existing projects open with their results.
Go back
The server stays as it was, except for the cancelled Blocks. If the cluster does not work:
-
To try again in the cluster: uninstall the Helm release (the database volume stays), delete the database volume, and restore the migration backup again.
-
To keep working on the server: start it again. To also get back the Blocks that you cancelled, restore the safety backup on the server while the Backend is stopped:
Terminal window sudo -u platforma /opt/platforma/binaries/platforma \--restore-db=<safety-backup> --db-dir=/data/platforma/rocksdb --force