Skip to content

Commit

Permalink
Merge pull request #39 from jujaga/feature/cronupdate
Browse files Browse the repository at this point in the history
Add Database User/Password Key Parameterization to cronjob
  • Loading branch information
WadeBarnes authored Feb 25, 2020
2 parents 1c66488 + c82d84d commit 63adae7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*_DeploymentConfig.json
*_BuildConfig.json
*.local.*
*.overrides.*

# Visual Studio Code
.vscode
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ The following environment variables are defaults used by the `backup` app.
| MONTHLY_BACKUPS | 1 | When using the rolling backup strategy this value is used to determine the number of monthly (last day of the month) backups to retain before pruning. |
| BACKUP_PERIOD | 1d | Only used for Legacy Mode. Ignored when running in Cron Mode. The schedule on which to run the backups. The value is used by a sleep command and can be defined in d, h, m, or s. |
| DATABASE_SERVICE_NAME | postgresql | The name of the service/host for the *default* database target. |
| DATABASE_USER_KEY_NAME | database-user | The database user key name stored in database deployment resources specified by DATABASE_DEPLOYMENT_NAME. |
| DATABASE_PASSWORD_KEY_NAME | database-password | The database password key name stored in database deployment resources specified by DATABASE_DEPLOYMENT_NAME. |
| POSTGRESQL_DATABASE | my_postgres_db | The name of the *default* database target; the name of the database you want to backup. |
| POSTGRESQL_USER | *wired to a secret* | The username for the database(s) hosted by the `postgresql` Postgres server. The deployment configuration makes the assumption you have your database credentials stored in secrets (which you should), and the key for the username is `database-user`. The name of the secret must be provided as the `DATABASE_DEPLOYMENT_NAME` parameter to the deployment configuration template. |
| POSTGRESQL_PASSWORD | *wired to a secret* | The password for the database(s) hosted by the `postgresql` Postgres server. The deployment configuration makes the assumption you have your database credentials stored in secrets (which you should), and the key for the username is `database-password`. The name of the secret must be provided as the `DATABASE_DEPLOYMENT_NAME` parameter to the deployment configuration template. |
Expand Down Expand Up @@ -124,6 +126,8 @@ The following variables are supported in the first iteration of the backup cronj
| WEEKLY_BACKUPS | 4 | When using the rolling backup strategy this value is used to determine the number of weekly (Sun) backups to retain before pruning. |
| MONTHLY_BACKUPS | 1 | When using the rolling backup strategy this value is used to determine the number of monthly (last day of the month) backups to retain before pruning. |
| DATABASE_SERVICE_NAME | postgresql | The name of the service/host for the *default* database target. |
| DATABASE_USER_KEY_NAME | database-user | The database user key name stored in database deployment resources specified by DATABASE_DEPLOYMENT_NAME. |
| DATABASE_PASSWORD_KEY_NAME | database-password | The database password key name stored in database deployment resources specified by DATABASE_DEPLOYMENT_NAME. |
| POSTGRESQL_DATABASE | my_postgres_db | The name of the *default* database target; the name of the database you want to backup. |
| POSTGRESQL_USER | *wired to a secret* | The username for the database(s) hosted by the `postgresql` Postgres server. The deployment configuration makes the assumption you have your database credentials stored in secrets (which you should), and the key for the username is `database-user`. The name of the secret must be provided as the `DATABASE_DEPLOYMENT_NAME` parameter to the deployment configuration template. |
| POSTGRESQL_PASSWORD | *wired to a secret* | The password for the database(s) hosted by the `postgresql` Postgres server. The deployment configuration makes the assumption you have your database credentials stored in secrets (which you should), and the key for the username is `database-password`. The name of the secret must be provided as the `DATABASE_DEPLOYMENT_NAME` parameter to the deployment configuration template. |
Expand Down
22 changes: 18 additions & 4 deletions openshift/templates/backup/backup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ parameters:
description: "The name associated to the database deployment resources. In particular, this is used to wire up the credentials associated to the database."
required: true
value: "postgresql"
- name: DATABASE_USER_KEY_NAME
displayName: Database User Key Name
description:
The database user key name stored in database deployment resources specified
by DATABASE_DEPLOYMENT_NAME.
required: true
value: database-user
- name: DATABASE_PASSWORD_KEY_NAME
displayName: Database Password Key Name
description:
The database password key name stored in database deployment resources
specified by DATABASE_DEPLOYMENT_NAME.
required: true
value: database-password
- name: "BACKUP_STRATEGY"
displayName: "Backup Strategy"
description: "The strategy to use for backups; for example daily, or rolling."
Expand Down Expand Up @@ -120,7 +134,7 @@ objects:
DATABASE_SERVICE_NAME: "${DATABASE_SERVICE_NAME}"
DEFAULT_PORT: "${DATABASE_DEFAULT_PORT}"
POSTGRESQL_DATABASE: "${DATABASE_NAME}"
# BACKUP_STRATEGY: "daily"
# BACKUP_STRATEGY: "daily"
RETENTION.NUM_BACKUPS: "${NUM_BACKUPS}"
BACKUP_STRATEGY: "rolling"
RETENTION.DAILY_BACKUPS: "${DAILY_BACKUPS}"
Expand Down Expand Up @@ -150,7 +164,7 @@ objects:
containers:
- name: "${JOB_NAME}-cronjob"
image: "docker-registry.default.svc:5000/${IMAGE_NAMESPACE}/${SOURCE_IMAGE_NAME}:${TAG_NAME}"
# image: backup
# image: backup
command:
- "/bin/bash"
- "-c"
Expand Down Expand Up @@ -210,12 +224,12 @@ objects:
valueFrom:
secretKeyRef:
name: "${DATABASE_DEPLOYMENT_NAME}"
key: database-user
key: "${DATABASE_USER_KEY_NAME}"
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: "${DATABASE_DEPLOYMENT_NAME}"
key: database-password
key: "${DATABASE_PASSWORD_KEY_NAME}"
volumes:
- name: backup
persistentVolumeClaim:
Expand Down

0 comments on commit 63adae7

Please sign in to comment.