Skip to content

Commit a3941a4

Browse files
shubham-cmykmattrobinsonsre
authored andcommitted
[Fix] : Fix the backup and restore script and manifest (#624)
* Add : job for bacup from the redis cluster Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> * remove unwanted var rom env_vars.env Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> * fix the backup scripts Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> * docker file Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> * write manifest for easy backup and restore Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> --------- Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com> Signed-off-by: Matt Robinson <mattrobinsonsre@gmail.com>
1 parent 2e37043 commit a3941a4

File tree

15 files changed

+181
-35
lines changed

15 files changed

+181
-35
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: env-secrets
5+
namespace: default
6+
type: Opaque
7+
stringData:
8+
CLUSTER_NAME: redis-cluster
9+
CLUSTER_NAMESPACE: default
10+
RESTIC_PASSWORD: abc@123
11+
RESTIC_CACHE_DIR: "/tmp/restic_cache"
12+
REDIS_PORT: "6379"
13+
REDIS_PASSWORD: ""
14+
BACKUP_DESTINATION: AWS_S3
15+
AWS_S3_BUCKET: shubham-redis
16+
AWS_DEFAULT_REGION: ap-south-1
17+
AWS_ACCESS_KEY_ID: ""
18+
AWS_SECRET_ACCESS_KEY: ""
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: redis-operator-backup-job
5+
namespace: default
6+
spec:
7+
template:
8+
metadata:
9+
name: redis-operator-backup-pod
10+
spec:
11+
serviceAccountName: backup-service-account
12+
containers:
13+
- name: redis-operator-backup-container
14+
image: "quay.io/opstree/redis-operator-backup:v0.15.1"
15+
command: ["/bin/bash", "-c", "/backup/backup.bash"]
16+
imagePullPolicy: Always
17+
envFrom:
18+
- secretRef:
19+
name: env-secrets
20+
restartPolicy: Never
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: backup-role-binding
5+
subjects:
6+
- kind: ServiceAccount
7+
name: backup-service-account
8+
roleRef:
9+
kind: Role
10+
name: modify-pods
11+
apiGroup: rbac.authorization.k8s.io
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: modify-pods
5+
rules:
6+
- apiGroups: ["*"]
7+
resources: ["*"]
8+
verbs: ["*"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: backup-service-account
File renamed without changes.

example/v1beta2/backup_restore/env-secret.yaml renamed to example/v1beta2/backup_restore/restore/env-secret.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ stringData:
1010
DEFAULT_FILE_PATH: /data/dump.rdb
1111
RESTIC_PASSWORD: abc@123
1212
RESTIC_CACHE_DIR: "/tmp/restic_cache"
13-
DEFAULT_REDIS_HOST: redis-cluster-leader-0
14-
DEFAULT_REDIS_PORT: "6379"
15-
DEFAULT_REDIS_PASSWORD: ""
1613
BACKUP_DESTINATION: AWS_S3
1714
AWS_S3_BUCKET: shubham-redis
1815
AWS_DEFAULT_REGION: ap-south-1

example/v1beta2/backup_restore/redis-cluster.yaml renamed to example/v1beta2/backup_restore/restore/redis-cluster.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec:
2727
# - name: regcred
2828
initContainer:
2929
enabled: true
30-
image: shubham192001/restore:latest
30+
image: quay.io/opstree/redis-operator-restore:latest
3131
imagePullPolicy: Always
3232
command: ["/bin/bash", "-c", "/app/restore.bash"]
3333
resources:
@@ -63,21 +63,6 @@ spec:
6363
secretKeyRef:
6464
name: env-secrets
6565
key: RESTIC_CACHE_DIR
66-
- name: DEFAULT_REDIS_HOST
67-
valueFrom:
68-
secretKeyRef:
69-
name: env-secrets
70-
key: DEFAULT_REDIS_HOST
71-
- name: DEFAULT_REDIS_PORT
72-
valueFrom:
73-
secretKeyRef:
74-
name: env-secrets
75-
key: DEFAULT_REDIS_PORT
76-
- name: DEFAULT_REDIS_PASSWORD
77-
valueFrom:
78-
secretKeyRef:
79-
name: env-secrets
80-
key: DEFAULT_REDIS_PASSWORD
8166
- name: BACKUP_DESTINATION
8267
valueFrom:
8368
secretKeyRef:
@@ -138,6 +123,7 @@ spec:
138123
resources:
139124
requests:
140125
storage: 1Gi
126+
nodeConfVolume: true
141127
nodeConfVolumeClaimTemplate:
142128
spec:
143129
accessModes: ["ReadWriteOnce"]

example/v1beta2/redis-cluster.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
runAsUser: 1000
1212
fsGroup: 1000
1313
kubernetesConfig:
14-
image: quay.io/opstree/redis:v7.0.5
14+
image: quay.io/opstree/redis:v7.0.11
1515
imagePullPolicy: IfNotPresent
1616
resources:
1717
requests:
@@ -64,6 +64,7 @@ spec:
6464
resources:
6565
requests:
6666
storage: 1Gi
67+
nodeConfVolume: true
6768
nodeConfVolumeClaimTemplate:
6869
spec:
6970
accessModes: ["ReadWriteOnce"]

scripts/backup/Dockerfile.kubectlpod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ RUN curl -LO "https://dl.k8s.io/$(cat stable.txt)/bin/linux/amd64/kubectl"
1515
RUN chmod +x kubectl
1616
RUN mv kubectl /usr/local/bin/
1717

18-
COPY backup-user.bash /backup
19-
# COPY backup.bash /backup
18+
# COPY backup-user.bash /backup/backup-user.bash
19+
# COPY backup.bash /backup/backup.bash
20+
COPY backup-v0.15.1.bash /backup/backup.bash
21+
22+
# Make the script executable
23+
RUN chmod +x /backup/backup.bash
24+
# RUN chmod +x /backup/backup-user.bash
2025
# COPY env_vars.env /backup

0 commit comments

Comments
 (0)