This repository contains the information and references needed to run Sunbird in a Production environment. The deployment design and software choices taken have been motivated with a need to run Sunbird in a highly available, reliable and scaleable setup. Higher levels of automation have been favored. The stack is meant to be extensible and parts of it are swappable to suit your deployment environments. Pull Requests are invited to add capability and variety to the deployment choices.
This section should expand as open source contributions to support multiple run times increase over time. Presently, the software and reference steps consider the following tech stack:
Required:
- Linux, preferably Ubuntu
- Docker Swarm Mode
- Ansible
Optional:
- A CI server, e.x. Jenkins, to build extensions and take future upgrades
- a source control mechanism, e.x. Git
Head over to specific Frontend or Backend service repos in Project Sunbird to understand how to run the parts of the stack locally, perhaps on your laptop.
You have a choice to use bare metal machines or go with a Cloud provider of your choice, which can provide you Linux runtime with root access. Initial scripts contain automation to setup Sunbird on Azure and assume that you have a Unix runtime on the machine you are initiating the installation.
- Create a RSA 2048 bit SSH keypair
- Set up Docker Swarm Mode using ACS-Engine
- Bootstrap the servers using Bootstrap script
- SSH into Master node
- Clone this repo
- Bootstrap configuration
- Install databases
- Bootstrap databases
- Deploy services
Following are some sample commands to automate various acts. Replace ? as appropriate. Understanding of Ansible is expected.
This bootstraps the VMs with initial configuration needed for automated script access.
ansible-playbook -i inventory/? --tags "bootstrap_any" -e "hosts=?" -e "bootstrap_secret_file=production" bootstrap.yml --ask-vault-pass
Typically, this step configures the production environment with the basic configuration required to boot up services, e.x. DB connection strings, secrets, etc
ansible-playbook -i ansible/inventory/? ansible/bootstrap.yml --extra-vars hosts=production-swarm-manager swarm_master=true --tags bootstrap_swarm --vault-password-file /run/secrets/vault-pass
Sunbird uses Mongo, Cassandra, Postgres and Elasticsearch for various scaleable persistence and query needs.
This repo contains provisioning scripts for DBs at ansible/provision.yml. You may use these or setup/reuse DB as appropriate in your deployment environments.
All DBs have Backup and Restore scripts.
Sunbird has a set of services, serving separate functional needs. Refer to sunbird-commons for a better understanding of the service oriented design.
METADATA_FILE=? ARTIFACT_LABEL=gold ENV=production ./pipelines/api-manager/deploy.sh
METADATA_FILE=? ARTIFACT_LABEL=gold ENV=production ./pipelines/proxy/deploy.sh
METADATA_FILE=? ENV=production ARTIFACT_LABEL=gold ./pipelines/sunbird-player/deploy.sh
METADATA_FILE=? ENV=production ARTIFACT_LABEL=gold ./pipelines/sunbird-actor-service/deploy.sh
METADATA_FILE=? ENV=production ARTIFACT_LABEL=gold ./pipelines/sunbird-content-service/deploy.sh
METADATA_FILE=? ENV=ntp-production ARTIFACT_LABEL=gold ./pipelines/sunbird-learner-service/deploy.sh
METADATA_FILE describes the version needed for deployment.
Sunbird can be run on VMs on various Cloud providers or bare metal. Cloud Infrastructure automation is work in progress.
Sunbird builds are available at a Image Registry. These builds are in the form of a Dockerfile. Stable releases are tagged as gold. Deployment scripts pull the gold images for production deployment. The gold images are also versioned to allow for release management and upgrade paths.
Most runtimes in Sunbird are containerized as Docker containers for portability, process isolation and standardization. For container orchestration, this repo contains scripts to run Sunbird on Docker Swarm. Cloud providers provide container services. In this repo, we are using ACS-Engine.
Sunbird comes with log aggregation and metrics reporting out of the box. For log aggregation, Sunbird is using a combination of cAdvisor, ELK stack, Prometheus and their plugin ecosystem. Ops dashboards are built using Grafana with some reference dashboards.
Sunbird is extendible. Sunbird can be taken as a base image with custom implementation of public interfaces and rebuilt for deployment. Scripts are available for ramping up of complex deployments with support to run local build promotions and deployments.
The code in this repository is licensed under AGPL-3.0 unless otherwise noted. Please see the LICENSE file for details.