Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Enmasse backup #430

Merged
merged 4 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions evals/playbooks/backup_restore/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
tasks:
- include_vars: ../../roles/3scale/defaults/main.yml
- include_vars: ../../roles/resources_backup/defaults/main.yml
- include_vars: ../../roles/enmasse/defaults/main.yml
- import_tasks: ../../roles/3scale/tasks/backup.yml
- import_tasks: ../../roles/resources_backup/tasks/main.yml
- import_tasks: ../../roles/enmasse/tasks/backup.yml
-
include_role:
name: rhsso
tasks_from: backup.yaml
tags: ['rhsso']

2 changes: 1 addition & 1 deletion evals/roles/3scale/tasks/backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
shell: oc get dc zync-database -n {{ threescale_namespace }} -o jsonpath='{ .spec.template.spec.containers[?(@.name=="postgresql")].env[?(@.name=="POSTGRESQL_DATABASE")].value }'
register: threescale_postgres_database

- name: Create the MySQL credentials secret for backup
- name: Create the Postgres credentials secret for backup
include_role:
name: backup
tasks_from: _create_postgres_secret.yml
Expand Down
5 changes: 4 additions & 1 deletion evals/roles/enmasse/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ enmasse_service_catalog: true
enmasse_keycloak_admin_password: admin
enmasse_authentication_services: ["standard"]
enmasse_clean_artifacts: true
enmasse_enable_monitoring: false
enmasse_enable_monitoring: false
enmasse_backup_postgres_secret: 'enmasse-postgres-secret'
enmasse_postgres_cronjob_name: 'enmasse-postgres-backup'
enmasse_pv_cronjob_name: 'enmasse-pv-backup'
52 changes: 52 additions & 0 deletions evals/roles/enmasse/tasks/backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# Create ServiceAccount
- name: Create ServiceAccount and role binding
include_role:
name: backup
tasks_from: _setup_service_account.yml
vars:
binding_name: enmasse_backup_binding
serviceaccount_namespace: '{{ enmasse_namespace }}'

# Postgres backup
- name: Get Postgres password
shell: oc get secret postgresql -n {{ enmasse_namespace }} -o jsonpath='{ .data.database-password }' | base64 --decode
register: enmasse_postgres_password

- name: Get Postgres username
shell: oc get secret postgresql -n {{ enmasse_namespace }} -o jsonpath='{ .data.database-user }' | base64 --decode
register: enmasse_postgres_username

- name: Get Postgres database
shell: oc get secret postgresql -n {{ enmasse_namespace }} -o jsonpath='{ .data.database-name }' | base64 --decode
register: enmasse_postgres_database

- name: Create the Postgres credentials secret for backup
include_role:
name: backup
tasks_from: _create_postgres_secret.yml
vars:
secret_name: '{{ enmasse_backup_postgres_secret }}'
secret_postgres_user: '{{ enmasse_postgres_username.stdout }}'
secret_postgres_host: postgresql.enmasse.svc
secret_postgres_database: '{{ enmasse_postgres_database.stdout }}'
secret_postgres_password: '{{ enmasse_postgres_password.stdout }}'

- name: Create the enmasse Postgres CronJob
shell: oc process -f {{ backup_resources_location }}/backup-cronjob-template.yaml \
-p 'COMPONENT=postgres' \
-p 'COMPONENT_SECRET_NAME={{ enmasse_backup_postgres_secret }}' \
-p 'BACKEND_SECRET_NAME={{ aws_credential_secret_name }}' \
-p 'IMAGE={{ backup_image }}' \
-p 'CRON_SCHEDULE={{ backup_schedule }}' \
-p 'NAME={{ enmasse_postgres_cronjob_name }}' | oc apply -n default -f -

# PV backup
- name: Create the enmasse PV CronJob
shell: oc process -f {{ backup_resources_location }}/backup-cronjob-template.yaml \
-p 'COMPONENT=enmasse_pv' \
-p 'BACKEND_SECRET_NAME={{ aws_credential_secret_name }}' \
-p 'IMAGE={{ backup_image }}' \
-p 'CRON_SCHEDULE={{ backup_schedule }}' \
-p 'NAME={{ enmasse_pv_cronjob_name }}' | oc apply -n default -f -

6 changes: 1 addition & 5 deletions evals/roles/resources_backup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
binding_name: resources_backup_binding
serviceaccount_namespace: default

# Delete the old backup cronjob in case this is a re-installation
- name: Remove old cronjob
shell: oc delete cronjob {{ resources_cronjob_name }} --ignore-not-found

# Kube resources backup backup
- name: Create the resources backup job
shell: oc process -f {{ backup_resources_location }}/backup-cronjob-template.yaml \
-p 'BACKEND_SECRET_NAME={{ backup_credentials_secret }}' \
-p 'COMPONENT=resources' \
-p 'IMAGE={{ backup_image }}' \
-p 'CRON_SCHEDULE={{ backup_schedule }}' \
-p 'NAME={{ resources_cronjob_name }}' | oc create -n default -f -
-p 'NAME={{ resources_cronjob_name }}' | oc apply -n default -f -