[COMMON] Adding Common Template for cassa-operator

- K8ssandraCluster resources template file added
- Modification of the cassandra chart to add the option to install
  cassandra using the k8ssandra-operator
- AAI and SDC values changed to support the new cassandra settings
- Fix for SDC cql version in jobs
- for London make k8ssandra-operator optional (default: false)

Issue-ID: OOM-3168
Signed-off-by: Dasarathi, Swain (ds00528024) <ds00528024@techmahindra.com>
Change-Id: Idfe232460c9c1f584536e60ea042345d7dca3164
diff --git a/kubernetes/sdc/components/sdc-cs/templates/job.yaml b/kubernetes/sdc/components/sdc-cs/templates/job.yaml
index 31ab047..e8f8700 100644
--- a/kubernetes/sdc/components/sdc-cs/templates/job.yaml
+++ b/kubernetes/sdc/components/sdc-cs/templates/job.yaml
@@ -64,6 +64,8 @@
           mountPath: /home/sdc/chef-solo/environments/
         - name: {{ include "common.fullname" . }}-chef-cache
           mountPath: /home/sdc/chef-solo/cache
+        - name: {{ include "common.fullname" . }}-cqlshrc
+          mountPath: /home/sdc/.cassandra
         env:
         - name: ENVNAME
           value: {{ .Values.env.name }}
@@ -98,6 +100,9 @@
           defaultMode: 0755
       - name: {{ include "common.fullname" . }}-chef-cache
         emptyDir: {}
+      - name: {{ include "common.fullname" . }}-cqlshrc
+        configMap:
+          name: {{ include "common.release" . }}-sdc-cqlshrc
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"
       restartPolicy: Never
diff --git a/kubernetes/sdc/components/sdc-cs/values.yaml b/kubernetes/sdc/components/sdc-cs/values.yaml
index f58fca7..2f943d7 100644
--- a/kubernetes/sdc/components/sdc-cs/values.yaml
+++ b/kubernetes/sdc/components/sdc-cs/values.yaml
@@ -26,12 +26,22 @@
     #should be sdc-cs if this flag is enabled
     localCluster: false
     #The cassandra service name to connect to (default: shared cassandra service)
+    #in case of using k8ssandra-operator in the common cassandra installation
+    #the service name is:
+    #serviceName: cassandra-dc1-service
+    #in case of local k8ssandra-operator instance it is
+    #serviceName: sdc-cs-dc1-service
+    #in case the older cassandra installation is used:
     serviceName: cassandra
+
     #Shared cassandra cluster replicaCount, should be changed if localCluster is enabled
     #to match with its own cluster replica
     replicaCount: 3
     clusterName: cassandra
+    #datacenter name (use "dc1" in case of k8ssandra-operator, otherwise "Pod")
     dataCenter: Pod
+    #cqlVersion for cassandra 3.11.* must be "3.4.4" and cassandra 4.* must be "3.4.5"
+    cqlVersion: "3.4.4"
 
 #################################################################
 # Application configuration defaults.
@@ -48,6 +58,10 @@
   persistence:
     mountSubPath: sdc/sdc-cs/CS
     enabled: true
+  k8ssandraOperator:
+    enabled: false
+    config:
+      clusterName: sdc-cs
 
 # application image
 repository: nexus3.onap.org:10001
diff --git a/kubernetes/sdc/components/sdc-onboarding-be/templates/job.yaml b/kubernetes/sdc/components/sdc-onboarding-be/templates/job.yaml
index 41996ff..43a4902 100644
--- a/kubernetes/sdc/components/sdc-onboarding-be/templates/job.yaml
+++ b/kubernetes/sdc/components/sdc-onboarding-be/templates/job.yaml
@@ -65,6 +65,8 @@
         volumeMounts:
         - name: {{ include "common.fullname" . }}-environments
           mountPath: /home/sdc/chef-solo/environments/
+        - name: {{ include "common.fullname" . }}-cqlshrc
+          mountPath: /home/sdc/.cassandra
         env:
         - name: ENVNAME
           value: {{ .Values.env.name }}
@@ -96,6 +98,9 @@
         configMap:
           name: {{ include "common.release" . }}-sdc-environments-configmap
           defaultMode: 0755
+      - name: {{ include "common.fullname" . }}-cqlshrc
+        configMap:
+          name: {{ include "common.release" . }}-sdc-cqlshrc
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"
       restartPolicy: Never
diff --git a/kubernetes/sdc/components/sdc-wfd-be/templates/job.yaml b/kubernetes/sdc/components/sdc-wfd-be/templates/job.yaml
index 9ba05b8..b9abef8 100644
--- a/kubernetes/sdc/components/sdc-wfd-be/templates/job.yaml
+++ b/kubernetes/sdc/components/sdc-wfd-be/templates/job.yaml
@@ -65,6 +65,9 @@
         - /bin/sh
         - -c
         {{- end }}
+        volumeMounts:
+          - name: {{ include "common.fullname" . }}-cqlshrc
+            mountPath: /home/sdc/.cassandra
         env:
           - name: CS_HOST
             value: "{{ .Values.global.sdc_cassandra.serviceName }}"
@@ -78,6 +81,10 @@
             valueFrom: {secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_password}}
         resources: {{ include "common.resources" . | nindent 10 }}
       {{ include "common.waitForJobContainer" . | indent 6 | trim }}
+      volumes:
+        - name: {{ include "common.fullname" . }}-cqlshrc
+          configMap:
+            name: {{ include "common.release" . }}-sdc-cqlshrc
       imagePullSecrets:
         - name: "{{ include "common.namespace" . }}-docker-registry-key"
 {{ end }}
diff --git a/kubernetes/sdc/resources/config/cqlshrc b/kubernetes/sdc/resources/config/cqlshrc
new file mode 100644
index 0000000..cb6df94
--- /dev/null
+++ b/kubernetes/sdc/resources/config/cqlshrc
@@ -0,0 +1,2 @@
+[cql]
+version={{.Values.global.sdc_cassandra.cqlVersion}}
\ No newline at end of file
diff --git a/kubernetes/sdc/templates/configmap.yaml b/kubernetes/sdc/templates/configmap.yaml
index 712f2ec..dee73ba 100644
--- a/kubernetes/sdc/templates/configmap.yaml
+++ b/kubernetes/sdc/templates/configmap.yaml
@@ -28,4 +28,17 @@
 data:
 {{ tpl (.Files.Glob "resources/config/environments/*").AsConfig . | indent 2 }}
 ---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "common.release" . }}-sdc-cqlshrc
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ include "common.release" . }}
+    heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/cqlshrc").AsConfig . | indent 2 }}
+---
 {{ include "common.log.configMap" . }}
diff --git a/kubernetes/sdc/values.yaml b/kubernetes/sdc/values.yaml
index cba3362..955ac4b 100644
--- a/kubernetes/sdc/values.yaml
+++ b/kubernetes/sdc/values.yaml
@@ -26,20 +26,28 @@
     keystore_password: PyhrUCFZdXIhWyohWTUhRV5mKFpLYzMx
     wf_external_user_password: S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==
   sdc_cassandra:
-   #This flag allows SDC to instantiate its own cluster, serviceName
-   #should be "sdc-cs" if this flag is enabled
-   localCluster: false
-   #The cassandra service name to connect to (default: shared cassandra service)
-   serviceName: cassandra
-   #Shared cassandra cluster replicaCount, should be changed if localCluster is enabled
-   #to match with its own cluster replica
-   #see "cassandra: replicaCount" in file sdc-cs/values.yaml)
-   replicaCount: 3
-   dbCache: true
-   readConsistencyLevel: ONE
-   writeConsistencyLevel: ALL
-   clusterName: cassandra
-   dataCenter: Pod
+    #This flag allows SDC to instantiate its own cluster, serviceName
+    #should be "sdc-cs" if this flag is enabled
+    localCluster: false
+    #The cassandra service name to connect to (default: shared cassandra service)
+    #in case of using k8ssandra-operator in the common cassandra installation
+    #the service name is:
+    #serviceName: cassandra-dc1-service
+    #in case the older cassandra installation is used:
+    serviceName: cassandra
+    #Shared cassandra cluster replicaCount, should be changed if localCluster is enabled
+    #to match with its own cluster replica
+    #see "cassandra: replicaCount" in file sdc-cs/values.yaml)
+    replicaCount: 3
+    dbCache: true
+    readConsistencyLevel: ONE
+    writeConsistencyLevel: ALL
+    clusterName: cassandra
+    #datacenter name (use "dc1" in case of k8ssandra-operator, otherwise "Pod")
+    dataCenter: Pod
+    #cqlVersion for cassandra 3.11.* must be "3.4.4" and cassandra 4.* must be "3.4.5"
+    cqlVersion: "3.4.4"
+
   centralizedLoggingEnabled: true
   # global Kafka config passed to sdc-be chart
   kafka: