Skip to content

Commit

Permalink
fix: 🐛 handle cnpg backups deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-tobi committed Jun 7, 2024
1 parent 9d5165c commit 5563dd9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions roles/console-dso/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@
secretAccessKey: "{{ dsc.global.backup.cnpg.s3Credentials.secretAccessKey.value | b64encode }}"
when: dsc.global.backup.cnpg.enabled

- name: Remove cnpg scheduled backup
kubernetes.core.k8s:
api_version: v1
kind: ScheduledBackup
namespace: "{{ dsc.console.namespace }}"
name: pg-cluster-console
state: absent
when: not dsc.global.backup.cnpg.enabled

- name: Set path fact
ansible.builtin.set_fact:
path: "{{ role_path + '/templates/values' }}"
Expand Down
9 changes: 9 additions & 0 deletions roles/harbor/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
secretAccessKey: "{{ dsc.global.backup.cnpg.s3Credentials.secretAccessKey.value | b64encode }}"
when: dsc.global.backup.cnpg.enabled

- name: Remove cnpg scheduled backup
kubernetes.core.k8s:
api_version: v1
kind: ScheduledBackup
namespace: "{{ dsc.harbor.namespace }}"
name: pg-cluster-harbor
state: absent
when: not dsc.global.backup.cnpg.enabled

- name: Create PostgreSQL cluster and harbor database
kubernetes.core.k8s:
template: pg-cluster-harbor.yaml.j2
Expand Down
2 changes: 2 additions & 0 deletions roles/harbor/templates/pg-cluster-harbor.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ spec:
backupOwnerReference: self
cluster:
name: pg-cluster-harbor
{% else %}
backup: null
{% endif %}
19 changes: 19 additions & 0 deletions roles/keycloak/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
secretAccessKey: "{{ dsc.global.backup.cnpg.s3Credentials.secretAccessKey.value | b64encode }}"
when: dsc.global.backup.cnpg.enabled

- name: Remove cnpg scheduled backup
kubernetes.core.k8s:
api_version: v1
kind: ScheduledBackup
namespace: "{{ dsc.keycloak.namespace }}"
name: pg-cluster-keycloak
state: absent
when: not dsc.global.backup.cnpg.enabled

- name: Create PostgreSQL cluster and keycloak database
kubernetes.core.k8s:
template: pg-cluster-keycloak.yaml.j2
Expand Down Expand Up @@ -128,6 +137,16 @@
release_namespace: "{{ dsc.keycloak.namespace }}"
values: "{{ kc_values }}"

- name: Wait Keycloak URL
ansible.builtin.uri:
url: https://{{ keycloak_domain }}
validate_certs: "{{ dsc.exposedCA.type == 'none' }}"
method: GET
return_content: false
register: kc_response

- debug: msg="{{ kc_response }}"

- name: Wait Keycloak URL
ansible.builtin.uri:
url: https://{{ keycloak_domain }}
Expand Down
2 changes: 2 additions & 0 deletions roles/keycloak/templates/pg-cluster-keycloak.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ spec:
backupOwnerReference: self
cluster:
name: pg-cluster-keycloak
{% else %}
backup: null
{% endif %}
9 changes: 9 additions & 0 deletions roles/sonarqube/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
secretAccessKey: "{{ dsc.global.backup.cnpg.s3Credentials.secretAccessKey.value | b64encode }}"
when: dsc.global.backup.cnpg.enabled

- name: Remove cnpg scheduled backup
kubernetes.core.k8s:
api_version: v1
kind: ScheduledBackup
namespace: "{{ dsc.sonarqube.namespace }}"
name: pg-cluster-sonar
state: absent
when: not dsc.global.backup.cnpg.enabled

- name: Create PostgreSQL cluster and sonar database
kubernetes.core.k8s:
template: pg-cluster-sonar.yaml.j2
Expand Down
2 changes: 2 additions & 0 deletions roles/sonarqube/templates/pg-cluster-sonar.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ spec:
backupOwnerReference: self
cluster:
name: pg-cluster-sonar
{% else %}
backup: null
{% endif %}

0 comments on commit 5563dd9

Please sign in to comment.