Merge "OAuth2 support"
[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             {{- if .Values.db.persistence }}
68             - name: db-pv
69               mountPath: /var/lib/postgresql/data
70             {{- end }}
71         - name: redis
72           image: "{{ .Values.o2ims.images.tags.redis }}"
73           ports:
74             - containerPort: 6379
75         - name: o2pubsub
76           image: "{{ .Values.o2ims.images.tags.o2service }}"
77           command: ["/bin/bash", "/opt/o2pubsub_start.sh"]
78           env:
79             - name: DB_HOST
80               value: localhost
81             - name: DB_PASSWORD
82               value: o2ims123
83             - name: LOGGING_CONFIG_LEVEL
84               value: {{ .Values.o2ims.logginglevel }}
85             - name: OS_AUTH_URL
86               value: {{ .Values.ocloud.OS_AUTH_URL }}
87             - name: OS_PASSWORD
88               value: {{ .Values.ocloud.OS_PASSWORD }}
89             - name: OS_USERNAME
90               value: {{ .Values.ocloud.OS_USERNAME }}
91             - name: PYTHONDONTWRITEBYTECODE
92               value: "1"
93             - name: REDIS_HOST
94               value: localhost
95             - name: K8S_KUBECONFIG
96               value: {{ .Values.ocloud.K8S_KUBECONFIG }}
97           volumeMounts:
98             - name: scripts
99               mountPath: /opt
100             - name: applicationconfig
101               mountPath: /configs/o2app.conf
102               subPath: config.json
103               readOnly: true
104             - name: smocacrt
105               mountPath: /configs/smoca.crt
106               subPath: config.json
107         - name: watcher
108           image: "{{ .Values.o2ims.images.tags.o2service }}"
109           command: ["/bin/bash", "/opt/o2watcher_start.sh"]
110           env:
111             - name: API_HOST_EXTERNAL_FLOATING
112               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
113             - name: DB_HOST
114               value: localhost
115             - name: DB_PASSWORD
116               value: o2ims123
117             - name: LOGGING_CONFIG_LEVEL
118               value: {{ .Values.o2ims.logginglevel }}
119             - name: OS_AUTH_URL
120               value: {{ .Values.ocloud.OS_AUTH_URL }}
121             - name: OS_PASSWORD
122               value: {{ .Values.ocloud.OS_PASSWORD }}
123             - name: OS_USERNAME
124               value: {{ .Values.ocloud.OS_USERNAME }}
125             - name: PYTHONDONTWRITEBYTECODE
126               value: "1"
127             - name: REDIS_HOST
128               value: localhost
129             {{- if default false .Values.o2ims.useHostCert }}
130             - name: REQUESTS_CA_BUNDLE
131               value: /etc/ssl/custom-cert.pem
132             {{- end }}
133             - name: CGTS_INSECURE_SSL
134               value: {{ ternary "1" "0" (default false .Values.o2ims.cgtsInsecureSSL) | quote }}
135           volumeMounts:
136             - name: scripts
137               mountPath: /opt
138             - name: applicationconfig
139               mountPath: /configs/o2app.conf
140               subPath: config.json
141               readOnly: true
142             {{- if default false .Values.o2ims.useHostCert }}
143             - name: ca-certs
144               mountPath: /etc/ssl/custom-cert.pem
145               readOnly: true
146             {{- end }}
147         - name: o2api
148           image: "{{ .Values.o2ims.images.tags.o2service }}"
149           ports:
150             - containerPort: 80
151           env:
152             - name: API_HOST_EXTERNAL_FLOATING
153               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
154             - name: DB_HOST
155               value: localhost
156             - name: DB_PASSWORD
157               value: o2ims123
158             # - name: FLASK_APP
159             #   value: /src/o2app/entrypoints/flask_application.py
160             # - name: FLASK_DEBUG
161             #   value: {{ .Values.o2ims.logginglevel }}
162             - name: LOGGING_CONFIG_LEVEL
163               value: {{ .Values.o2ims.logginglevel }}
164             - name: OS_AUTH_URL
165             - name: OS_PASSWORD
166             - name: OS_USERNAME
167             - name: PYTHONDONTWRITEBYTECODE
168               value: "1"
169             - name: PYTHONUNBUFFERED
170               value: "1"
171             - name: REDIS_HOST
172               value: localhost
173             - name: HELM_USER_PASSWD
174               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
175           command: ["/bin/bash", "/opt/o2api_start.sh"]
176           volumeMounts:
177             - name: scripts
178               mountPath: /opt
179             {{- if .Values.o2dms.helm_cli_enable }}
180             - name: share
181               mountPath: /share
182             {{- end }}
183             - name: applicationconfig
184               mountPath: /configs/o2app.conf
185               subPath: config.json
186               readOnly: true
187             - name: servercrt
188               mountPath: /configs/server.crt
189               subPath: config.json
190               readOnly: true
191             - name: serverkey
192               mountPath: /configs/server.key
193               subPath: config.json
194               readOnly: true
195             - name: smocacrt
196               mountPath: /configs/smoca.crt
197               subPath: config.json
198         {{- if .Values.o2dms.helm_cli_enable }}
199         - name: helmcli
200           image: "{{ .Values.o2ims.images.tags.o2service }}"
201           ports:
202             - containerPort: 22
203           env:
204             - name: API_HOST_EXTERNAL_FLOATING
205               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
206             - name: HELM_USER_PASSWD
207               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
208           command: ["/bin/bash", "/opt/o2_helmcli_start.sh"]
209           volumeMounts:
210             - name: scripts
211               mountPath: /opt
212             - name: share
213               mountPath: /share
214         {{- end }}
215       volumes:
216         - name: scripts
217           configMap:
218             name: {{ .Chart.Name }}-scripts-configmap
219         {{- if .Values.o2dms.helm_cli_enable }}
220         - name: share
221           emptyDir: {}
222         {{- end }}
223         - configMap:
224             name: {{ .Chart.Name }}-application-config
225           name: applicationconfig
226         - configMap:
227             name: {{ .Chart.Name }}-serverkey
228           name: serverkey
229         - configMap:
230             name: {{ .Chart.Name }}-servercrt
231           name: servercrt
232         - configMap:
233             name: {{ .Chart.Name }}-smocacrt
234           name: smocacrt
235         {{- if .Values.db.persistence }}
236         - name: db-pv
237           persistentVolumeClaim:
238             claimName: {{ .Chart.Name }}-db-pv
239         {{- end }}
240         {{- if default false .Values.o2ims.useHostCert }}
241         - name: ca-certs
242           hostPath:
243             path: {{ .Values.o2ims.hostCertPath | quote }}
244             type: File
245         {{- end }}
246 ---