Merge "[CPS] New Delhi release changes"
[oom.git] / kubernetes / common / cassandra / templates / backup / cronjob.yaml
index f536be5..6db1202 100644 (file)
@@ -13,8 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 */}}
-{{- $global := . }}
 {{- if .Values.backup.enabled }}
+{{- if .Values.global.cassandra.useOperator }}
+{{ else }}
 apiVersion: batch/v1beta1
 kind: CronJob
 metadata:
@@ -36,9 +37,9 @@ spec:
           restartPolicy: Never
           initContainers:
             - command:
-              - /root/ready.py
+              - /app/ready.py
               args:
-              - --container-name
+              - --app-name
               - {{ include "common.name" . }}
               env:
               - name: NAMESPACE
@@ -46,21 +47,35 @@ spec:
                   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
+              resources:
+                limits:
+                  cpu: "100m"
+                  memory: "500Mi"
+                requests:
+                  cpu: "3m"
+                  memory: "20Mi"
             - name: "cassandra-backup-init"
-              image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
+              image: {{ include "repositoryGenerator.image.readiness" . }}
               imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+              resources:
+                limits:
+                  cpu: "100m"
+                  memory: "500Mi"
+                requests:
+                  cpu: "3m"
+                  memory: "20Mi"
               command:
-              - /bin/sh
+              - /bin/bash
               - -c
               - |
                 clearSnapshot(){
                   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`
@@ -76,11 +91,11 @@ spec:
 
                 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"
-                /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!!!"
@@ -96,7 +111,7 @@ 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
-                      /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 $!"
                     fi
                   done
@@ -133,9 +148,6 @@ spec:
                     apiVersion: v1
                     fieldPath: metadata.namespace
               volumeMounts:
-              - mountPath: /etc/localtime
-                name: localtime
-                readOnly: true
               {{- range $i := until (int .Values.replicaCount)}}
               - mountPath: /onap-data/cassandra-{{ $i }}
                 name: data-dir-{{ $i }}
@@ -143,14 +155,14 @@ spec:
               - mountPath: /backup
                 name: backup-dir
               - name: scripts
-                mountPath: /root/restore.sh
+                mountPath: /app/restore.sh
                 subPath: restore.sh
               - name: scripts
-                mountPath: /root/exec.py
+                mountPath: /app/exec.py
                 subPath: exec.py
           containers:
             - name: cassandra-backup-validate
-              image: "{{ .Values.image }}"
+              image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
               imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
               command:
               - /bin/bash
@@ -224,13 +236,7 @@ spec:
               volumeMounts:
               - name: backup-dir
                 mountPath: /backup
-              - name: localtime
-                mountPath: /etc/localtime
-                readOnly: true
           volumes:
-          - name: localtime
-            hostPath:
-              path: /etc/localtime
           - name: scripts
             configMap:
               name: {{ include "common.fullname" . }}-configmap
@@ -238,9 +244,10 @@ spec:
           {{- range $i := until (int .Values.replicaCount)}}
           - name: data-dir-{{ $i }}
             persistentVolumeClaim:
-              claimName: {{ include "common.fullname" $global }}-data-{{ include "common.fullname" $global }}-{{ $i }} 
+              claimName: {{ include "common.fullname" . }}-data-{{ $i }}
           {{- end }}
           - name: backup-dir
             persistentVolumeClaim:
               claimName: {{ include "common.fullname" . }}-backup-data
 {{- end -}}
+{{- end -}}
\ No newline at end of file