Skip to content

Commit

Permalink
Merge pull request #53 from bcgov/dev
Browse files Browse the repository at this point in the history
Release to prod
  • Loading branch information
timwekkenbc authored Nov 12, 2024
2 parents da37974 + 62e16e9 commit 59ed523
Show file tree
Hide file tree
Showing 40 changed files with 2,124 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:

- name: Run Helm
run: |
helm upgrade --install brms-api ./helm --set image.tag=${{ needs.build_image.outputs.image_tag }}
helm upgrade --install brm-backend ./helm --set image.tag=${{ needs.build_image.outputs.image_tag }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BRMS API/Backend
# BRM (Business Rules Management) Backend

This project is the API/Backend for the SDPR Business Rules Engine (BRE) and Business Rules Engine Management System (BRMS). It will act primarly as the backend for the [frontend simulator](https://github.com/bcgov/brms-simulator-frontend).
This project is the Backend for the SDPR Business Rules Engine (BRE) and [BRM App](https://github.com/bcgov/brm-app).

## Local Development Setup

Expand Down
99 changes: 99 additions & 0 deletions backups/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# backup-storage

Helm chart to deploy the `bcgov/backup-container` solution.

Original README and helm chart can be found here: https://github.com/bcgov/helm-charts/tree/master/charts/backup-storage

This is a customized version of the original readme and value.yaml files for the BRM Application.

See: https://github.com/BCDevOps/backup-container for the code.

## Chart Details

This chart will do the following:

- Deploy a backup solution for a mongoDB database.

## Installing the Chart

To install the chart with the release name `bre-db-backup` and the customized values.yaml file:

```bash
$ helm repo add bcgov https://bcgov.github.io/helm-charts
$ helm install bre-db-backup -f values.yaml bcgov/backup-storage
```

## Updating the Chart

To update the chart with the release name `bre-db-backup` and the customized values.yaml file:

```bash
$ helm repo update
$ helm upgrade bre-db-backup -f values.yaml bcgov/backup-storage
```

## Configuration

The following tables list the configurable parameters of the `backup-storage` chart and their default values.

| Parameter | Description | Default |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------- |
| `backupConfig ` | Backup config details | See below |
| `persistence.backup.mountPath ` | Where the volume for storing backups is mounted | /backups/ |
| `persistence.backup.claimName ` | If the PVC is created outside the chart, specify the name here | |
| `persistence.backup.size ` | To create the PVC, omit the `claimName` and specify the size | |
| `persistence.backup.storageClassName ` | To create the PVC, omit the `claimName` and specify the storageClassName | netapp-block-standard |
| `persistence.backup.storageAccessMode ` | PVC [access mode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) | ReadWriteOnce |
| `persistence.verification.mountPath ` | Where the volume for the verification database is mounted | /var/lib/mongodb/data |
| `persistence.verification.claimName ` | If the PVC is created outside the chart, specify the name here | |
| `persistence.verification.size ` | To create the PVC, omit the `claimName` and specify the size | |
| `persistence.verification.storageClassName ` | To create the PVC, omit the `claimName` and specify the storageClassName | netapp-block-standard |
| `persistence.verification.storageAccessMode ` | PVC [access mode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) | ReadWriteOnce |
| `db.secretName ` | The secret that has the database credentials | |
| `db.usernameKey ` | The key in the secret that has the db username | |
| `db.passwordKey ` | The key in the secret that has the db password | |
| `env.* ` | Environment variables for the solution - see `values.yaml` | |
| `env.MONGODB_AUTHENTICATION_DATABASE ` | This is only required if you are backing up mongo database with a separate authentication database. | |
| `env.MSSQL_SA_PASSWORD ` | The database password to use for the local backup database. | |
| `env.TABLE_SCHEMA ` | The table schema for your database. Used for Postgres backups. | |
| `env.BACKUP_STRATEGY ` | The strategy to use for backups; for example daily, or rolling. | rolling |
| `env.FTP_SECRET_KEY ` | The FTP secret key is used to wire up the credentials associated to the FTP. | |
| `env.FTP_URL ` | The URL of the backup FTP server | |
| `env.FTP_USER ` | FTP user name | |
| `env.FTP_PASSWORD ` | FTP password | |
| `env.WEBHOOK_URL ` | The URL of the webhook to use for notifications. If not specified, the webhook integration feature is disabled. | |
| `env.ENVIRONMENT_FRIENDLY_NAME ` | The human readable name of the environment. This variable is used by the webhook integration to identify the environment in which the backup notifications originate. | |
| `env.ENVIRONMENT_NAME ` | The name or Id of the environment. This variable is used by the webhook integration to identify the environment in which the backup notifications originate. | |
| `env.BACKUP_DIR ` | The name of the root backup directory. The backup volume will be mounted to this directory. | /backups/ |
| `env.BACKUP_CONF ` | Location of the backup configuration file | /conf/backup.conf |
| `env.NUM_BACKUPS ` | Used for backward compatibility only. Ignored when using the recommended `rolling` backup strategy. The number of backup files to be retained. Used for the `daily` backup strategy. | |
| `env.DAILY_BACKUPS ` | The number of daily backup files to be retained. Used for the `rolling` backup strategy. | 12 |
| `env.WEEKLY_BACKUPS ` | The number of weekly backup files to be retained. Used for the `rolling` backup strategy. | 8 |
| `env.MONTHLY_BACKUPS ` | The number of monthly backup files to be retained. Used for the `rolling` backup strategy. | 6 |

The `env.*` format follows:

```
ENV_VAR_NAME:
value: "ENV_VAR_VALUE"
secure: false
```

The `secure` parameter is by default `false`; if it set to `true` then the value will be put into a secret and referenced in the deployment.

**backup.conf**:
The backup.conf file is used to configure the backup schedules. The default schedule is set to run every day at 1:00 AM. The schedule can be changed by modifying the values.yaml file. The two different environments can be specified by using the following syntax:
Production: mongo=brms-db:27017/brms-db
Development: mongo=brms-db:27017/nest

Example:

```
backupConfig: |
mongo=brms-db:27017/brms-db
0 1 * * * default ./backup.sh -s
0 4 * * * default ./backup.sh -s -v all
```

**Volume Claims:** Please note, when using the recommended nfs-backup storage class the name of the pvc MUST be taken from the manually provisioned claim; nfs-backup storage MUST be provisioned manually.
101 changes: 101 additions & 0 deletions backups/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Default values for backup-storage for the BRM db.
# Declare variables to be passed into the templates.

image:
repository: bcgovimages/backup-container-mongo
pullPolicy: IfNotPresent
tag: latest

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

backupConfig: |-
mongo=brms-db:27017/brms-db
0 1 * * * default ./backup.sh -s
0 4 * * * default ./backup.sh -s -v all
config: []

persistence:
backup:
claimName: brms-db-backup
mountPath: /backups/
verification:
size: 1Gi
mountPath: /var/lib/mongodb/data
storageClassName: netapp-file-standard
storageAccessMode: ReadWriteOnce

db:
secretName: brms-db
usernameKey: database-admin
passwordKey: database-admin-password

env:
BACKUP_STRATEGY:
value: "rolling"
secure: false
BACKUP_DIR:
value: "/backups/"
BACKUP_CONF:
value: "/conf/backup.conf"
NUM_BACKUPS:
value: ""
DAILY_BACKUPS:
value: "12"
WEEKLY_BACKUPS:
value: "8"
MONTHLY_BACKUPS:
value: "6"
BACKUP_PERIOD:
value: ""
MONGODB_AUTHENTICATION_DATABASE:
value: "admin"
MSSQL_SA_PASSWORD:
value: ""
secure: true
TABLE_SCHEMA:
value: ""
FTP_URL:
value: ""
secure: true
FTP_USER:
value: ""
secure: true
FTP_PASSWORD:
value: ""
secure: true
WEBHOOK_URL:
value: ""
secure: true
ENVIRONMENT_NAME:
value: ""
ENVIRONMENT_FRIENDLY_NAME:
value: ""

serviceAccount:
create: true
annotations: {}
name: ""

podAnnotations: {}

podSecurityContext: {}

securityContext: {}

resources:
limits:
cpu: 375m
memory: 192Mi
requests:
cpu: 75m
memory: 96Mi

nodeSelector: {}

tolerations: []

affinity: {}
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v2
name: brms-api
description: A Helm chart for deploying brms-api
name: brm-backend
description: A Helm chart for deploying brm-backend
version: 0.1.0
28 changes: 22 additions & 6 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: brms-api
name: brm-backend
labels:
app.kubernetes.io/name: brms-api
app.kubernetes.io/name: brm-backend
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: brms-api
app.kubernetes.io/name: brm-backend
template:
metadata:
labels:
app.kubernetes.io/name: brms-api
app.kubernetes.io/name: brm-backend
annotations:
helm.sh/release: "{{ .Release.Name }}"
helm.sh/revision: "{{ .Release.Revision }}"
spec:
containers:
- name: brms-api
- name: brm-backend
image: '{{ .Values.image.tag }}'
ports:
- containerPort: 8080
resources: {}
resources:
limits:
cpu: 300m
memory: 750Mi
requests:
cpu: 200m
memory: 512Mi
readinessProbe:
httpGet:
path: /api/ruleData/list?page=1&pageSize=10
port: 3000
scheme: HTTP
initialDelaySeconds: 10
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
Expand Down
6 changes: 3 additions & 3 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: brms-api
name: brm-backend
labels:
app.kubernetes.io/name: brms-api
app.kubernetes.io/name: brm-backend
spec:
selector:
app.kubernetes.io/name: brms-api
app.kubernetes.io/name: brm-backend
ports:
- protocol: TCP
port: 3000
Expand Down
Loading

0 comments on commit 59ed523

Please sign in to comment.