Skip to content

Commit

Permalink
Add support for logical backup
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaldivyam committed Mar 27, 2024
1 parent 8df0981 commit 7d53bf0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,75 +1,73 @@
{{ if (.Values.logicalbackup).enabled }}

{{ if (.Values.postgresql.logicalBackup).enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: postgres-logical-backup
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
schedule: {{ (.Values.logicalbackup).schedule | default "30 00 * * *" }}
schedule: {{ (.Values.postgresql.logicalBackup).schedule | default "30 00 * * *" }}
successfulJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
containers:
- name: logical-backup
image: ghcr.io/obmondo/logical-backup:latest
image: ghcr.io/obmondo/logical-backup:1.0.1
imagePullPolicy: IfNotPresent
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: LOGICAL_BACKUP_PROVIDER
value: {{ (.Values.logicalbackup).provider | default "s3" }}
- name: LOGICAL_BACKUP_S3_BUCKET_SCOPE_SUFFIX
value: {{ (.Values.logicalbackup).s3bucketscopesuffix | default "logicalBackup" }}
- name: LOGICAL_BACKUP_S3_BUCKET
value: {{ (.Values.logicalbackup).s3bucket }}
- name: PG_VERSION
value: "{{ (.Values.logicalbackup).pgversion | default "15" }}"
- name: PG_PORT
value: "{{ (.Values.logicalbackup).pgport | default "5432" }}"
- name: PGSSLMODE
value: {{ (.Values.logicalbackup).pgsslmode | default "require" }}
- name: PGHOST
value: "{{ .Values.postgresql.host }}"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.postgresql.pass }}
key: password
- name: PGPORT
value: "{{ .Values.postgresql.port | default 5432 }}"
- name: PGUSER
value: {{ (.Values.logicalbackup).pguser | default "keycloakx" }}
value: {{ .Values.postgresql.user | default "api" }}
- name: PGDATABASE
value: {{ (.Values.logicalbackup).pgdatabase | default "keycloakx" }}
value: {{ .Values.postgresql.db | default "api" }}
- name: CLUSTER_NAME_LABEL
value: {{ (.Values.logicalbackup).pgOperatorClusterName | default "keycloakx-pgsql" }}

{{- if eq .Values.logicalbackup.provider "az" }}
- name: LOGICAL_BACKUP_PROVIDER
value: "az"
- name: LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_NAME
value: {{ (.Values.logicalbackup).azurecontainer }}
- name: LOGICAL_BACKUP_AZURE_STORAGE_CONTAINER
value: {{ (.Values.logicalbackup).s3bucket }}

{{- else if eq .Values.logicalbackup.provider "s3" }}
value: {{ (.Values.postgresql.logicalBackup).pgOperatorClusterName | default "api-postgresql" }}
- name: AWS_ACCESS_KEY_ID
value: {{ (.Values.postgresql.logicalBackup).s3accesskeyid }}
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ (.Values.postgresql.logicalBackup).s3accesssecretkey }}
key: aws-secret-key
- name: PG_VERSION
value: "{{ (.Values.postgresql.logicalBackup).pgversion | default 16 }}"
- name: LOGICAL_BACKUP_S3_ENDPOINT
value: {{ (.Values.postgresql.logicalBackup).s3endpoint }}
- name: LOGICAL_BACKUP_PROVIDER
value: "s3"
- name: AWS_ACCESS_KEY_ID
value: {{ (.Values.logicalbackup).awsaccesskeyid }}
- name: LOGICAL_BACKUP_S3_BUCKET_SCOPE_SUFFIX
value: {{ (.Values.postgresql.logicalBackup).s3bucketscopesuffix | default "logicalBackup" }}
- name: LOGICAL_BACKUP_S3_REGION
value: {{ (.Values.logicalbackup).s3region }}
- name: LOGICAL_BACKUP_S3_ENDPOINT
value: {{ (.Values.logicalbackup).s3endpoint }}
{{- end }}

{{- toYaml .Values.logicalbackup.extraEnvVars | nindent 16 }}

value: {{ (.Values.postgresql.logicalBackup).s3region }}
- name: LOGICAL_BACKUP_S3_BUCKET
value: {{ (.Values.postgresql.logicalBackup).s3bucket }}
- name: LOGICAL_BACKUP_S3_RETENTION_TIME
value: {{ (.Values.postgresql.logicalBackup).retention }}
- name: POSTGRES_OPERATOR
value: cngp
resources:
limits:
cpu: "1"
memory: 500Mi
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 100Mi
memory: 128Mi
securityContext:
allowPrivilegeEscalation: true
privileged: false
Expand All @@ -78,8 +76,5 @@ spec:
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Never
serviceAccount: "{{ .Values.logicalbackup.serviceAccount | default "postgres-pod" }}"
serviceAccountName: "{{ .Values.logicalbackup.serviceAccountName | default "postgres-pod" }}"
terminationGracePeriodSeconds: 300

{{ end }}
6 changes: 5 additions & 1 deletion argocd-helm-charts/keycloakx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ keycloakx:

postgresql:
size: 4Gi
enableLogicalBackup: true
host: keycloakx-pgsql
user: keycloak
db: keycloak
logicalBackup:
enabled: true

0 comments on commit 7d53bf0

Please sign in to comment.