Skip to content

Commit

Permalink
one shot backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Dec 11, 2023
1 parent 25e5653 commit 840510d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 34 deletions.
60 changes: 60 additions & 0 deletions k8s/backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
- name: "Execute a one shot backup of Squest"
hosts: localhost
gather_facts: true

tasks:
- name: Generate job name
ansible.builtin.set_fact:
job_name: backup-{{ ansible_date_time.date }}

- name: Create Job from backup cronjob
shell: "kubectl --namespace {{ squest_namespace }} create job --from=cronjob/squest-backup {{ job_name }}"
environment:
KUBECONFIG: "{{ k8s_kubeconfig_path }}"
register: register_backup
failed_when:
- register_backup.rc != 0
- '"already exists" not in register_backup.stdout'

- name: Wait until backup complete
kubernetes.core.k8s_info:
kubeconfig: "{{ k8s_kubeconfig_path }}"
api_version: "batch/v1"
kind: Job
name: "{{ job_name }}"
namespace: "{{ squest_namespace }}"
wait: yes
wait_sleep: 10
wait_timeout: 120
wait_condition:
type: Complete
status: "True"

- when: squest_django.externalize_backup_via_rsync.enabled
block:
- name: Generate job name
ansible.builtin.set_fact:
job_name: rsync-backup-{{ ansible_date_time.date }}

- name: Create Job from rsync backup cronjob
shell: "kubectl --namespace {{ squest_namespace }} create job --from=cronjob/squest-rsync-backup {{ job_name }}"
environment:
KUBECONFIG: "{{ k8s_kubeconfig_path }}"
register: register_backup
failed_when:
- register_backup.rc != 0
- '"already exists" not in register_backup.stdout'

- name: Wait until rsync backup complete
kubernetes.core.k8s_info:
kubeconfig: "{{ k8s_kubeconfig_path }}"
api_version: "batch/v1"
kind: Job
name: "{{ job_name }}"
namespace: "{{ squest_namespace }}"
wait: yes
wait_sleep: 10
wait_timeout: 120
wait_condition:
type: Complete
status: "True"
68 changes: 34 additions & 34 deletions k8s/squest_k8s/files/redis.operator.v1.2.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,37 +143,37 @@ spec:
app: redisoperator
---

#apiVersion: monitoring.coreos.com/v1
#kind: ServiceMonitor
#metadata:
# name: redis-operator-metrics
# namespace: redis-operator
# labels:
# app: redisoperator
# release: prometheus
#spec:
# selector:
# matchLabels:
# app: redisoperator
# endpoints:
# - port: metrics
# namespaceSelector:
# matchNames:
# - redis-operator
#---
#
#
#apiVersion: monitoring.coreos.com/v1
#kind: PodMonitor
#metadata:
# name: redisoperator
# namespace: redis-operator
# labels:
# app: redisoperator
# release: prometheus
#spec:
# selector:
# matchLabels:
# app: redisoperator
# podMetricsEndpoints:
# - port: metrics
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: redis-operator-metrics
namespace: redis-operator
labels:
app: redisoperator
release: prometheus
spec:
selector:
matchLabels:
app: redisoperator
endpoints:
- port: metrics
namespaceSelector:
matchNames:
- redis-operator
---


apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: redisoperator
namespace: redis-operator
labels:
app: redisoperator
release: prometheus
spec:
selector:
matchLabels:
app: redisoperator
podMetricsEndpoints:
- port: metrics

0 comments on commit 840510d

Please sign in to comment.