Migration from Docker swarm guide
Prerequisites and Important Information
This tutorial guides you through all steps required to transform your v1.9 Docker Swarm infrastructure to Kubernetes and redeploy OpenCRVS on it. Please carefully review this section before proceeding with the migration.
Before you begin
Prerequisites
1. Infrastructure Repository
OpenCRVS v2.0+ uses a dedicated repository for continuous delivery configuration:
Repository: https://github.com/opencrvs/infrastructure
Required Action:
Fork this repository to your organization or personal GitHub account before starting migration
Detailed forking steps are provided in
Ensure that your user has admin rights over the repository
2. SSH Access Configuration
The provision user on your production Docker manager server must have passwordless SSH access to the backup server. You will need configure SSH key-based authentication between Docker manager and backup server.
Steps:
Login on production docker manager as
provisionuser:Generate private/public key-pair:
Copy public key value from output (example value):
Login on worker/backup server as
provisionuser and add public key from production to/home/provision/.ssh/authorized_keyson backup server:
3. Migration token
A classic GitHub token is required to run the migration workflow. The token should have following permissions:
repo: Full control of private repositoriesworkflow: Update GitHub Action workflowsexpiration date should be set to manageable period (few months, year, never) established by organisation secure policies.
Purpose of MIGRATION_GH_TOKEN
Token is used while secrets and variables migration from Countryconfig template to infrastructure repository.
Token is stored as
GH_TOKENsecret in infrastructure repository.Token is used to provision Kubernetes self-hosted runner.
Steps to create Migration token
In your countryconfig repository navigate to repository level secrets at "Actions secrets and variables" (Settings -> Secrets & Variables -> Actions)
Create new secret
MIGRATION_GH_TOKENwith value of GitHub token.
Changes between docker swarm and Kubernetes
1. Changes to Environments
After migration only the following environments will appear in your new forked infrastructure repository (if they existed in your original repository):
developmentqastagingproduction
The following Gihtub environments are deprecated:
backupis merged into production while migration and the backup server is managed as part of a production environment by the Provision workflow.jumpboxis not used anymore
2. Docker-compose migration
All OpenCRVS services are deployed as helm charts during migration.
All customizations must be re-implemented using a custom Helm chart.
An example custom helm chart is published as part of the infrastructure repository, see https://github.com/opencrvs/infrastructure/tree/develop/charts/opencrvs-mosip
You may also choose to use Bitnami Common Library Chart for more advanced use cases.
Migration Architecture
Single Server Deployments
Docker Swarm: Single server environment
Kubernetes: Converted to single server Kubernetes environment (single-node cluster)
Multi-Node Deployments
Docker Swarm: Multi-node with manager and worker nodes
Kubernetes: Converted to Kubernetes cluster with worker nodes
⚠️ Important Limitation:
Migration script does not support multiple Docker manager nodes
Only single manager + multiple workers configuration is supported
Single server docker environments are converted to single server Kubernetes environments.
Multi node docker environments are converted to Kubernetes clusters with worker nodes. Migration script doesn't support multiple docker manager nodes.
Migration process
Pre-migration check-list
Make sure all preparations steps completed
Migration steps in Country config (old repository)
Navigate to your countryconfig repository
Run the provision workflow for each environment, e/g if you have qa, staging and production environments, you need to run workflow 3 times. This ensures that all your servers are up to date .
Run "Migration swarm to k8s" GitHub actions workflow

"The environment to migrate": Environment chosen for migration, you may migrate environments one by one or altogether
"The target organisation owner": GitHub organisation or your personal account who owns Infrastructure repository
"The target infrastructure repository": GitHub infrastructure repository name
Verify workflow execution results: On the screenshot execution results for single environment are shown, make sure all steps completed successfully.

Verify target repository
Navigate to Infrastructure repository
Navigate to Settings -> Environments: Make all repository and environment level secrets and variables have been created
Navigate to Settings -> Actions -> Runners -> Self-hosted runners: Make sure self-hosted runners are available for each migrated environment. If you run migration for one environment only, you will find only one runner. NOTE: Environment name is a part of runner name and one of the runner tags, e/g "development" on the screenshot

Each environment will have ows self-hosted runner Navigate to "Pull requests" section: You will find PR with all changes required to deploy new environment with Kubernetes.

Review changes within PR:
If your docker-compose file had any customisations like environment variables, please add them to
environments/<env name>/opencrvs-services/values.yamlBy default traefik is configured to use static ssl certificates, adjust values if needed, check documentation at
Merge Pull request to main (develop) branch. If multiple environments were migrated at the same time, you will need to resolve pull request conflicts manually, usually effected section is
environmentinput selector:

Kubernetes environment provision and deploy
Provision Kubernetes environment on top of Docker Swarm environment: Run Provision workflow from Infrastructure repository, see for more information
Reboot your target server
Deploy dependencies, see for more information
Deploy OpenCRVS: see for more information
Use same OpenCRVS Core image tag as docker swarm
Use same Country config image tag as docker swarm
Make sure "Enable data seeding during deployment" is unchecked

Post migration steps
Configuring Workflow Approval Process
OpenCRVS now requires approval for deployment and maintenance GitHub Actions workflows on production environments. This adds an additional layer of control to prevent unexpected downtime or issues.
Environments Requiring Approval
Production: Approvals required by default
Staging and Other environments: No approval required (unless explicitly configured)
Setup Instructions
Step 1: Identify Approvers
Determine which team members should have authority to approve production deployments and maintenance tasks.
Step 2: Configure Repository Variable
Set up the GH_APPROVERS variable at the repository level:
Navigate to your repository settings
Go to Settings → Secrets and variables → Actions → Variables
Click New repository variable
Configure:
Name:
GH_APPROVERSValue: Comma-separated list of GitHub usernames (e.g.,
alice,bob,charlie)
Set Up APPROVAL_REQUIRED at environment level to control which environments require approval before workflow execution:
Navigate to your repository settings
Go to Settings → Environments
Select the environment you want to configure (e.g.,
production,staging)Scroll to Environment variables section
Click Add variable
Configure:
Name:
APPROVAL_REQUIREDValue:
true(to enable approval) orfalse(to disable)
Step 3: Verify Configuration
After configuration, workflows targeting production will pause for approval from designated users before execution.
Important Notes
GH_APPROVERSmust be defined at repository level (not environment level)APPROVAL_REQUIREDmust be defined at environment level (not repository level)Use GitHub usernames without
@symbolMultiple approvers separated by commas with no spaces
At least one designated approver must approve the workflow to proceed
Backup & Restore
Please read this section to get better understanding about changes, no actions is needed from your side
This section outlines the fundamental differences in backup and restore implementation between Docker Swarm and Kubernetes deployments. Understanding these differences is critical for migration planning and operational adjustments.
Docker Swarm Approach
Architecture:
Backup and restore operations run as shell scripts on the Docker manager node
Backup script scheduled as OS cronjob on production environment
Restore script scheduled as OS cronjob on staging environment
Single monolithic script handles all datastores (PostgreSQL, MongoDB, MinIO, InfluxDB)
Uses direct filesystem access to
/datadirectory
Kubernetes Approach
Architecture:
Backup and restore jobs split by datastore (one job per database)
Backup and restore operations are environment-agnostic and can be configured on any deployment (development, QA, staging, production, etc.).
Scheduled as Kubernetes CronJobs (native k8s resources)
Scripts use remote database connections via network protocols
Each job runs as a Kubernetes pod with database client tools
The fundamental shift is from filesystem-based operations to network-based database operations. While this introduces network overhead, it provides the flexibility and portability required for modern cloud-native deployments, including support for managed database services and multi-environment consistency.
Check for more information and configuration details.
GitHub Fine-grained token
GitHub self-hosted runners could be configured to use fine-grained token.
Variable name: GH_TOKEN
Required permissions:
Actions: Read and Write
Administration: Read and Write
Metadata: Read-only
Last updated