How mosip/infra works
1. What this repository is
- This repo is a deployment and lifecycle-management system for the MOSIP platform, not the application itself.
- It combines Terraform for cloud/infrastructure provisioning and Helmsman for Kubernetes application deployment.
- The main supported runtime is AWS; Azure and GCP directories exist but are largely placeholders compared with AWS.
2. Top-level control plane
- GitHub Actions is the orchestration layer for all deployment and teardown operations.
- Workflows in .github/workflows call shell scripts in .github/scripts, which then invoke Terraform or Helmsman.
- The workflows are segmented by lifecycle stage: base infrastructure, observability infrastructure, MOSIP infrastructure, Helmsman app stacks, and destroy/cleanup.
3. Infrastructure provisioning boundary: Terraform
- Terraform owns the cloud boundary: VPC/networking, EC2 instances, security groups, DNS, storage, cluster bootstrap, and optional observability management infrastructure.
- The Terraform tree is split into:
- base-infra for foundational network access and WireGuard/jump-host setup
- infra for the main MOSIP cluster and supporting services
- observ-infra for the optional management plane
- terraform/modules/aws contains reusable units for AWS-specific setup such as RKE2 cluster bootstrap, PostgreSQL setup, NGINX, NFS, and Rancher/Keycloak-related provisioning.
4. Terraform deployment model and state
- Terraform workflows support two backends: local encrypted state and S3 remote state.
- Local state is protected with GPG encryption; repo scripts handle encrypt/decrypt and backend setup.
- This means state management is a first-class concern in the architecture: the repo is designed to safely persist infra state across CI runs.
5. Cloud resources and cluster shape
- On AWS, Terraform creates:
- VPC, subnets, route tables, security groups
- a jump server for access
- WireGuard endpoints for private connectivity
- EC2-based nodes for RKE2 Kubernetes
- optional external PostgreSQL on a dedicated volume
- DNS records and certificates for service subdomains
- The infrastructure is built around private networking, with the cluster and supporting services largely accessed through VPN/jump-host boundaries rather than public exposure.
6. Platform management plane: optional observ-infra
- observ-infra is a separate, optional cluster used for Rancher and Keycloak.
- This plane is intended for operator identity, cluster management, and centralized monitoring rather than MOSIP workloads.
- If used, it introduces an extra integration boundary: the main cluster must later be registered with Rancher, and Keycloak becomes the identity provider for operator access.
7. Helmsman as the Kubernetes application layer
- Helmsman deploys and manages Helm releases from Desired State Files (DSFs) in Helmsman/dsf.
- The DSFs are split by responsibility:
- prereq-dsf.yaml for cluster-wide prerequisites like monitoring, Istio, and logging
- external-dsf.yaml for shared dependencies like PostgreSQL, MinIO, Kafka, and Keycloak
- mosip-dsf.yaml for core MOSIP services
- esignet-dsf.yaml for the eSignet stack
- testrigs-dsf.yaml for test/validation workloads
- Helmsman is the application boundary where Kubernetes resources are declared, but many low-level prerequisites are injected via hooks and external secrets.
8. Helmsman hook layer and setup automation
- The Helmsman/hooks directory contains the operational glue that prepares namespaces, configmaps, secrets, DB state, Istio, SoftHSM, Redis, and test jobs.
- These hooks are run before/after Helm installs to bridge gaps between cluster state and application readiness.
- This layer is important architecturally because it handles cross-chart coordination that Helm charts alone do not manage cleanly.
9. Key runtime dependencies and data flow
- The main service stack depends on shared platform services:
- PostgreSQL for persistent data
- MinIO for object storage
- Kafka/Activemq for messaging
- Keycloak for identity/authentication
- Istio for service mesh and ingress routing
- Monitoring/logging components for observability
- Data flows are mostly internal to the Kubernetes cluster, with DNS routing and Istio gateways exposing the public/internal subdomains.
- Secrets and access inputs flow from GitHub Secrets into workflows, then into Terraform/Helmsman, and finally into Kubernetes secrets/configmaps or cloud resources.
10. eSignet and test-rig branch of the architecture
- eSignet is an optional stack that extends MOSIP with OIDC and mock identity/relying-party components for identity flows and integration testing.
- It sits on top of the same shared infrastructure and typically depends on MOSIP core services and Keycloak.
- Test rigs are a final validation layer: they consume the deployed MOSIP platform and exercise APIs/UI/DSL workflows, making them downstream from the core platform rather than standalone services.
11. Observability, logging, and mesh boundary
- The repo includes dedicated utilities for monitoring, logging, alerting, and Istio add-ons.
- Prometheus/Grafana-style monitoring, alertmanager rules, Kibana dashboards, and logging outputs are treated as shared platform services rather than application-specific features.
- This subsystem crosses both Terraform and Helmsman: Terraform can provision the management plane, while Helmsman installs the in-cluster observability stack.
12. Operational lifecycle and teardown
- Destroy workflows mirror the deployment structure: there are separate paths for Terraform destroy and Helmsman resource cleanup.
- Cleanup scripts in both .github/scripts and Helmsman/hooks reflect that the repo manages stateful infra across multiple layers, so teardown is not a single action.
- For an architecture diagram, it’s useful to show two independent lifecycles: provisioning via Terraform and application deployment/rollback/cleanup via Helmsman.
Main entry points: Helmsman Helmsman Root · workflows GitHub Actions · terraform Terraform Root · aws AWS Modules
Components 20
CI Orchestration
GitHub Actions workflows and scripts that drive provisioning, deployment, and teardown.
- GitHub Actions · Top-level control plane for deploy, destroy, and integration flows.
.github/workflows - Workflow Scripts · Shell layer that configures backends, state, secrets, and test execution.
.github/scripts - Terraform Jobs · Workflow entrypoints for provisioning and destroying infrastructure.
.github/workflows/terraform.yml - Helmsman Jobs · Workflow entrypoints for MOSIP, eSignet, external, and testrig deployment lifecycles.
.github/workflows/helmsman_mosip.yml - Destroy Jobs · Cleanup and teardown paths for Terraform and Helmsman resources.
.github/workflows/destroy-resources.yml
Terraform
Cloud infrastructure provisioning and state management.
- Terraform Root · Repository-wide Terraform entrypoints and environment splits.
terraform - Base Infra · Foundational network access, jump host, and WireGuard setup.
terraform/base-infra - MOSIP Infra · Primary AWS cluster and supporting platform services.
terraform/infra - Observ Infra · Optional management plane for Rancher and Keycloak.
terraform/observ-infra - AWS Modules · Reusable AWS building blocks for cluster bootstrap and shared services.
terraform/modules/aws - RKE2 Cluster · EC2-based Kubernetes cluster bootstrap and worker/control-plane setup.
terraform/modules/aws/rke2-cluster - Shared Services · Reusable provisioning for PostgreSQL, NGINX, NFS, and resource creation.
terraform/modules/aws/postgresql-setup - Rancher/Keycloak · Optional operator management plane and identity integration setup.
terraform/modules/aws/rancher-keycloak-setup
Helmsman
Kubernetes application deployment, hooks, and platform utilities.
- Helmsman Root · Desired-state driven Kubernetes application layer.
Helmsman - DSF Sets · Helmsman desired-state files split by prerequisites, shared deps, MOSIP, eSignet, and test rigs.
Helmsman/dsf - Hooks · Pre/post install automation for namespaces, secrets, databases, mesh, storage, and tests.
Helmsman/hooks - Platform Utils · Shared charts and manifests for ingress, observability, logging, and service wiring.
Helmsman/utils
Ops Integrations
Cross-cutting operator-management and observability boundaries.
- Observability · Monitoring, logging, alerting, and Istio add-ons spanning Terraform and Helmsman.
Helmsman/utils/logging - Identity Mgmt · Keycloak and Rancher integration boundary for operator access and cluster registration.
Rancher-keycloak-integration - State Mgmt · Encrypted local state and remote S3 backend handling for Terraform runs.
.github/scripts
Connections 22
- GitHub Actions → Workflow Scripts: invokes · Workflows delegate setup, backend configuration, encryption, and cleanup to scripts.
- GitHub Actions → Terraform Jobs: runs · CI entrypoints for terraform apply and destroy operations.
- GitHub Actions → Helmsman Jobs: runs · CI entrypoints for Helmsman deployments across MOSIP and supporting stacks.
- GitHub Actions → Destroy Jobs: runs · Separate teardown flows for infrastructure and Kubernetes resources.
- Workflow Scripts → State Mgmt: protects · Scripts manage GPG encryption, decryption, locking, and backend setup.
- Terraform Jobs → Terraform Root: provisions · Terraform workflows drive the infrastructure tree.
- Terraform Root → Base Infra: contains · Base infrastructure is the foundational provisioning stage.
- Terraform Root → MOSIP Infra: contains · Main cluster and workload infrastructure lives here.
- Terraform Root → Observ Infra: contains · Optional management-plane infrastructure lives here.
- MOSIP Infra → AWS Modules: uses · AWS environments assemble reusable modules.
- AWS Modules → RKE2 Cluster: includes · Cluster bootstrap and node provisioning.
- AWS Modules → Shared Services: includes · Storage, database, and edge-service setup.
- AWS Modules → Rancher/Keycloak: includes · Optional management-plane provisioning.
- Base Infra → RKE2 Cluster: enables access · Jump-host and private connectivity support cluster access.
- Observ Infra → Rancher/Keycloak: integrates · Management cluster and identity services are provisioned together.
- Helmsman Jobs → Helmsman Root: deploys · Helmsman workflows apply desired-state files and hooks.
- Helmsman Root → DSF Sets: defines · Desired-state files describe stack-specific releases.
- Helmsman Root → Hooks: executes · Hooks prepare cluster state before and after Helm actions.
- Helmsman Root → Platform Utils: installs · Shared manifests and charts provide ingress, mesh, logging, and monitoring.
- Platform Utils → Observability: provides · Logging, alerting, dashboards, and Istio add-ons form the observability layer.
- Observ Infra → Identity Mgmt: supports · Rancher and Keycloak are the operator-management boundary.
- Helmsman Root → Identity Mgmt: consumes · Application deployment depends on shared identity and cluster-management services.