Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update the backup container process #350

Merged
merged 17 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3203b16
chore: reduce dev and test backup frequency to save space
thegentlemanphysicist Dec 15, 2023
3a0e331
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Dec 15, 2023
07cac36
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Dec 15, 2023
f73a8d5
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Feb 8, 2024
6ea9314
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Feb 13, 2024
7718f5f
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Mar 12, 2024
443661d
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Mar 14, 2024
ada90eb
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Apr 4, 2024
33500a7
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Apr 9, 2024
7f77298
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist Apr 25, 2024
da518bd
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist May 2, 2024
9b4b6e7
Merge branch 'dev' of github.com:bcgov/sso-keycloak into dev
thegentlemanphysicist May 2, 2024
0012236
chore: clean up backup process and documentation
thegentlemanphysicist May 3, 2024
9db6940
chore: remove webhook template
thegentlemanphysicist May 3, 2024
3f85434
chore: update prod helm charts and remove test webhook
thegentlemanphysicist May 6, 2024
b67095c
chore: update the verification config
thegentlemanphysicist May 6, 2024
ef9b06c
chore: simplify the backup image creation action
thegentlemanphysicist May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/publish-image-backup-storage-gold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ name: Create and publish Backup Storage Docker image Gold
on:
workflow_dispatch:
inputs:
postgres_version:
description: 'The postgres version'
replace_docker_image:
description: 'Do we use a custom docker image?'
type: boolean
required: true
default: 'false'
tag_for_image:
default: 'testing'
required: true
options: ['12', '13']

env:
GITHUB_REGISTRY: ghcr.io
Expand All @@ -28,7 +32,7 @@ jobs:
run: git clone https://github.com/BCDevOps/backup-container.git

- name: Replace the dockerfile
if: ${{ github.event.inputs.postgres_version == '13'}}
if: ${{ github.event.inputs.replace_docker_image == 'true'}}
run: cp ./docker/backup-container/* ./backup-container/docker

- name: Log in to the GitHub Container registry
Expand All @@ -43,5 +47,5 @@ jobs:
with:
context: backup-container/docker
push: true
tags: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:postgres-${{ github.event.inputs.postgres_version}}
tags: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{github.event.inputs.tag_for_image}}
labels: sso-keycloak-backup
61 changes: 0 additions & 61 deletions .github/workflows/publish-image-backup-storage-test.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/publish-image-backup-storage.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker/backup-container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /
# Load the backup scripts into the container (must be executable).
COPY backup.* /

COPY webhook-template.json /
# COPY webhook-template.json /
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess their image has a template built in so we don't need this anymore?


# ========================================================================================================
# Install go-crond (from https://github.com/webdevops/go-crond)
Expand Down
62 changes: 0 additions & 62 deletions docs/bkp-and-restore-keycloak-db.md

This file was deleted.

42 changes: 28 additions & 14 deletions helm/backup-storage/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
# The sso-keycloak implementation of the backup container

## **BEFORE RUNNING HELM UPGRADE:**
As part of the backup restore process we can build and host backup-container images that our helm charts can use to deploy the container. However, currently we are using the backup container's hosted images.

Make sure to add the rocket chat webhook to production facing values files. Make sure not to commit this value.
The backup container repo we use is [here](https://github.com/BCDevOps/backup-container).

## Intro to backup container

The current patroni clusters are backud up using a modified version of the platform services backup container. This is due to an issue with the spilo patroni image.
## The verification and restore process

The backup container repo is [here](https://github.com/BCDevOps/backup-container).
Currently running backup restoration and verification againts the patroni cluster raises several errors, meaning the `-I` flag needs to be added to the verification config and restoration process. To verify a backup run:

The modified postgres plugin can be found [here](https://github.com/bcgov/sso-keycloak/blob/dev/docker/backup-container/backup.postgres.plugin).
`./backup.sh -I -v all`

A side effect of this conflict is that we cannot currently verify the daily backups with a test restoration.
To restore from a backup:

## Installing and upgrading backups
`./backup.sh -I -r sso-patroni:5432/ssokeycloak`

These charts can be upgraded using make commands:
Furhter documentation can be found in the backup container's [repos](https://github.com/BCDevOps/backup-container)

`make upgrade NAME=sso-backup NAMESPACE=<<namespace>>`
## Building the image

As of May 2024 we are using the backup-container's images directly in our deployments. However the action `.github/workflows/publish-image-backup-storage-gold.yml` allows us create a backup container image with files overridden by those in the folder `sso-keycloak/docker/backup-container/*`. We can tag the image and then use it in our helm chart via the yaml stanza:

```
image:
repository: ghcr.io/bcgov/backup-storage
tag: <<TAG NAME>>
pullPolicy: Always
```

To restore from the most recent backup, follow the docs `sso-keycloak/docs/bkp-and-restore-keycloak-db.md`
## Deploying the charts

### **BEFORE RUNNING HELM UPGRADE:**

Deprecated method left as an example: rsh into the backup pod in the namespace in question and run:
Make sure to add the rocket chat webhook to production facing values files. Make sure not to commit this value.

Make certain the image tag reflects the version of the backup container you intend to deploy.

**dev silver production**:
### Installing and upgrading backups

`./backup.sh -r postgres=sso-pgsql-dev-11-patroni:5432/rhsso`
These charts can be upgraded using make commands:

`make upgrade NAME=sso-backup NAMESPACE=<<namespace>>`
37 changes: 37 additions & 0 deletions helm/backup-storage/values-e4ca1d-dev-sso-backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
nameOverride: sso-backup-storage
fullnameOverride: sso-backup-storage

image:
repository: bcgovimages/backup-container
tag: 2.8.1
pullPolicy: Always

backupConfig: |
sso-patroni:5432/ssokeycloak
0 1 * * * default ./backup.sh -s
0 4 * * * default ./backup.sh -I -s -v all

db:
secretName: sso-patroni-appusers
usernameKey: username-appuser1
passwordKey: password-appuser1

persistence:
backup:
size: 5Gi

env:
ENVIRONMENT_FRIENDLY_NAME:
value: 'SSO Sandbox Client Dev Backup'
ENVIRONMENT_NAME:
value: e4ca1d-dev
WEBHOOK_URL:
# value: '<<WEBHOOK URL FOR ROCKETCHAT>>'
secure: true

DAILY_BACKUPS:
value: '3'
WEEKLY_BACKUPS:
value: '2'
MONTHLY_BACKUPS:
value: '1'
37 changes: 37 additions & 0 deletions helm/backup-storage/values-e4ca1d-prod-sso-backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
nameOverride: sso-backup-storage
fullnameOverride: sso-backup-storage

image:
repository: bcgovimages/backup-container
tag: 2.8.1
pullPolicy: Always

backupConfig: |
sso-patroni:5432/ssokeycloak
0 1 * * * default ./backup.sh -s
0 4 * * * default ./backup.sh -I -s -v all

db:
secretName: sso-patroni-appusers
usernameKey: username-appuser1
passwordKey: password-appuser1

persistence:
backup:
size: 5Gi

env:
ENVIRONMENT_FRIENDLY_NAME:
value: 'SSO Sandbox Client Prod Backup'
ENVIRONMENT_NAME:
value: e4ca1d-prod
WEBHOOK_URL:
# value: '<<WEBHOOK URL FOR ROCKETCHAT>>'
secure: true

DAILY_BACKUPS:
value: '3'
WEEKLY_BACKUPS:
value: '2'
MONTHLY_BACKUPS:
value: '1'
37 changes: 37 additions & 0 deletions helm/backup-storage/values-e4ca1d-test-sso-backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
nameOverride: sso-backup-storage
fullnameOverride: sso-backup-storage

image:
repository: bcgovimages/backup-container
tag: 2.8.1
pullPolicy: Always

backupConfig: |
sso-patroni:5432/ssokeycloak
0 1 * * * default ./backup.sh -s
0 4 * * * default ./backup.sh -I -s -v all

db:
secretName: sso-patroni-appusers
usernameKey: username-appuser1
passwordKey: password-appuser1

persistence:
backup:
size: 5Gi

env:
ENVIRONMENT_FRIENDLY_NAME:
value: 'SSO Sandbox Client Test Backup'
ENVIRONMENT_NAME:
value: e4ca1d-test
WEBHOOK_URL:
# value: '<<WEBHOOK URL FOR ROCKETCHAT>>'
secure: true

DAILY_BACKUPS:
value: '3'
WEEKLY_BACKUPS:
value: '2'
MONTHLY_BACKUPS:
value: '1'
Loading