summaryrefslogtreecommitdiffstats
path: root/kubernetes/common/cassandra
diff options
context:
space:
mode:
Diffstat (limited to 'kubernetes/common/cassandra')
-rw-r--r--kubernetes/common/cassandra/templates/backup/cronjob.yaml25
-rw-r--r--kubernetes/common/cassandra/templates/backup/pv.yaml32
-rw-r--r--kubernetes/common/cassandra/templates/backup/pvc.yaml41
-rw-r--r--kubernetes/common/cassandra/templates/pv.yaml39
-rw-r--r--kubernetes/common/cassandra/templates/statefulset.yaml21
-rw-r--r--kubernetes/common/cassandra/values.yaml6
6 files changed, 60 insertions, 104 deletions
diff --git a/kubernetes/common/cassandra/templates/backup/cronjob.yaml b/kubernetes/common/cassandra/templates/backup/cronjob.yaml
index 630ac43ba3..0d06318422 100644
--- a/kubernetes/common/cassandra/templates/backup/cronjob.yaml
+++ b/kubernetes/common/cassandra/templates/backup/cronjob.yaml
@@ -75,7 +75,7 @@ spec:
echo "Executing cleanup!!"
command="nodetool cleanup"
- /root/exec.py -p "cassandra" -c "$command"
+ /root/exec.py -p "cassandra" -c "$command"
echo "Cleaned Node!! Backing up database now!!!"
command="nodetool snapshot -t $curr_time"
@@ -97,7 +97,7 @@ spec:
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 &
pids="$pids $!"
- fi
+ fi
done
{{- end }}
@@ -121,7 +121,7 @@ spec:
echo "Failed" > /backup/backup.log
exit 0
fi
-
+
mv /backup/temp /backup/backup-${curr_time}
echo "Success" > /backup/backup.log
echo "Cassandra Backup Succeeded"
@@ -135,8 +135,10 @@ spec:
- 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
@@ -144,7 +146,7 @@ spec:
subPath: restore.sh
- name: scripts
mountPath: /root/exec.py
- subPath: exec.py
+ subPath: exec.py
containers:
- name: cassandra-backup-validate
image: "{{ .Values.image }}"
@@ -200,7 +202,7 @@ spec:
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
@@ -230,13 +232,14 @@ spec:
path: /etc/localtime
- name: scripts
configMap:
- name: {{ include "common.fullname" $ }}-configmap
+ name: {{ include "common.fullname" . }}-configmap
defaultMode: 0755
- - name: data-dir
+ {{- range $i := until (int .Values.replicaCount)}}
+ - name: data-dir-{{ $i }}
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 -}}
-
diff --git a/kubernetes/common/cassandra/templates/backup/pv.yaml b/kubernetes/common/cassandra/templates/backup/pv.yaml
index 332dc95e05..10c310077b 100644
--- a/kubernetes/common/cassandra/templates/backup/pv.yaml
+++ b/kubernetes/common/cassandra/templates/backup/pv.yaml
@@ -1,5 +1,5 @@
{{/*
-# Copyright © 2019 Amdocs, Bell Canada, AT&T
+# Copyright © 2019 Amdocs, Bell Canada, AT&T, Orange
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,25 +14,8 @@
# limitations under the License.
*/}}
{{- if .Values.backup.enabled }}
-{{ if .Values.persistence.enabled }}
-apiVersion: v1
-kind: PersistentVolume
-metadata:
- name: {{ include "common.fullname" . }}-db-data
- namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.name" . }}
- chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
- heritage: {{ .Release.Service }}
- name: {{ include "common.fullname" . }}-db-data
-spec:
- capacity:
- storage: {{ .Values.persistence.size }}
- accessModes:
- - {{ .Values.persistence.accessMode }}
- hostPath:
- path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}
- persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
+{{- if eq "True" (include "common.needPV" .) -}}
---
apiVersion: v1
kind: PersistentVolume
@@ -49,9 +32,10 @@ spec:
storage: {{ .Values.persistence.size }}
accessModes:
- {{ .Values.persistence.accessMode }}
- hostPath:
- path: {{ .Values.global.persistence.backup.mountPath | default .Values.persistence.backup.mountPath }}/{{ include "common.namespace" $ }}/{{ include "common.fullname" $ }}
persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
-{{ end }}
+ storageClassName: "{{ include "common.fullname" . }}-data"
+ hostPath:
+ path: {{ .Values.global.persistence.backup.mountPath | default .Values.persistence.backup.mountPath }}/{{ include "common.namespace" . }}/{{ include "common.fullname" . }}
+{{- end -}}
+{{- end -}}
{{- end -}}
-
diff --git a/kubernetes/common/cassandra/templates/backup/pvc.yaml b/kubernetes/common/cassandra/templates/backup/pvc.yaml
index 1f848c3315..dd7f3810a0 100644
--- a/kubernetes/common/cassandra/templates/backup/pvc.yaml
+++ b/kubernetes/common/cassandra/templates/backup/pvc.yaml
@@ -15,36 +15,6 @@
*/}}
{{- if .Values.backup.enabled }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
-kind: PersistentVolumeClaim
-apiVersion: v1
-metadata:
- name: {{ include "common.fullname" . }}-db-data
- namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.name" . }}-backup
- chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
- release: "{{ .Release.Name }}"
- heritage: "{{ .Release.Service }}"
-{{- if .Values.persistence.annotations }}
- annotations:
-{{ toYaml .Values.persistence.annotations | indent 4 }}
-{{- end }}
-spec:
- selector:
- matchLabels:
- name: {{ include "common.fullname" . }}-db-data
- accessModes:
- - {{ .Values.persistence.accessMode }}
- resources:
- requests:
- storage: {{ .Values.persistence.size }}
-{{- if .Values.persistence.storageClass }}
-{{- if (eq "-" .Values.persistence.storageClass) }}
- storageClassName: ""
-{{- else }}
- storageClassName: "{{ .Values.persistence.storageClass }}"
-{{- end }}
-{{- end }}
---
kind: PersistentVolumeClaim
apiVersion: v1
@@ -61,20 +31,11 @@ metadata:
{{ toYaml .Values.persistence.annotations | indent 4 }}
{{- end }}
spec:
- selector:
- matchLabels:
- name: {{ include "common.fullname" . }}-backup-data
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}
-{{- if .Values.persistence.storageClass }}
-{{- if (eq "-" .Values.persistence.storageClass) }}
- storageClassName: ""
-{{- else }}
- storageClassName: "{{ .Values.persistence.storageClass }}"
-{{- end }}
-{{- end }}
+ storageClassName: {{ include "common.storageClass" . }}
{{- end -}}
{{- end -}}
diff --git a/kubernetes/common/cassandra/templates/pv.yaml b/kubernetes/common/cassandra/templates/pv.yaml
index 06f41e7683..fbbb5ba105 100644
--- a/kubernetes/common/cassandra/templates/pv.yaml
+++ b/kubernetes/common/cassandra/templates/pv.yaml
@@ -12,28 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-{{ if .Values.persistence.enabled }}
-{{- $root := . -}}
-{{ range $i, $e := until (int $root.Values.replicaCount) }}
+{{- $global := . }}
+{{- if and $global.Values.persistence.enabled (not $global.Values.persistence.existingClaim) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{- range $i := until (int $global.Values.replicaCount)}}
---
apiVersion: v1
kind: PersistentVolume
metadata:
- name: {{ $root.Release.Name }}-{{ $root.Values.service.name }}-{{ $i }}
- namespace: {{ $root.Release.Namespace }}
+ name: {{ $global.Release.Name }}-{{ $global.Values.service.name }}-{{ $i }}
+ namespace: {{ $global.Release.Namespace }}
labels:
- type: {{ $root.Values.persistence.storageType }}
- app: {{ $root.Values.service.name }}
- chart: {{ $root.Chart.Name }}-{{ $root.Chart.Version | replace "+" "_" }}
- release: {{ $root.Release.Name }}
- heritage: {{ $root.Release.Service }}
+ type: {{ $global.Values.persistence.storageType }}
+ app: {{ $global.Values.service.name }}
+ chart: {{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}
+ release: {{ $global.Release.Name }}
+ heritage: {{ $global.Release.Service }}
spec:
capacity:
- storage: {{ $root.Values.persistence.size }}
+ storage: {{ $global.Values.persistence.size }}
accessModes:
- - {{ $root.Values.persistence.accessMode }}
+ {{- if $global.Values.backup.enabled }}
+ - ReadWriteMany
+ {{- else }}
+ - ReadWriteOnce
+ {{- end }}
+ persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
+ storageClassName: "{{ include "common.fullname" $global }}-data"
hostPath:
- path: {{ $root.Values.persistence.mountPath }}/{{ $root.Release.Name }}/{{ $root.Values.persistence.mountSubPath }}-{{ $i }}
- persistentVolumeReclaimPolicy: {{ $root.Values.persistence.volumeReclaimPolicy }}
-{{ end }}
-{{ end }}
+ path: {{ $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.mountSubPath }}-{{ $i }}
+{{- end -}}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/common/cassandra/templates/statefulset.yaml b/kubernetes/common/cassandra/templates/statefulset.yaml
index 4be3570851..72e886d4d1 100644
--- a/kubernetes/common/cassandra/templates/statefulset.yaml
+++ b/kubernetes/common/cassandra/templates/statefulset.yaml
@@ -49,7 +49,7 @@ spec:
- containerPort: {{ $ports.port }}
{{- end }}
volumeMounts:
- - name: cassandra-data
+ - name: {{ include "common.fullname" . }}-data
mountPath: /var/lib/cassandra
- name: localtime
mountPath: /etc/localtime
@@ -151,25 +151,26 @@ spec:
name: {{ include "common.fullname" . }}-entrypoint
defaultMode: 0755
{{- if not .Values.persistence.enabled }}
- - name: cassandra-data
+ - name: {{ include "common.fullname" . }}-data
emptyDir: {}
{{- else }}
volumeClaimTemplates:
- metadata:
- name: cassandra-data
+ name: {{ include "common.fullname" . }}-data
labels:
- app: {{ template "common.fullname" . }}
+ name: {{ include "common.fullname" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
- annotations:
- volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass }}
spec:
accessModes:
- - {{ .Values.persistence.accessMode | quote }}
+ {{- if .Values.backup.enabled }}
+ - ReadWriteMany
+ {{- else }}
+ - ReadWriteOnce
+ {{- end }}
+ storageClassName: {{ include "common.storageClass" . }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
- selector:
- matchLabels:
- release: "{{ .Release.Name }}"
{{- end }}
diff --git a/kubernetes/common/cassandra/values.yaml b/kubernetes/common/cassandra/values.yaml
index f078bd17ce..c3af7e59b2 100644
--- a/kubernetes/common/cassandra/values.yaml
+++ b/kubernetes/common/cassandra/values.yaml
@@ -37,7 +37,7 @@ debugEnabled: false
config:
cluster_domain: cluster.local
heap:
- max: 512M
+ max: 2048M
min: 100M
jvmOpts: -Dcassandra.consistent.rangemovement=false
clusterName: cassandra
@@ -115,12 +115,12 @@ persistence:
## GKE, AWS & OpenStack)
##
## storageClass: "-"
- accessMode: ReadWriteOnce
+ ## Not set as it depends of the backup enabledment or not.
+ #accessMode: ReadWriteOnce
size: 2Gi
mountPath: /dockerdata-nfs
mountSubPath: cassandra
storageType: local
- storageClass: ""
backup:
mountPath: /dockerdata-nfs/backup