[EXTAPI] Make NBI ServiceMesh compatible
[oom.git] / kubernetes / nbi / templates / deployment.yaml
1 {{/*
2 # Copyright © 2018 Orange
3 # Modifications Copyright © 2018  Amdocs, Bell Canada
4 # Modifications Copyright © 2020 Nokia
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 */}}
18
19 apiVersion: apps/v1
20 kind: Deployment
21 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
22 spec:
23   selector: {{- include "common.selectors" . | nindent 4 }}
24   replicas: {{ .Values.replicaCount }}
25   template:
26     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
27     spec:
28 {{- if .Values.global.aafEnabled }}
29       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
30 {{- end }}
31       containers:
32         - name: {{ include "common.name" . }}
33           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
34           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
35           ports: {{ include "common.containerPorts" . | nindent 12 }}
36           # disable liveness probe when breakpoints set in debugger
37           # so K8s doesn't restart unresponsive container
38           {{- if .Values.global.aafEnabled }}
39           command:
40           - sh
41           args:
42           - -c
43           - |
44             export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
45             export JAVA_OPTS="-Djavax.net.ssl.trustStorePassword=$cadi_truststore_password \
46               -Dserver.ssl.key-store={{ .Values.certInitializer.credsPath }}/org.onap.nbi.p12 \
47               -Dserver.ssl.key-store-type=PKCS12 \
48               -Djavax.net.ssl.trustStore={{ .Values.certInitializer.credsPath }}/org.onap.nbi.trust.jks \
49               -Dserver.ssl.key-store-password=$cadi_keystore_password_p12  \
50               -Djavax.net.ssl.trustStoreType=jks\
51               -Djava.security.egd=file:/dev/./urandom -Dserver.port=8443"
52             exec java -XX:+UseContainerSupport $JAVA_OPTS -jar /opt/onap/app.jar
53           {{- end }}
54           {{ if .Values.liveness.enabled }}
55           livenessProbe:
56             httpGet:
57               port: {{ if (include "common.needTLS" .) }}{{ .Values.service.internalPort }}{{ else }}{{ .Values.service.internalPlainPort }}{{ end }}
58               path: {{ .Values.liveness.path }}
59               scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
60             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
61             periodSeconds: {{ .Values.liveness.periodSeconds }}
62           {{ end }}
63           readinessProbe:
64             httpGet:
65               port: {{ if (include "common.needTLS" .) }}{{ .Values.service.internalPort }}{{ else }}{{ .Values.service.internalPlainPort }}{{ end }}
66               path: {{ .Values.readiness.path }}
67               scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
68             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
69             periodSeconds: {{ .Values.readiness.periodSeconds }}
70           env:
71             - name: SPRING_DATASOURCE_URL
72               value: jdbc:mariadb://{{ include "common.mariadbService" . }}:{{ include "common.mariadbPort" . }}/{{ index .Values "mariadb-galera" "db" "name" }}
73             - name: SPRING_DATASOURCE_USERNAME
74               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nbi-db-secret" "key" "login") | indent 14 }}
75             - name: SPRING_DATASOURCE_PASSWORD
76               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nbi-db-secret" "key" "password") | indent 14 }}
77             - name: SPRING_DATA_MONGODB_HOST
78               value: {{ .Values.mongo.service.name }}.{{ include "common.namespace" . }}
79             - name: SPRING_DATA_MONGODB_PORT
80               value: "{{ .Values.mongo.service.internalPort }}"
81             - name: SPRING_DATA_MONGODB_DATABASE
82               value: {{ .Values.mongo.config.dbName }}
83             - name: ONAP_LCPCLOUDREGIONID
84               value: {{ .Values.config.openStackRegion }}
85             - name: ONAP_TENANTID
86               value: {{ .Values.config.openStackVNFTenantId | quote }}
87             - name: ONAP_CLOUDOWNER
88               value: {{ .Values.config.cloudOwner }}
89             - name: ONAP_K8SCLOUDREGIONID
90               value: {{ .Values.config.k8sCloudRegionId }}
91             - name: ONAP_K8SCLOUDOWNER
92               value: {{ .Values.config.k8sCloudOwner }}
93             - name: NBI_URL
94               value: "{{ if (include "common.needTLS" .) }}https{{ else }}http{{ end }}://nbi.{{ include "common.namespace" . }}:{{ if (include "common.needTLS" .) }}{{ .Values.service.internalPort }}{{ else }}{{ .Values.service.internalPlainPort }}{{ end }}/nbi/api/v4"
95             - name: SDC_HOST
96               value: "{{ if (include "common.needTLS" .) }}https{{ else }}http{{ end }}://sdc-be.{{ include "common.namespace" . }}:{{ if (include "common.needTLS" .) }}8443{{ else }}8080{{ end }}"
97             - name: SDC_HEADER_ECOMPINSTANCEID
98               value: {{ .Values.config.ecompInstanceId }}
99             - name: SDC_HEADER_AUTHORIZATION
100               value: {{ .Values.sdc_authorization }}
101             - name: AAI_HOST
102               value: "{{ if (include "common.needTLS" .) }}https{{ else }}http{{ end }}://aai.{{ include "common.namespace" . }}:{{ if (include "common.needTLS" .) }}8443{{ else }}80{{ end }}"
103             - name: AAI_HEADER_AUTHORIZATION
104               value: {{ .Values.aai_authorization }}
105             - name: SO_HOST
106               value: http://so.{{ include "common.namespace" . }}:8080
107             {{- if .Values.so_authorization }}
108             - name: SO_HEADER_AUTHORIZATION
109               value: {{ .Values.so_authorization }}
110             {{- end }}
111             - name: DMAAP_HOST
112               value: "{{ if (include "common.needTLS" .) }}https{{ else }}http{{ end }}://message-router.{{ include "common.namespace" . }}:{{ if (include "common.needTLS" .) }}3905{{ else }}3904{{ end }}"
113             - name: LOGGING_LEVEL_ORG_ONAP_NBI
114               value: {{ .Values.config.loglevel }}
115             - name: MSB_ENABLED
116               value: "{{ .Values.global.msbEnabled }}"
117             - name: MSB_DISCOVERY_HOST
118               value: "msb-discovery.{{ include "common.namespace" . }}"
119             - name: MSB_DISCOVERY_PORT
120               value: "10081"
121           volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 12 }}
122             - mountPath: /etc/localtime
123               name: localtime
124               readOnly: true
125           resources:
126 {{ include "common.resources" . | indent 12 }}
127         {{- if .Values.nodeSelector }}
128         nodeSelector:
129 {{ toYaml .Values.nodeSelector | indent 10 }}
130         {{- end -}}
131         {{- if .Values.affinity }}
132         affinity:
133 {{ toYaml .Values.affinity | indent 10 }}
134         {{- end }}
135       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
136       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
137         - name: localtime
138           hostPath:
139             path: /etc/localtime
140       imagePullSecrets:
141       - name: "{{ include "common.namespace" . }}-docker-registry-key"