Merge "[SDNC] Set STDOUT Log level"
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
index e3ac50f..265d3af 100644 (file)
@@ -1,3 +1,5 @@
+{{/*
+# Copyright © 2020 Samsung Electronics
 # Copyright © 2017 Amdocs, Bell Canada
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,8 +13,9 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+*/}}
 
-apiVersion: apps/v1beta1
+apiVersion: apps/v1
 kind: StatefulSet
 metadata:
   name: {{ include "common.fullname" . }}
@@ -20,9 +23,12 @@ metadata:
   labels:
     app: {{ include "common.name" . }}
     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ .Release.Name }}
+    release: {{ include "common.release" . }}
     heritage: {{ .Release.Service }}
 spec:
+  selector:
+    matchLabels:
+      app: {{ include "common.name" . }}
   serviceName: {{ include "common.servicename" . }}-cluster
   replicas: {{ .Values.replicaCount }}
   podManagementPolicy: Parallel
@@ -30,14 +36,55 @@ spec:
     metadata:
       labels:
         app: {{ include "common.name" . }}
-        release: {{ .Release.Name }}
+        release: {{ include "common.release" . }}
     spec:
       initContainers:
+      - command:
+        - sh
+        args:
+        - -c
+        - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
+        env:
+        - name: AAI_CLIENT_NAME
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
+        - name: AAI_CLIENT_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
+        - name: MODELSERVICE_USER
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
+        - name: MODELSERVICE_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
+        - name: RESTCONF_USER
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
+        - name: RESTCONF_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
+        - name: ANSIBLE_USER
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
+        - name: ANSIBLE_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
+        - name: SCALEOUT_USER
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
+        - name: SCALEOUT_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
+        - name: NETBOX_APIKEY
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
+        - name: SDNC_DB_USER
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
+        - name: SDNC_DB_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
+        volumeMounts:
+        - mountPath: /config-input
+          name: config-input
+        - mountPath: /config
+          name: properties
+        image: "{{ .Values.global.envsubstImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        name: {{ include "common.name" . }}-update-config
+
       - command:
         - /root/ready.py
         args:
         - --container-name
-        - {{ .Values.config.mariadbGalera.chartName }}
+        - {{ include "common.mariadbService" . }}
         env:
         - name: NAMESPACE
           valueFrom:
@@ -46,21 +93,30 @@ spec:
               fieldPath: metadata.namespace
         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-readiness   
+        name: {{ include "common.name" . }}-readiness
+
+{{ include "common.certInitializer.initContainer" . | indent 6 }}
+
       - name: {{ include "common.name" . }}-chown
         image: "busybox"
-        command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }} ; chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certpersistence.certPath }}"]
+        command:
+        - sh
+        args:
+        - -c
+        - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
+{{- if .Values.global.aafEnabled }}
+        - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
+{{- end }}
         volumeMounts:
+{{ include "common.certInitializer.volumeMount" . | indent 10 }}
           - mountPath: {{ .Values.persistence.mdsalPath }}
-            name: {{ include "common.fullname" . }}-mdsal
-          - mountPath: {{ .Values.certpersistence.certPath }}
-            name: {{ include "common.fullname" . }}-certs
+            name: {{ include "common.fullname" . }}-data
       containers:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           command: ["/bin/bash"]
-          args: ["-c", "/opt/sdnc/bin/startODL.sh"]
+          args: ["-c", "/opt/onap/sdnc/bin/startODL.sh"]
           ports:
           - containerPort: {{ .Values.service.internalPort }}
           - containerPort: {{ .Values.service.internalPort2 }}
@@ -72,40 +128,40 @@ spec:
             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
             periodSeconds: {{ .Values.readiness.periodSeconds }}
           env:
-            - name: MYSQL_ROOT_PASSWORD
-              valueFrom:
-                secretKeyRef:
-                  name: {{ template "common.fullname" . }}
-                  key: db-root-password
-            - name: ODL_ADMIN_PASSWORD
-              valueFrom:
-                secretKeyRef:
-                  name: {{ template "common.fullname" . }}-odl
-                  key: odl-password
-            - name: SDNC_DB_PASSWORD
-              valueFrom:
-                secretKeyRef:
-                  name: {{ template "common.fullname" . }}-sdnctl
-                  key: db-sdnctl-password
-            - name: SDNC_CONFIG_DIR
-              value: "{{ .Values.config.configDir }}"
-            - name: ENABLE_ODL_CLUSTER
-              value: "{{ .Values.config.enableClustering }}"
-            - name: MY_ODL_CLUSTER
-              value: "{{ .Values.config.myODLCluster }}"
-            - name: PEER_ODL_CLUSTER
-              value: "{{ .Values.config.peerODLCluster }}"
-            - name: IS_PRIMARY_CLUSTER
-              value: "{{ .Values.config.isPrimaryCluster }}"
-            - name: GEO_ENABLED
-              value: "{{ .Values.config.geoEnabled}}"
-            - name: SDNC_REPLICAS
-              value: "{{ .Values.replicaCount }}"
-            - name: MYSQL_HOST
-              value: "{{.Values.config.mariadbGalera.serviceName}}.{{.Release.Namespace}}"
-            - name: JAVA_HOME
-              value: "{{ .Values.config.javaHome}}"
+          - name: MYSQL_ROOT_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
+          - name: ODL_ADMIN_USERNAME
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
+          - name: ODL_ADMIN_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
+          - name: SDNC_DB_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
+          - name: SDNC_DB_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
+          - name: SDNC_CONFIG_DIR
+            value: "{{ .Values.config.configDir }}"
+          - name: ENABLE_ODL_CLUSTER
+            value: "{{ .Values.config.enableClustering }}"
+          - name: MY_ODL_CLUSTER
+            value: "{{ .Values.config.myODLCluster }}"
+          - name: PEER_ODL_CLUSTER
+            value: "{{ .Values.config.peerODLCluster }}"
+          - name: IS_PRIMARY_CLUSTER
+            value: "{{ .Values.config.isPrimaryCluster }}"
+          - name: GEO_ENABLED
+            value: "{{ .Values.config.geoEnabled}}"
+          - name: SDNC_AAF_ENABLED
+            value: "{{ .Values.global.aafEnabled}}"
+          - name: SDNC_REPLICAS
+            value: "{{ .Values.replicaCount }}"
+          - name: MYSQL_HOST
+            value: {{ include "common.mariadbService" . }}
+          - name: JAVA_HOME
+            value: "{{ .Values.config.javaHome}}"
+          - name: KARAF_CONSOLE_LOG_LEVEL
+            value: "{{ include "common.log.level" . }}"
           volumeMounts:
+{{ include "common.certInitializer.volumeMount" . | indent 10 }}
           - mountPath: /etc/localtime
             name: localtime
             readOnly: true
@@ -118,6 +174,9 @@ spec:
           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
             name: bin
             subPath: installSdncDb.sh
+          - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
+            name: properties
+            subPath: aaiclient.properties
           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
             name: properties
             subPath: aaiclient.properties
@@ -140,11 +199,9 @@ spec:
             name: properties
             subPath: blueprints-processor-adaptor.properties
           - mountPath: {{ .Values.persistence.mdsalPath }}
-            name: {{ include "common.fullname" . }}-mdsal
+            name: {{ include "common.fullname" . }}-data
           - mountPath: /var/log/onap
             name: logs
-          - mountPath: {{ .Values.certpersistence.certPath }}
-            name: {{ include "common.fullname" . }}-certs
           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
             name: properties
             subPath: akka.conf
@@ -197,33 +254,31 @@ spec:
           configMap:
             name: {{ include "common.fullname" . }}-bin
             defaultMode: 0755
-        - name: properties
+        - name: config-input
           configMap:
             name: {{ include "common.fullname" . }}-properties
             defaultMode: 0644
-        - name: {{ include "common.fullname" . }}-certs
-  {{ if .Values.certpersistence.enabled }}
-          persistentVolumeClaim:
-            claimName: {{ include "common.fullname" . }}-pvc-certs
-  {{ else }}
-          emptyDir: {}
-  {{ end }}
+        - name: properties
+          emptyDir:
+            medium: Memory
   {{ if not .Values.persistence.enabled }}
-        - name: {{ include "common.fullname" . }}-mdsal
+        - name: {{ include "common.fullname" . }}-data
           emptyDir: {}
   {{ else }}
+{{ include "common.certInitializer.volumes" . | nindent 8 }}
   volumeClaimTemplates:
   - metadata:
-      name: {{ include "common.fullname" . }}-mdsal
+      name: {{ include "common.fullname" . }}-data
       labels:
         name: {{ include "common.fullname" . }}
+        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+        release: "{{ include "common.release" . }}"
+        heritage: "{{ .Release.Service }}"
     spec:
-      accessModes: [ {{ .Values.persistence.accessMode }} ]
-      storageClassName: {{ include "common.fullname" . }}-mdsal
+      accessModes:
+      - {{ .Values.persistence.accessMode }}
+      storageClassName: {{ include "common.storageClass" . }}
       resources:
         requests:
           storage: {{ .Values.persistence.size }}
-      selector:
-        matchLabels:
-          name: {{ include "common.fullname" . }}
-  {{ end }}
+  {{- end }}