[AAF] v1.16+ compatible templates

Use the different "common" templates in order to create consistent and
v1.16+ compatible templates for the different resources of AAF

Issue-ID: AAF-1122
Issue-ID: OOM-1971
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: Iefc1391211a69b6584ea127066ce430d4f5eb389
diff --git a/kubernetes/aaf/charts/aaf-cass/templates/deployment.yaml b/kubernetes/aaf/charts/aaf-cass/templates/deployment.yaml
index eb785e2..309a9f3 100644
--- a/kubernetes/aaf/charts/aaf-cass/templates/deployment.yaml
+++ b/kubernetes/aaf/charts/aaf-cass/templates/deployment.yaml
@@ -1,4 +1,5 @@
 # Copyright © 2017 Amdocs, Bell Canada
+# Modifications © 2020 Orange
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,23 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: extensions/v1beta1
+apiVersion: apps/v1
 kind: Deployment
-metadata:
-  name: {{ include "common.fullname" . }}
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ include "common.release" . }}
-    heritage: {{ .Release.Service }}
+metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
 spec:
-  replicas: {{ .Values.global.aaf.cass.replicas }}
+  selector: {{- include "common.selectors" . | nindent 4 }}
+  replicas: {{ .Values.replicaCount }}
   template:
-    metadata:
-      labels:
-        app: {{ include "common.name" . }}
-        release: {{ include "common.release" . }}
+    metadata: {{- include "common.templateMetadata" . | nindent 6 }}
     spec:
       initContainers:
       - name: fix-permission
@@ -37,47 +29,38 @@
         args:
         - -c
         - |
-          chmod -R 775 /opt/app/aaf/status
           chown -R 1000:1000 /opt/app/aaf/status
-          chmod -R 775 /var/lib/cassandra
           chown -R 1000:1000 /var/lib/cassandra
         image: "{{ .Values.global.busyboxRepository }}/{{ .Values.global.busyboxImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         volumeMounts:
-          - mountPath: /opt/app/aaf/status
-            name: aaf-status-vol
           - mountPath: /var/lib/cassandra
             name: aaf-cass-vol
+        resources:
+          limits:
+            cpu: 100m
+            memory: 100Mi
+          requests:
+            cpu: 30m
+            memory: 100Mi
       containers:
       - name: {{ include "common.name" . }}
-        image: {{ .Values.global.repository }}/{{.Values.global.aaf.cass.image}}
+        image: {{ include "common.repository" . }}/{{ .Values.image }}
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         # installing with cmd "onap" will not only initialize the DB, but add ONAP bootstrap data as well
         command: ["/bin/bash","/opt/app/aaf/cass_init/cmd.sh","onap"]
-        lifecycle:
-          preStop:
-            exec:
-              command: ["/bin/sh","-c","rm /opt/app/aaf/status/aaf-cass"]
-        ports:
-        - name: storage
-          containerPort: {{.Values.global.aaf.cass.storage_port}}
-        - name: ssl-storage
-          containerPort: {{.Values.global.aaf.cass.ssl_storage_port}}
-        - name: native-trans
-          containerPort: {{.Values.global.aaf.cass.native_trans_port}}
-        - name: rpc
-          containerPort: {{.Values.global.aaf.cass.rpc_port}}
+        ports: {{ include "common.containerPorts" . | nindent 10  }}
         env:
         - name: CASSANDRA_CLUSTER_NAME
-          value: {{.Values.global.aaf.cass.cluster_name}}
+          value: {{ .Values.config.cluster_name }}
         - name: CASSANDRA_DC
-          value: {{.Values.global.aaf.cass.dc}}
+          value: {{ .Values.config.dc }}
         - name: CQLSH
           value: "/opt/cassandra/bin/cqlsh"
         - name: HEAP_NEWSIZE
-          value: {{.Values.global.aaf.cass.heap_new_size}}
+          value: {{ .Values.config.heap_new_size }}
         - name: MAX_HEAP_SIZE
-          value: {{.Values.global.aaf.cass.max_heap_size}}
+          value: {{ .Values.config.max_heap_size }}
         - name: MY_POD_NAME
           valueFrom:
             fieldRef:
@@ -93,44 +76,36 @@
         volumeMounts:
         - mountPath: /var/lib/cassandra
           name: aaf-cass-vol
-        - mountPath: /opt/app/aaf/status
-          name: aaf-status-vol
         - mountPath: /etc/localtime
           name: localtime
           readOnly: true
         {{- if eq .Values.liveness.enabled true }}
         livenessProbe:
           tcpSocket:
-            port: {{.Values.global.aaf.cass.native_trans_port}}
+            port: tcp-cql
           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
           periodSeconds: {{ .Values.liveness.periodSeconds }}
         {{ end -}}
         readinessProbe:
           tcpSocket:
-            port: {{.Values.global.aaf.cass.native_trans_port}}
+            port: tcp-cql
           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
           periodSeconds: {{ .Values.readiness.periodSeconds }}
-        resources:
-{{ include "common.resources" . | indent 10 }}
+        resources: {{ include "common.resources" . | nindent 10 }}
       {{- if .Values.nodeSelector }}
-      nodeSelector:
-{{ toYaml .Values.nodeSelector | indent 10 }}
+      nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
       {{- end -}}
       {{- if .Values.affinity }}
-      affinity:
-{{ toYaml .Values.affinity | indent 10 }}
+      affinity: {{ toYaml .Values.affinity | nindent 10 }}
       {{- end }}
       volumes:
       - name: localtime
         hostPath:
           path: /etc/localtime
-      - name: aaf-status-vol
-        persistentVolumeClaim:
-          claimName: {{ include "common.release" . }}-aaf-status
       - name: aaf-cass-vol
       {{- if .Values.persistence.enabled }}
         persistentVolumeClaim:
-          claimName: {{ include "common.fullname" . }}-data
+          claimName: {{ include "common.fullname" . }}
       {{- else }}
         emptyDir: {}
       {{- end }}