QuickStart for OpenShift
Pull Request-Based Workflows with Sample Stack
This repository provides a template to rapidly deploy a modern web application stack to OpenShift using GitHub Actions, incorporating best practices for CI/CD, security, and observability. By hitting the ground running we can save weeks‑to‑months of development time, receive regular updates, and built‑in Maintenance Mode Automation, which allows an app to go on autopilot for security and dependency updates. This limits developmer involvement to critical issues only, drastically reducing labor costs and freeing up resources for higher priority work.
Includes:
- Pull Request-based pipeline
- Sandboxed development environments
- Container publishing (ghcr.io) and importing (OpenShift)
- Security, vulnerability, infrastructure, and container scan tools
- Out-of-the-box alignment with OWASP ASVS Level 1 & 2 controls (see SECURITY.md)
- Automatic dependency patching via bcgov/renovate-config
- Maintenance Mode Automation (hands‑off updates, low‑dev mode) via the same Renovate config
- Enforced code reviews and workflow jobs (pass|fail)
- OpenShift Templates
- Prometheus Metrics export from Backend/Frontend
- Resource Tuning with Horizontal Pod Autoscaler
- Affinity and anti-affinity for Scheduling on different worker nodes
- Rolling updates with zero downtime in PROD
- Database Migrations with Flyway
- Pod disruption budgets for high availability
- Self-healing through probes/checks (startup, readiness, liveness)
- Sample application stack:
- Database: Postgres, Flyway
- Frontend: TypeScript, React, Caddy Server with Coraza WAF (prefers native
fetch over Axios)
- Backend: TypeScript, Nest.js
Setup
Setup takes an hour or less. Scripts in scripts/ do the GitHub and OpenShift parts. Each one previews its changes by default, makes them only with --apply, and is safe to re-run: it changes only what differs and leaves everything else alone. Running any of them without --apply verifies the setup: it ends with All set: nothing to change., or exits non-zero with the number of things to change. It confirms secrets exist but can't verify their values. Run them yourself, with your own logins.
Checklist
Accounts (by hand): GitHub accounts for the team. For BC Government, also IDIR accounts and membership in the bcgov GitHub organization (instructions).
OpenShift namespaces (by hand): request a project set (DEV, TEST and PROD) from Platform Services at the registry. You get a licence plate, e.g. abc123, and namespaces abc123-dev, abc123-test and abc123-prod.
Create the repository (by hand): use this repository as a template, with bcgov/quickstart-openshift selected under Repository template.

Log in (by hand): gh auth login, then in the OpenShift console select your name (top right) > Copy login command and paste it into a shell (oc login --token=... --server=...). You need admin rights on the repo and edit rights in all three namespaces.
Then run steps 5 to 7 with one command, which previews by default and exits non-zero if anything needs changing; add --apply to make the changes:
scripts/setup.sh --plate abc123 # preview, then add --apply
OpenShift deploy account (optional helper; see by hand): creates the github-actions service account, edit role binding and token Secret in each namespace.
scripts/setup-openshift.sh --plate abc123 # preview, then add --apply
GitHub environments, secrets and variables (optional helper; see by hand): creates the test and prod environments, and sets the OC_NAMESPACE variable and OC_TOKEN and DB_PASSWORD secrets for pull requests (repository level), TEST and PROD, plus the OC_SERVER variable. Without --plate it reads the plate from existing OC_NAMESPACE variables. It won't generate a DB_PASSWORD for a namespace that already has a database, since a new password would lock the app out. Secrets that are already set are never overwritten. Secret values are piped from oc or openssl straight into gh secret set; they're never printed or written to disk, and previews show only the secret's name.
scripts/setup-environments.sh --plate abc123 # preview, then add --apply
GitHub repository settings: the main ruleset, pull request settings and private vulnerability reporting (see Repository Configuration).
scripts/setup-github.sh # preview, then add --apply
First pull request: open one to run the pipeline, then make the packages public (see Packages).
Optional (by hand): SonarCloud, Renovate, Sysdig, a vanity URL with TLS, PROD deployment rules and team members, all described below.
Secrets, Variables and Environments
Workflows read these values. Repository-level values are used by pull request deploys; test and prod environment values override them for those deploys. Steps 5 and 6 set the required ones.
| Environment |
Name |
Description |
| none |
vars.OC_SERVER |
OpenShift API server URL (repository-level) |
| none |
vars.OC_NAMESPACE |
PR namespace, <plate>-dev |
| none |
secrets.OC_TOKEN |
PR service token |
| none |
secrets.DB_PASSWORD |
PR database password |
| test |
vars.OC_NAMESPACE |
TEST namespace, <plate>-test |
| test |
secrets.OC_TOKEN |
TEST service token |
| test |
secrets.DB_PASSWORD |
TEST database password |
| prod |
vars.OC_NAMESPACE |
PROD namespace, <plate>-prod |
| prod |
secrets.OC_TOKEN |
PROD service token |
| prod |
secrets.DB_PASSWORD |
PROD database password |
| none (opt) |
vars.ROUTE_HOST |
Vanity URL hostname (repository-level) |
| prod (opt) |
vars.S3_BUCKET |
S3 bucket name for offsite database backups |
| prod (opt) |
vars.S3_ENDPOINT |
S3 endpoint URL (e.g. https://nrs.objectstore.gov.bc.ca) |
| prod (opt) |
secrets.S3_USER |
S3 access key ID for offsite database backups |
| prod (opt) |
secrets.S3_PASSWORD |
S3 secret access key for offsite database backups |
| none (opt) |
secrets.SONAR_TOKEN_BACKEND, secrets.SONAR_TOKEN_FRONTEND |
See SonarCloud |
| none (opt) |
secrets.SYSDIG_API_TOKEN |
PROD alert sync |
DB_PASSWORD is generated separately for each environment. Don't change it after the first deploy: PostgreSQL keeps its first password.
Copied the template before OC_NAMESPACE became a variable? Move it: gh variable set OC_NAMESPACE --body <plate>-dev, and the same with --env test / --env prod (or run scripts/setup-environments.sh --apply). The old secret is unused and can be deleted.
Secrets and Variables by Hand
Steps 5 and 6 above are an optional helper. Everything they do can be done by hand, as below.
Variables and secrets are consumed by workflows. Variables are visible in workflows and logs, while secrets are hidden/redacted.
Repository-level vs Environment-specific:
- Repository-level (shown as
<none> in the environment column): These are available to all workflows and environments. They're created at the repository level and apply globally unless overridden by environment-specific values.
- Environment-specific: These are scoped to a particular environment (e.g., TEST, PROD) and override repository-level values when that environment is used.
To create new secrets from GitHub.com click:
Settings > Secrets and Variables > Actions > Secrets > New repository secret
To create new environments from GitHub.com click:
Settings > Environments > New environment
OC_TOKEN
Create separate tokens for each of the DEV, TEST and PROD namespaces.
- Login to your OpenShift console, e.g. Silver or Gold.
- Select the pulldown with your username in the top right corner.
- Select
Copy login command.
- Follow the UI to access a one-time login with token.
- Paste the login command into a shell, e.g.:
oc login --token=... --server=...
- View available projects:
oc projects
- Switch to a namespace:
oc project <abc123-name>
- Create a service account:
oc create sa github-actions
- Create a role binding:
oc create rolebinding github-actions-edit --clusterrole=edit --serviceaccount=$(oc project -q):github-actions
- Create and copy a token. It cannot be retrieved again:
oc create token github-actions --duration=87600h
- Save it as the
OC_TOKEN secret: repository level for <plate>-dev (pull requests), or in the test / prod environment for those namespaces. To pipe it straight in without printing it:oc create token github-actions --duration=87600h | gh secret set OC_TOKEN # add --env test or --env prod for those namespaces
- Alternate steps using an inline template can be found here.
scripts/setup-openshift.sh uses the same approach: a github-actions-token Secret of type kubernetes.io/service-account-token, which doesn't expire.
- In earlier versions of OpenShift, a pipeline token secret was created automatically in each namespace.
- Reference:
${{ secrets.OC_TOKEN }}
OC_NAMESPACE
Teams will receive a set of project namespaces, usually DEV (for PRs), TEST and PROD. TOOLS namespaces (e.g. Jenkins, shared Oracle resources) are not used here. Provided by your OpenShift platform team.
- Reference:
${{ vars.OC_NAMESPACE }}
- E.g.:
abc123-dev
- Set it with
gh variable set OC_NAMESPACE --body abc123-dev (repository level, for pull requests), and --env test / --env prod with abc123-test / abc123-prod.
OC_SERVER
OpenShift API server URL for your cluster. One repository-level variable, shared by pull requests, TEST and PROD (not set per environment).
- Reference:
${{ vars.OC_SERVER }}
- Silver:
https://api.silver.devops.gov.bc.ca:6443
- Gold:
https://api.gold.devops.gov.bc.ca:6443
- Set it once at repository level, while logged in to the right cluster:
gh variable set OC_SERVER --body "$(oc whoami --show-server)"
DB_PASSWORD
The password used for the PostgreSQL database. This MUST be a strong, unique password and DISTINCT across all environments (pr, test, prod). Reusing the same password in development/PRs as in production is a critical security risk.
- Reference:
${{ secrets.DB_PASSWORD }}
- Minimum 12 characters recommended for production.
- Pro-tip: Use a password manager (like BitWarden, 1Password, or KeePass) to generate and store long, random, and unique passwords for each environment. Avoid simple, guessable passwords like
password or secure.
Optional Values
Set these by hand with gh secret set / gh variable set when you need them.
SYSDIG_API_TOKEN
Sysdig API token used to sync the PROD email-alert set on every merge. Sourced from the in-cluster Secret materialized by your SysdigTeam CR (BC Gov platform-services provisions this in your *-tools namespace). Optional — if unset, the monitor-prod step no-ops with a warning, so the deploy still succeeds.
- Reference:
${{ secrets.SYSDIG_API_TOKEN }}