7c3746a0a3340442b73cda22b1949ba23cbb1af9
[oom.git] / kubernetes / dcaegen2 / components / dcae-inventory-api / templates / deployment.yaml
1 {{/*
2 #============LICENSE_START========================================================
3 # ================================================================================
4 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
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 # ============LICENSE_END=========================================================
18 */}}
19
20 apiVersion: apps/v1
21 kind: Deployment
22 metadata:
23   name: {{ include "common.fullname" . }}
24   namespace: {{ include "common.namespace" . }}
25   labels:
26     app: {{ include "common.name" . }}
27     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
28     release: {{ include "common.release" . }}
29     heritage: {{ .Release.Service }}
30 spec:
31   replicas: 1
32   selector:
33     matchLabels:
34       app: {{ include "common.name" . }}
35   template:
36     metadata:
37       labels:
38         app: {{ include "common.name" . }}
39         release: {{ include "common.release" . }}
40     spec:
41       initContainers:
42         - command:
43           - sh
44           args:
45           - -c
46           - "cd /config-input && for PFILE in `find . -not -type d | grep -v -F ..`; do envsubst <${PFILE} >/config/${PFILE}; done"
47           env:
48           - name: PG_USER
49             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
50           - name: PG_PASSWORD
51             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
52           volumeMounts:
53           - mountPath: /config-input
54             name: {{ include "common.fullname" . }}-inv-config-input
55           - mountPath: /config
56             name: {{ include "common.fullname" . }}-inv-config
57           image: {{ include "repositoryGenerator.image.envsubst" . }}
58           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59           name: {{ include "common.name" . }}-update-config
60
61         - name: {{ include "common.name" . }}-readiness
62           image: {{ include "repositoryGenerator.image.readiness" . }}
63           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
64           command:
65             - /app/ready.py
66           args:
67             - --container-name
68             - {{ .Values.postgres.nameOverride }}
69             - --container-name
70             - aaf-cm
71             - "-t"
72             - "15"
73           env:
74           - name: NAMESPACE
75             valueFrom:
76               fieldRef:
77                 apiVersion: v1
78                 fieldPath: metadata.namespace
79         - name: init-tls
80           env:
81           - name: aaf_locator_fqdn
82             value: dcae
83           - name: POD_IP
84             valueFrom:
85               fieldRef:
86                 apiVersion: v1
87                 fieldPath: status.podIP
88           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.global.tlsImage }}
89           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
90           resources: {}
91           volumeMounts:
92             - mountPath: /opt/app/osaaf
93               name: tls-info
94       containers:
95         - name: {{ include "common.name" . }}
96           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
97           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
98           # Assumes that the Docker image is built with ENTRYPOINT set to
99           # ["java", "-jar", "/opt/inventory-api-x.y.z.jar", "server"]
100           # where "x.y.z" is the version number (matches the Docker image version number)
101           # The arg below adds a parameter, the path to a config file.
102           # This tells the inventory-api app to get its configuration from the file
103           # rather than querying Consul.
104           args:
105             - "/opt/config.json"
106           resources:
107 {{ include "common.resources" . | indent 12 }}
108           ports:
109           - containerPort: {{ .Values.service.internalPort }}
110           # disable liveness probe when breakpoints set in debugger
111           # so K8s doesn't restart unresponsive container
112           {{- if eq .Values.liveness.enabled true }}
113           livenessProbe:
114             tcpSocket:
115               port: {{ .Values.service.internalPort }}
116             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
117             periodSeconds: {{ .Values.liveness.periodSeconds }}
118           {{ end }}
119           readinessProbe:
120             httpGet:
121               path: {{ .Values.readiness.path }}
122               port: {{ .Values.service.internalPort }}
123               scheme: {{ .Values.readiness.scheme }}
124             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
125             periodSeconds: {{ .Values.readiness.periodSeconds }}
126           volumeMounts:
127             - name: {{  include "common.fullname" . }}-inv-config
128               mountPath: /opt/config.json
129               subPath: config.json
130             - mountPath: /opt/cert/
131               name: tls-info
132             - mountPath: /opt/logs/
133               name: component-log
134           env:
135             - name: CONSUL_HOST
136               value: consul.{{ include "common.namespace" . }}
137         - name: {{ include "common.name" . }}-filebeat
138           env:
139             - name: POD_IP
140               valueFrom:
141                 fieldRef:
142                   apiVersion: v1
143                   fieldPath: status.podIP
144           image: {{ include "repositoryGenerator.image.logging" . }}
145           imagePullPolicy: IfNotPresent
146           resources: {}
147           volumeMounts:
148           - mountPath: /var/log/onap/inventory
149             name: component-log
150           - mountPath: /usr/share/filebeat/data
151             name: filebeat-data
152           - mountPath: /usr/share/filebeat/filebeat.yml
153             name: filebeat-conf
154             subPath: filebeat.yml
155       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
156       volumes:
157         - emptyDir: {}
158           name: component-log
159         - emptyDir: {}
160           name: filebeat-data
161         - configMap:
162             defaultMode: 420
163             name: {{ include "common.fullname" . }}-filebeat-configmap
164           name: filebeat-conf
165         - name: {{ include "common.fullname" . }}-inv-config-input
166           configMap:
167             name: {{ include "common.fullname" . }}-configmap
168         - name: {{ include "common.fullname" . }}-inv-config
169           emptyDir:
170             medium: Memory
171         - emptyDir: {}
172           name: tls-info
173       imagePullSecrets:
174       - name: "{{ include "common.namespace" . }}-docker-registry-key"