Skip to content

Instance Provisioning

Provisioning creates and configures the necessary resources for a new Open edX instance. This includes setting up databases and users for MySQL and MongoDB, storage buckets, Kubernetes namespaces, and RBAC policies. The provisioning process is automated through Argo Workflows and executed when creating a new instance.

The provisioning system handles:

  • MySQL Database: Creates database and user with appropriate permissions
  • MongoDB Database: Creates databases and user with appropriate permissions
  • Storage Buckets: Creates S3-compatible storage buckets (AWS S3 or DigitalOcean Spaces)
  • Kubernetes Resources: Sets up namespaces, RBAC policies, and service accounts

All provisioning workflows run in parallel and must complete successfully before the instance can be built and deployed.

Object storage uses tutor-contrib-s3 keys

Instance config.yml stores Tutor S3_* / OPENEDX_AWS_* settings (seeded from LAUNCHPAD_STORAGE_* at create time). The same keys drive Open edX uploads and Launchpad bucket workflows. See Object Storage.

Provisioning Steps

Prerequisites

Before provisioning an instance, ensure the following are configured:

  1. Kubernetes Cluster: A running Kubernetes cluster with ArgoCD and Argo Workflows installed
  2. Database Access: Admin credentials for MySQL and MongoDB servers
  3. Storage Credentials: Access keys for S3-compatible storage (AWS S3 or DigitalOcean Spaces)
  4. Environment Variables: Required configuration variables set (see below)

Required Environment Variables

Docker Registry:

export LAUNCHPAD_DOCKER_REGISTRY_CREDENTIALS="base64-encoded user:password"

MySQL Database:

export LAUNCHPAD_MYSQL_HOST="mysql.cluster.domain"
export LAUNCHPAD_MYSQL_PORT="3306"
export LAUNCHPAD_MYSQL_ROOT_USER="root"
export LAUNCHPAD_MYSQL_ROOT_PASSWORD="secure_password"

MongoDB Database (Required for all):

export LAUNCHPAD_MONGODB_HOST="mongodb.cluster.domain"
export LAUNCHPAD_MONGODB_PORT="27017"
export LAUNCHPAD_MONGODB_ADMIN_USER="admin"
export LAUNCHPAD_MONGODB_ADMIN_PASSWORD="secure_password"
export LAUNCHPAD_MONGODB_AUTH_SOURCE="admin"

MongoDB Database (DigitalOcean):

export LAUNCHPAD_MONGODB_CLUSTER_ID="abc12345-xyz67890"
export LAUNCHPAD_DIGITALOCEAN_TOKEN="dop_v1_your_token"

MongoDB Database (MongoDB Atlas):

export LAUNCHPAD_ATLAS_PUBLIC_KEY="your_public_key"
export LAUNCHPAD_ATLAS_PRIVATE_KEY="your_private_key"
export LAUNCHPAD_ATLAS_PROJECT_ID="your_project_id"
export LAUNCHPAD_ATLAS_CLUSTER_NAME="Cluster0"

Storage (seeds tutor-contrib-s3 settings in config.yml at create time):

export LAUNCHPAD_STORAGE_TYPE="spaces"  # or "s3"
export LAUNCHPAD_STORAGE_REGION="nyc3"  # or "us-east-1", or "us-1" for UpCloud
export LAUNCHPAD_STORAGE_HOST=""        # UpCloud Managed Object Storage hostname
export LAUNCHPAD_STORAGE_ACCESS_KEY_ID="your_key"
export LAUNCHPAD_STORAGE_SECRET_ACCESS_KEY="your_secret"

Use spaces for DigitalOcean Spaces (S3_HOST={region}.digitaloceanspaces.com) and s3 for AWS (S3_HOST empty). For UpCloud, use s3, set LAUNCHPAD_STORAGE_REGION to the object storage region, and set LAUNCHPAD_STORAGE_HOST to the Terraform output object_storage_endpoint_hostname. After creation, edit the Tutor keys in config.yml if needed; Launchpad derives the workflow provider from whether S3_HOST contains digitaloceanspaces.com. See Object Storage.

Provisioning Process

The provisioning process is automatically executed when creating a new instance using the launchpad_create_instance command or the GitHub Actions workflow (recommended).

Existing configuration

launchpad_create_instance reuses or clones instance files instead of failing when instances/<name>/ already exists:

  • Retry / same-name migration: if instances/<name>/config.yml already belongs to this instance (K8S_NAMESPACE or TUTOR_APP_NAME matches the instance slug), generation is skipped. Passwords and the S3 bucket name are not regenerated. Missing application.yml is generated from the template without rewriting config.yml. You do not need to delete the instance directory to re-run create after a failure.
  • Based on another instance: copy config.yml and application.yml from an existing instance, or pass --from-instance <name>. Extra keys (plugins, theming, Tutor extras) are kept. Identity and credentials are rewritten so the new instance does not share databases, bucket, namespace, or hosts.
  • Existing dest config, different identity: if instances/<name>/config.yml already exists but K8S_NAMESPACE / TUTOR_APP_NAME do not match the new slug, cookiecutter runs into a temp dir and identity/credentials are overlaid (same rebase as --from-instance after copy).
  • Fresh create: if there is no dest config.yml, cookiecutter generates a new instance directory.

Rewritten identity fields include Docker image tags, K8S_NAMESPACE / TUTOR_APP_NAME, LMS/CMS hosts, MySQL and MongoDB names/users/passwords/hosts, and S3 bucket/region/credentials. When destination application.yml exists it is copied from the source and patched (metadata.name, labels, spec.source.path / repoURL / targetRevision, spec.destination.namespace); custom syncPolicy is preserved. When it is missing, the generated application.yml is used instead.

--from-instance is refused when dest config already matches this instance, so a retry or same-name migration is not overwritten.

Failed provision workflows are deleted and re-applied on retry so Argo actually re-runs them.

The process then follows these steps:

1. Namespace and RBAC Setup

  • Creates a Kubernetes namespace for the instance
  • Configures RBAC policies to allow Argo Workflows to manage resources
  • Sets up service accounts and permissions

2. Workflow Creation

Three provision workflows are created in parallel:

  • MySQL Provision Workflow: Creates the MySQL database and user
  • MongoDB Provision Workflow: Creates MongoDB databases and user
  • Storage Provision Workflow: Creates the storage bucket

Each workflow is parameterized with instance-specific configuration values extracted from the instance configuration file.

3. Workflow Execution

The workflows execute the following operations:

MySQL Provisioning:

  • Connects to the MySQL server using admin credentials
  • Creates the database specified in the instance configuration
  • Creates a user with appropriate permissions

MongoDB Provisioning:

  • Detects the MongoDB provider (DigitalOcean API, Atlas, or direct connection)
  • Creates the main database and forum database
  • Creates a user with readWrite on both MONGODB_DATABASE and FORUM_MONGODB_DATABASE
  • For API-based providers, uses the provider's API to manage users

Storage Provisioning:

  • Creates an S3-compatible storage bucket named from S3_STORAGE_BUCKET in the instance config
  • Derives provider from S3_HOST (spaces if the host contains digitaloceanspaces.com, otherwise AWS s3)
  • Uses a custom endpoint built from S3_HOST / S3_PORT / S3_USE_SSL when a host is set; AWS with an empty host uses default endpoints
  • Enables versioning for AWS S3 when the endpoint is empty; skips versioning and public-bucket API calls when a custom endpoint is set
  • Leaves the bucket private by default

4. Workflow Completion

The system waits for all workflows to complete successfully. If any workflow fails, the provisioning process is aborted and an error is reported.

5. Configuration Updates

After successful provisioning:

  • MongoDB password is retrieved from the Kubernetes Secret and updated in the instance configuration file
  • The temporary secret containing the MongoDB password is deleted for security

6. ArgoCD Application Creation

Once provisioning is complete, an ArgoCD Application is created to manage the Open edX deployment. The application monitors the cluster repository and deploys the instance when changes are detected.

Troubleshooting

Workflow Failures

If a provisioning workflow fails, check the workflow status and logs:

# Check workflow status
kubectl get workflows -n <instance-name>

# View detailed workflow information
kubectl describe workflow <workflow-name> -n <instance-name>

# View workflow logs
kubectl logs -n <instance-name> workflow/<workflow-name>

Common Issues:

  • Database Connection Failures: Verify that database host, port, and credentials are correct
  • Permission Errors: Ensure admin credentials have sufficient privileges to create databases and users
  • Network Issues: Check that the Kubernetes cluster can reach the database servers
  • Provider API Errors: For MongoDB Atlas or DigitalOcean, verify API credentials and permissions

Forum index creation is unauthorized

The forum init job fails when forum_create_mongodb_indexes returns MongoDB code 13 (Unauthorized) for createIndexes on FORUM_MONGODB_DATABASE. On Atlas, that means the instance user has readWrite on the Open edX database and lacks it on the forum database. DigitalOcean provisioning already grants both databases. AWS and UpCloud use the Atlas provider, so they need both roles.

Add the forum role to an existing user. Use MONGODB_USERNAME, MONGODB_DATABASE, and FORUM_MONGODB_DATABASE from that instance's config.yml. Omit --password so the password already stored in config.yml stays valid. The Atlas --role flag replaces the user's full role list, so include both databases:

set -euo pipefail

export ATLAS_PROJECT_ID="your-atlas-project-id"
export MONGODB_USERNAME="launchpad-demo"
export MONGODB_DATABASE="launchpad-demo-openedx"
export FORUM_MONGODB_DATABASE="launchpad-demo-forum"

atlas dbusers update "$MONGODB_USERNAME" \
  --projectId "$ATLAS_PROJECT_ID" \
  --role "readWrite@${MONGODB_DATABASE},readWrite@${FORUM_MONGODB_DATABASE}"

atlas dbusers describe "$MONGODB_USERNAME" \
  --projectId "$ATLAS_PROJECT_ID"

Confirm the description lists readWrite for both database names. Then delete the failed Drydock init job, the one whose logs contain forum_create_mongodb_indexes, and sync the Argo CD application so it recreates that job. The recreated job should finish successfully. forum_create_mongodb_indexes can still log the MySQL forum setup line Forum indices initialized successfully before it creates the MongoDB indexes; success means that command exits without MongoDB code 13.

For later instances, install the updated workflow template with launchpad_install_argo --workflows-only before provisioning. That template grants both roles when it creates or updates the Atlas user.

Partial Provisioning

If provisioning partially succeeds (some workflows succeed, others fail):

  1. Check Dependencies: Ensure all required services (databases, storage) are available
  2. Retry: Re-run launchpad_create_instance without deleting the instance config. Existing matching config is reused; failed provision workflows are deleted and re-run.

Init jobs not starting

In some rare cases when a deployment initially failed, init jobs may get stuck.

To restart them, use the following script from the repo root:

set -euo pipefail

export namespace=demo
export rendered="$(kubectl kustomize instances/demo/env)"

for job in \
  drydock-lms-job-0 \
  drydock-lms-job-3 \
  drydock-lms-job-4 \
  drydock-cms-job-5 \
  drydock-lms-job-6 \
  drydock-lms-job-7
do
  echo "Starting ${job}"
  kubectl -n "${namespace}" delete job "${job}" --ignore-not-found
  printf '%s\n' "${rendered}" | awk -v name="${job}" '
    BEGIN { RS = "\n---\n" }
    $0 ~ "\n  name: " name "\n" { print "---\n" $0 }
  ' | kubectl apply -n "${namespace}" -f -
  kubectl -n "${namespace}" wait --for=condition=complete "job/${job}" --timeout=30m
  kubectl -n "${namespace}" logs "job/${job}"
done

Getting Help

If provisioning continues to fail:

  1. Collect Logs: Gather workflow logs, Kubernetes events, and any error messages
  2. Check Configuration: Verify all environment variables and instance configuration values
  3. Check Cluster Health: Ensure the Kubernetes cluster and Argo Workflows are functioning correctly

See Also