The Dockerized application is deployed to OpenShift using Makefile targets and YAML templates defined in the openshift directory.
To create the resources required to run the application in OpenShift, run make server-create. Optionally, a namespace prefix and/or suffix can be provided to target a namespace other than the default rupaog-dev, e.g. NAMESPACE_SUFFIX=test make server-create.
The OpenShift objects created are defined in the openshift/server.bc.yml and openshift/server.dc.yml. At a high level, these objects include the following:
| Object | Function |
|---|---|
| Build Config | Defines how an image is built. Properties such as build strategy (Docker), repository (the very repository you're looking at), and rebuild triggers are defined within this object. |
| Image Stream | Defines a stream of built images. Essentially, this is an image repository similar to DockerHub. Images sent to the Image Stream must be tagged (e.g. latest). |
| Service | Defines a hostname for a particular service exposed by a pod or set of pods. Services can only be seen and consumed by pods within the same OpenShift namespace. The service published by the HCAP application is the backend API endpoint. Similarly, the database will expose a service that is to be consumed by the application backend. |
| Route | Exposes a service to the Internet. Routes differ from services in that they may only transmit HTTP(S) traffic. As such, the database service could not be directly exposed to the Internet. |
| Deployment Config | Defines how a new version of an application is to be deployed. Additionally, triggers for redeployment are defined within this object. For the HCAP application, we've used a rolling deployment triggered by new images pushed to the image stream and tagged with the latest tag. |
| Secret | Defines values that can be used by pods within in the same namespace. While there are no secrets defined in our server application, there is a reference to a secret defined by the MongoDB database template. In order for the server to access the DB, it must be provided with MONGODB_DATABASE and MONGODB_URI environment variables. The definition for these environment variables can be found in the server deployment config template. Note that they are referencing the ${APP_NAME}-mongodb (resolves to hcap-mongodb) secret and the mongo-url and database keys within this secret. |
The application uses a branch-based deployment strategy for development and test environments, and a tag-based approach for production.
When making changes to OpenShift configuration files (in the openshift/ directory), the deployment workflows automatically:
- Test Phase: Validate configurations using
make server-config-testandmake cron-job-test - Apply Phase: Deploy server configurations and cronjobs using
make server-configandmake cron-job
This ensures that both application deployment configurations and scheduled job configurations are properly tested and deployed together.
Deployments to the development environment can be triggered by these 3 approaches:
- Creating and merging a PR to the
dev-envbranch - Manually triggering the "OpenShift Deploy/Promotion to Dev" workflow in GitHub Actions
- Using the Makefile command for quick deployments without a PR:
# Deploy your current branch to dev
make deploy-to-dev ticket=BCMOHAM-12345This command will:
- Get your current branch name
- Force push your current branch to the remote
dev-envbranch - Trigger the GitHub Actions workflow for deployment to dev
Automatic Infrastructure Updates: When OpenShift configuration files are modified, the workflow will automatically test and apply both server configuration and cronjob changes to ensure consistency.
Deployments to the test environment follow a more controlled process:
- Create a PR from
dev-envtotest-env - Get the PR reviewed and approved by the team
- Merge the approved PR to update the
test-envbranch - Go to GitHub Actions
- Select "OpenShift Deploy/Promotion to Test" workflow
- Click "Run workflow"
- Enter the ticket number (e.g., BCMOHAM-12345) in the reason field
- Select the branch (
test-env) - Submit the workflow
- Wait for environment approval and deployment completion
Test deployments require:
- The ticket number
- PR approval from authorized team members
- Manual workflow trigger with proper documentation
- Final environment approval in GitHub Actions
Infrastructure Change Handling: If your deployment includes changes to files in the openshift/ directory, the workflow will automatically:
- Run validation tests (
server-config-testandcron-job-test) - Apply server deployment configuration updates
- Update scheduled cronjob configurations
- Ensure all infrastructure changes are deployed consistently
Production deployments use a tag-based approach and require environment approval:
# Use the Makefile command
make tag-prod ticket=HCAP-123This command will:
- Create a tag named
prodpointing to your current commit - Push it to the remote repository
- Trigger the "OpenShift Deploy/Promotion to Production" workflow
Production Deployment Process:
- Automatic Trigger: Pushing the
prodtag automatically starts the deployment workflow - Environment Protection: The workflow requires approval from authorized production environment reviewers
- Infrastructure Validation: If OpenShift configuration files have changed, the workflow will:
- Run
make server-config-testandmake cron-job-testfor validation - Apply configuration changes using
make server-configandmake cron-job
- Run
- Application Deployment: Execute
make server-deployto deploy the tagged version - Notification: Send deployment status to Microsoft Teams channel
Production deployments require:
- Authorized tag creation (typically restricted to senior developers/leads)
- Environment approval from production reviewers
- All OpenShift configuration changes are automatically tested and applied
- Deployment timeout is limited to 6 minutes with concurrency controls
Currently, the domain is a custom domain ordered from IMS. Please follow the renewal process outlined in Request a domain renewal or transfer to renew the cert.
If a new cert is needed, please make sure to add CNAME of console.apps.silver.devops.gov.bc.ca for all required URL.
Dev and Test domains are bundled under the same cert, as in all dev.-prefixed URLs are ordered under the same CSR as Common Name (CN) and Subject Alternative Names (SANs). You only need to renew 1 cert for DEV and 1 cert for TEST.
After getting the certs from the renewal process, please use the following format for creating the Routes:
tls:
termination: edge
certificate: |-
-----BEGIN CERTIFICATE-----
url.txt
-----END CERTIFICATE-----
key: |-
-----BEGIN PRIVATE KEY-----
.key
-----END PRIVATE KEY-----
caCertificate: |-
-----BEGIN CERTIFICATE-----
TLSChain.txt
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
TrustedRoot.txt
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
TLSRoot.txt
-----END CERTIFICATE-----
insecureEdgeTerminationPolicy: Redirect