Skip to content

Commit d1b6467

Browse files
author
Alan Christie
committed
feat: Better recovery logic and doc tweaks
1 parent 1912046 commit d1b6467

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,21 @@ Or copy a backup file from it...
8787
When you're done, use kubectl to delete the Pod.
8888

8989
## Recovery (of a database)
90+
You can run the `site-recovery.yaml` playbook to recover data. What you need to do
91+
depends on your specific situation but typically you'll need to set suitable
92+
kubernetes and AWS/S3 variables: -
9093

9194
export K8S_AUTH_HOST=https://????
9295
export K8S_AUTH_API_KEY=????
9396
export K8S_AUTH_VERIFY_SSL=false
9497

98+
export AWS_ACCESS_KEY_ID=????
99+
export AWS_SECRET_ACCESS_KEY=????
100+
101+
And then run the playbook with your chosen parameters: -
102+
103+
ansible-playbook -e @parameters.yaml site-recovery.yaml
104+
95105
## Testing
96106
To test this repository (Normally done via GitHib Actions)
97107
we essentially employ yaml and ansible lint code. From a suitable

roles/recovery/defaults/main.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ recovery_do_not_stop_on_error: no
4141
recovery_wait_minutes: 60
4242

4343
# Database (admin) credentials are in a secret in the namespace.
44-
# The admin user and password are expected in the secret's: -
45-
# - database_admin_user
46-
# - database_admin_user_password
4744
# We just need to supply the name of the Secret.
48-
recovery_secret: postgres
45+
recovery_database_secret: database
4946

5047
# Is the recovery volume expected to be an S3 mount?
5148
recovery_volume_is_s3: no

roles/recovery/tasks/deploy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
- recovery_namespace|string|length > 0
1010
- recovery_sa|string != 'SetMe'
1111
- recovery_sa|string|length > 0
12-
- recovery_secret|string != 'SetMe'
13-
- recovery_secret|string|length > 0
12+
- recovery_database_secret|string != 'SetMe'
13+
- recovery_database_secret|string|length > 0
1414
- recovery_database_expected_count|int >= 0
1515
- recovery_latest_backup_maximum_age_h|int >= 0
1616

@@ -57,7 +57,7 @@
5757
k8s_info:
5858
kind: Secret
5959
namespace: "{{ recovery_namespace }}"
60-
name: "{{ recovery_secret }}"
60+
name: "{{ recovery_database_secret }}"
6161
register: secret_result
6262

6363
- name: Assert secret

roles/recovery/templates/job.yaml.j2

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ spec:
3333
- name: PGHOST
3434
value: '{{ recovery_host }}'
3535
- name: PGUSER
36-
valueFrom:
37-
secretKeyRef:
38-
name: {{ recovery_secret }}
39-
key: database_admin_user
36+
value: '{{ recovery_database_admin_user }}'
4037
- name: PGADMINPASS
4138
valueFrom:
4239
secretKeyRef:
43-
name: {{ recovery_secret }}
44-
key: database_admin_user_password
40+
name: {{ recovery_database_secret }}
41+
key: {{ recovery_database_secret_admin_user_password_key }}
4542
{% if recovery_do_not_stop_on_error %}
4643
- name: DO_NOT_STOP_ON_ERROR
4744
value: '1'

roles/recovery/vars/main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ wait_timeout: 600
2222
wait_for_bind: no
2323
# Volume binding timeout (seconds)
2424
bind_timeout: 60
25+
26+
# Names of kesy in the database Secret
27+
recovery_database_admin_user: postgres
28+
recovery_database_secret_admin_user_password_key: root_password

0 commit comments

Comments
 (0)