Fix install O2 on subcloud failed
[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: OS_REGION_NAME
126               value: {{ .Values.ocloud.OS_REGION_NAME }}
127             - name: PYTHONDONTWRITEBYTECODE
128               value: "1"
129             - name: REDIS_HOST
130               value: localhost
131             {{- if default false .Values.o2ims.useHostCert }}
132             - name: REQUESTS_CA_BUNDLE
133               value: /etc/ssl/custom-cert.pem
134             {{- end }}
135             - name: CGTS_INSECURE_SSL
136               value: {{ ternary "1" "0" (default false .Values.o2ims.cgtsInsecureSSL) | quote }}
137           volumeMounts:
138             - name: scripts
139               mountPath: /opt
140             - name: applicationconfig
141               mountPath: /configs/o2app.conf
142               subPath: config.json
143               readOnly: true
144             {{- if default false .Values.o2ims.useHostCert }}
145             - name: ca-certs
146               mountPath: /etc/ssl/custom-cert.pem
147               readOnly: true
148             {{- end }}
149         - name: o2api
150           image: "{{ .Values.o2ims.images.tags.o2service }}"
151           ports:
152             - containerPort: 80
153           env:
154             - name: API_HOST_EXTERNAL_FLOATING
155               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
156             - name: DB_HOST
157               value: localhost
158             - name: DB_PASSWORD
159               value: o2ims123
160             # - name: FLASK_APP
161             #   value: /src/o2app/entrypoints/flask_application.py
162             # - name: FLASK_DEBUG
163             #   value: {{ .Values.o2ims.logginglevel }}
164             - name: LOGGING_CONFIG_LEVEL
165               value: {{ .Values.o2ims.logginglevel }}
166             - name: OS_AUTH_URL
167             - name: OS_PASSWORD
168             - name: OS_USERNAME
169             - name: PYTHONDONTWRITEBYTECODE
170               value: "1"
171             - name: PYTHONUNBUFFERED
172               value: "1"
173             - name: REDIS_HOST
174               value: localhost
175             - name: HELM_USER_PASSWD
176               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
177           command: ["/bin/bash", "/opt/o2api_start.sh"]
178           volumeMounts:
179             - name: scripts
180               mountPath: /opt
181             {{- if .Values.o2dms.helm_cli_enable }}
182             - name: share
183               mountPath: /share
184             {{- end }}
185             - name: applicationconfig
186               mountPath: /configs/o2app.conf
187               subPath: config.json
188               readOnly: true
189             - name: servercrt
190               mountPath: /configs/server.crt
191               subPath: config.json
192               readOnly: true
193             - name: serverkey
194               mountPath: /configs/server.key
195               subPath: config.json
196               readOnly: true
197             - name: smocacrt
198               mountPath: /configs/smoca.crt
199               subPath: config.json
200         {{- if .Values.o2dms.helm_cli_enable }}
201         - name: helmcli
202           image: "{{ .Values.o2ims.images.tags.o2service }}"
203           ports:
204             - containerPort: 22
205           env:
206             - name: API_HOST_EXTERNAL_FLOATING
207               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
208             - name: HELM_USER_PASSWD
209               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
210           command: ["/bin/bash", "/opt/o2_helmcli_start.sh"]
211           volumeMounts:
212             - name: scripts
213               mountPath: /opt
214             - name: share
215               mountPath: /share
216         {{- end }}
217       volumes:
218         - name: scripts
219           configMap:
220             name: {{ .Chart.Name }}-scripts-configmap
221         {{- if .Values.o2dms.helm_cli_enable }}
222         - name: share
223           emptyDir: {}
224         {{- end }}
225         - configMap:
226             name: {{ .Chart.Name }}-application-config
227           name: applicationconfig
228         - configMap:
229             name: {{ .Chart.Name }}-serverkey
230           name: serverkey
231         - configMap:
232             name: {{ .Chart.Name }}-servercrt
233           name: servercrt
234         - configMap:
235             name: {{ .Chart.Name }}-smocacrt
236           name: smocacrt
237         {{- if .Values.db.persistence }}
238         - name: db-pv
239           persistentVolumeClaim:
240             claimName: {{ .Chart.Name }}-db-pv
241         {{- end }}
242         {{- if default false .Values.o2ims.useHostCert }}
243         - name: ca-certs
244           hostPath:
245             path: {{ .Values.o2ims.hostCertPath | quote }}
246             type: File
247         {{- end }}
248 ---