Code Review
/
oom.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "[COMMON][CASSANDRA] Uses new tpls for repos / images"
[oom.git]
/
kubernetes
/
common
/
cassandra
/
templates
/
backup
/
cronjob.yaml
diff --git
a/kubernetes/common/cassandra/templates/backup/cronjob.yaml
b/kubernetes/common/cassandra/templates/backup/cronjob.yaml
index
630ac43
..
27f3cc6
100644
(file)
--- a/
kubernetes/common/cassandra/templates/backup/cronjob.yaml
+++ b/
kubernetes/common/cassandra/templates/backup/cronjob.yaml
@@
-19,11
+19,7
@@
kind: CronJob
metadata:
name: {{ include "common.fullname" . }}-backup
namespace: {{ include "common.namespace" . }}
metadata:
name: {{ include "common.fullname" . }}-backup
namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.fullname" . }}
- chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
- release: {{ .Release.Name }}
- heritage: {{ .Release.Service }}
+ labels: {{- include "common.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.backup.cron | quote }}
concurrencyPolicy: Forbid
spec:
schedule: {{ .Values.backup.cron | quote }}
concurrencyPolicy: Forbid
@@
-31,11
+27,15
@@
spec:
jobTemplate:
spec:
template:
jobTemplate:
spec:
template:
+ metadata:
+ labels: {{- include "common.labels" . | nindent 12 }}
+ annotations: {{- include "common.tplValue" (dict "value" .Values.podAnnotations "context" .) | nindent 12 }}
+ name: {{ include "common.name" . }}
spec:
restartPolicy: Never
initContainers:
- command:
spec:
restartPolicy: Never
initContainers:
- command:
- - /
root
/ready.py
+ - /
app
/ready.py
args:
- --container-name
- {{ include "common.name" . }}
args:
- --container-name
- {{ include "common.name" . }}
@@
-45,11
+45,11
@@
spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- image:
"{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
+ image:
{{ include "repositoryGenerator.image.readiness" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
name: {{ include "common.name" . }}-readiness
- name: "cassandra-backup-init"
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
name: {{ include "common.name" . }}-readiness
- name: "cassandra-backup-init"
- image:
"{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
+ image:
{{ include "repositoryGenerator.image.readiness" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
command:
- /bin/bash
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
command:
- /bin/bash
@@
-59,7
+59,7
@@
spec:
curr_time=$1
echo "Clearing snapshots!!!"
command="nodetool clearsnapshot -t $curr_time"
curr_time=$1
echo "Clearing snapshots!!!"
command="nodetool clearsnapshot -t $curr_time"
- /
root/exec.py -p "cassandra
" -c "$command"
+ /
app/exec.py -p "{{ include "common.name" . }}
" -c "$command"
}
{{ $root := . }}
curr_time=`date +%s`
}
{{ $root := . }}
curr_time=`date +%s`
@@
-75,11
+75,11
@@
spec:
echo "Executing cleanup!!"
command="nodetool cleanup"
echo "Executing cleanup!!"
command="nodetool cleanup"
- /
root/exec.py -p "cassandra" -c "$command"
+ /
app/exec.py -p "{{ include "common.name" . }}" -c "$command"
echo "Cleaned Node!! Backing up database now!!!"
command="nodetool snapshot -t $curr_time"
echo "Cleaned Node!! Backing up database now!!!"
command="nodetool snapshot -t $curr_time"
- /
root/exec.py -p "cassandra
" -c "$command"
+ /
app/exec.py -p "{{ include "common.name" . }}
" -c "$command"
retCode=$?
if [ $retCode -ne 0 ]; then
echo "Backup Failed!!!"
retCode=$?
if [ $retCode -ne 0 ]; then
echo "Backup Failed!!!"
@@
-95,9
+95,9
@@
spec:
d=$(echo $d | sed 's:/*$::')
keyspace_name=$(echo "$d" | awk -F/ '{ print $NF }')
if [ 1 ] {{- range $t, $keyspace := $root.Values.backup.keyspacesToSkip }} && [ "{{ $keyspace.name }}" != "$keyspace_name" ] {{- end }}; then
d=$(echo $d | sed 's:/*$::')
keyspace_name=$(echo "$d" | awk -F/ '{ print $NF }')
if [ 1 ] {{- range $t, $keyspace := $root.Values.backup.keyspacesToSkip }} && [ "{{ $keyspace.name }}" != "$keyspace_name" ] {{- end }}; then
- /
root
/restore.sh -b $backup_dir/cassandra-{{ $i }}/data -s /onap-data/cassandra-{{ $i }}/data/$keyspace_name -k $keyspace_name -t $curr_time &
+ /
app
/restore.sh -b $backup_dir/cassandra-{{ $i }}/data -s /onap-data/cassandra-{{ $i }}/data/$keyspace_name -k $keyspace_name -t $curr_time &
pids="$pids $!"
pids="$pids $!"
- fi
+ fi
done
{{- end }}
done
{{- end }}
@@
-121,7
+121,7
@@
spec:
echo "Failed" > /backup/backup.log
exit 0
fi
echo "Failed" > /backup/backup.log
exit 0
fi
-
+
mv /backup/temp /backup/backup-${curr_time}
echo "Success" > /backup/backup.log
echo "Cassandra Backup Succeeded"
mv /backup/temp /backup/backup-${curr_time}
echo "Success" > /backup/backup.log
echo "Cassandra Backup Succeeded"
@@
-135,19
+135,21
@@
spec:
- mountPath: /etc/localtime
name: localtime
readOnly: true
- mountPath: /etc/localtime
name: localtime
readOnly: true
- - mountPath: /onap-data
- name: data-dir
+ {{- range $i := until (int .Values.replicaCount)}}
+ - mountPath: /onap-data/cassandra-{{ $i }}
+ name: data-dir-{{ $i }}
+ {{- end }}
- mountPath: /backup
name: backup-dir
- name: scripts
- mountPath: /backup
name: backup-dir
- name: scripts
- mountPath: /
root
/restore.sh
+ mountPath: /
app
/restore.sh
subPath: restore.sh
- name: scripts
subPath: restore.sh
- name: scripts
- mountPath: /
root
/exec.py
- subPath: exec.py
+ mountPath: /
app
/exec.py
+ subPath: exec.py
containers:
- name: cassandra-backup-validate
containers:
- name: cassandra-backup-validate
- image:
"{{ .Values.image }}"
+ image:
{{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
command:
- /bin/bash
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
command:
- /bin/bash
@@
-200,7
+202,7
@@
spec:
done
kill -9 $CASS_PID
{{- end }}
done
kill -9 $CASS_PID
{{- end }}
- echo "Validation Successful!!!"
+ echo "Validation Successful!!!"
cd /backup
totalFiles=`ls -t | grep "backup-" | wc -l`
if [ $totalFiles -gt {{ .Values.backup.retentionPeriod }} ]; then
cd /backup
totalFiles=`ls -t | grep "backup-" | wc -l`
if [ $totalFiles -gt {{ .Values.backup.retentionPeriod }} ]; then
@@
-230,13
+232,14
@@
spec:
path: /etc/localtime
- name: scripts
configMap:
path: /etc/localtime
- name: scripts
configMap:
- name: {{ include "common.fullname"
$
}}-configmap
+ name: {{ include "common.fullname"
.
}}-configmap
defaultMode: 0755
defaultMode: 0755
- - name: data-dir
+ {{- range $i := until (int .Values.replicaCount)}}
+ - name: data-dir-{{ $i }}
persistentVolumeClaim:
persistentVolumeClaim:
- claimName: {{ include "common.fullname" . }}-db-data
+ claimName: {{ include "common.fullname" . }}-data-{{ $i }}
+ {{- end }}
- name: backup-dir
persistentVolumeClaim:
claimName: {{ include "common.fullname" . }}-backup-data
{{- end -}}
- name: backup-dir
persistentVolumeClaim:
claimName: {{ include "common.fullname" . }}-backup-data
{{- end -}}
-