a1e45822ffffb7f424a6213120e574f4df07c343
[pti/o2.git] / charts / templates / deployment.yaml
1 # Copyright (C) 2021-2023 Wind River Systems, Inc.
2 #
3 #  Licensed under the Apache License, Version 2.0 (the "License");
4 #  you may not use this file except in compliance with the License.
5 #  You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #  Unless required by applicable law or agreed to in writing, software
10 #  distributed under the License is distributed on an "AS IS" BASIS,
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 ---
16 apiVersion: apps/v1
17 kind: Deployment
18 metadata:
19   name: o2api
20   namespace: {{ .Values.global.namespace }}
21   labels:
22     app: o2api
23 spec:
24   replicas: 1
25   selector:
26     matchLabels:
27       app: o2api
28   template:
29     metadata:
30       labels:
31         app: o2api
32         {{- with .Values.podLabels }}
33         {{- toYaml . | nindent 8 }}
34         {{- end }}
35       annotations:
36         {{- with .Values.podAnnotations }}
37         {{- toYaml . | nindent 8 }}
38         {{- end }}
39     spec:
40       serviceAccountName: {{ .Values.o2ims.serviceaccountname }}
41       {{- if .Values.imagePullSecrets }}
42       imagePullSecrets:
43         {{- range .Values.imagePullSecrets }}
44         - name: {{ . }}
45         {{- end }}
46       {{- end }}
47 {{- if .Values.o2ims.affinity }}
48       affinity:
49 {{ toYaml .Values.o2ims.affinity | indent 8 }}
50 {{- end }}
51       containers:
52         - name: postgres
53           image: "{{ .Values.o2ims.images.tags.postgres }}"
54           ports:
55             - containerPort: 5432
56           env:
57             - name: POSTGRES_PASSWORD
58               value: o2ims123
59             - name: POSTGRES_USER
60               value: o2ims
61             - name: PGDATA
62               value: /var/lib/postgresql/data/pgdata
63           command: ["/bin/bash", "/opt/postgres_start.sh"]
64           volumeMounts:
65             - name: scripts
66               mountPath: /opt
67             - name: db-pv
68               mountPath: /var/lib/postgresql/data
69         - name: redis
70           image: "{{ .Values.o2ims.images.tags.redis }}"
71           ports:
72             - containerPort: 6379
73         - name: o2pubsub
74           image: "{{ .Values.o2ims.images.tags.o2service }}"
75           command: ["/bin/bash", "/opt/o2pubsub_start.sh"]
76           env:
77             - name: DB_HOST
78               value: localhost
79             - name: DB_PASSWORD
80               value: o2ims123
81             - name: LOGGING_CONFIG_LEVEL
82               value: {{ .Values.o2ims.logginglevel }}
83             - name: OS_AUTH_URL
84               value: {{ .Values.ocloud.OS_AUTH_URL }}
85             - name: OS_PASSWORD
86               value: {{ .Values.ocloud.OS_PASSWORD }}
87             - name: OS_USERNAME
88               value: {{ .Values.ocloud.OS_USERNAME }}
89             - name: PYTHONDONTWRITEBYTECODE
90               value: "1"
91             - name: REDIS_HOST
92               value: localhost
93             - name: K8S_KUBECONFIG
94               value: {{ .Values.ocloud.K8S_KUBECONFIG }}
95           volumeMounts:
96             - name: scripts
97               mountPath: /opt
98             - name: applicationconfig
99               mountPath: /configs/o2app.conf
100               subPath: config.json
101               readOnly: true
102             - name: smocacrt
103               mountPath: /configs/smoca.crt
104               subPath: config.json
105         - name: watcher
106           image: "{{ .Values.o2ims.images.tags.o2service }}"
107           command: ["/bin/bash", "/opt/o2watcher_start.sh"]
108           env:
109             - name: API_HOST_EXTERNAL_FLOATING
110               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
111             - name: DB_HOST
112               value: localhost
113             - name: DB_PASSWORD
114               value: o2ims123
115             - name: LOGGING_CONFIG_LEVEL
116               value: {{ .Values.o2ims.logginglevel }}
117             - name: OS_AUTH_URL
118               value: {{ .Values.ocloud.OS_AUTH_URL }}
119             - name: OS_PASSWORD
120               value: {{ .Values.ocloud.OS_PASSWORD }}
121             - name: OS_USERNAME
122               value: {{ .Values.ocloud.OS_USERNAME }}
123             - name: PYTHONDONTWRITEBYTECODE
124               value: "1"
125             - name: REDIS_HOST
126               value: localhost
127             {{- if default false .Values.o2ims.useHostCert }}
128             - name: REQUESTS_CA_BUNDLE
129               value: /etc/ssl/custom-cert.pem
130             {{- end }}
131             - name: CGTS_INSECURE_SSL
132               value: {{ ternary "1" "0" (default false .Values.o2ims.cgtsInsecureSSL) | quote }}
133           volumeMounts:
134             - name: scripts
135               mountPath: /opt
136             - name: applicationconfig
137               mountPath: /configs/o2app.conf
138               subPath: config.json
139               readOnly: true
140             {{- if default false .Values.o2ims.useHostCert }}
141             - name: ca-certs
142               mountPath: /etc/ssl/custom-cert.pem
143               readOnly: true
144             {{- end }}
145         - name: o2api
146           image: "{{ .Values.o2ims.images.tags.o2service }}"
147           ports:
148             - containerPort: 80
149           env:
150             - name: API_HOST_EXTERNAL_FLOATING
151               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
152             - name: DB_HOST
153               value: localhost
154             - name: DB_PASSWORD
155               value: o2ims123
156             # - name: FLASK_APP
157             #   value: /src/o2app/entrypoints/flask_application.py
158             # - name: FLASK_DEBUG
159             #   value: {{ .Values.o2ims.logginglevel }}
160             - name: LOGGING_CONFIG_LEVEL
161               value: {{ .Values.o2ims.logginglevel }}
162             - name: OS_AUTH_URL
163             - name: OS_PASSWORD
164             - name: OS_USERNAME
165             - name: PYTHONDONTWRITEBYTECODE
166               value: "1"
167             - name: PYTHONUNBUFFERED
168               value: "1"
169             - name: REDIS_HOST
170               value: localhost
171             - name: HELM_USER_PASSWD
172               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
173           command: ["/bin/bash", "/opt/o2api_start.sh"]
174           volumeMounts:
175             - name: scripts
176               mountPath: /opt
177             {{- if .Values.o2dms.helm_cli_enable }}
178             - name: share
179               mountPath: /share
180             {{- end }}
181             - name: applicationconfig
182               mountPath: /configs/o2app.conf
183               subPath: config.json
184               readOnly: true
185             - name: servercrt
186               mountPath: /configs/server.crt
187               subPath: config.json
188               readOnly: true
189             - name: serverkey
190               mountPath: /configs/server.key
191               subPath: config.json
192               readOnly: true
193         {{- if .Values.o2dms.helm_cli_enable }}
194         - name: helmcli
195           image: "{{ .Values.o2ims.images.tags.o2service }}"
196           ports:
197             - containerPort: 22
198           env:
199             - name: API_HOST_EXTERNAL_FLOATING
200               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
201             - name: HELM_USER_PASSWD
202               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
203           command: ["/bin/bash", "/opt/o2_helmcli_start.sh"]
204           volumeMounts:
205             - name: scripts
206               mountPath: /opt
207             - name: share
208               mountPath: /share
209         {{- end }}
210       volumes:
211         - name: scripts
212           configMap:
213             name: {{ .Chart.Name }}-scripts-configmap
214         {{- if .Values.o2dms.helm_cli_enable }}
215         - name: share
216           emptyDir: {}
217         {{- end }}
218         - configMap:
219             name: {{ .Chart.Name }}-application-config
220           name: applicationconfig
221         - configMap:
222             name: {{ .Chart.Name }}-serverkey
223           name: serverkey
224         - configMap:
225             name: {{ .Chart.Name }}-servercrt
226           name: servercrt
227         - configMap:
228             name: {{ .Chart.Name }}-smocacrt
229           name: smocacrt
230         - name: db-pv
231           persistentVolumeClaim:
232             claimName: {{ .Chart.Name }}-db-pv
233         {{- if default false .Values.o2ims.useHostCert }}
234         - name: ca-certs
235           hostPath:
236             path: {{ .Values.o2ims.hostCertPath | quote }}
237             type: File
238         {{- end }}
239 ---