Set helm CLI container not start by default; Add PV for DB
[pti/o2.git] / charts / templates / deployment.yaml
1 # Copyright (C) 2021 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     spec:
33       serviceAccountName: {{ .Values.o2ims.serviceaccountname }}
34       # imagePullSecrets:
35       #   - name: {{ .Values.o2ims.imagePullSecrets }}
36       imagePullSecrets:
37         - name: {{ .Values.o2ims.serviceaccountname }}-registry-secret
38 {{- if .Values.o2ims.affinity }}
39       affinity:
40 {{ toYaml .Values.o2ims.affinity | indent 8 }}
41 {{- end }}
42       containers:
43         - name: postgres
44           image: postgres:9.6
45           ports:
46             - containerPort: 5432
47           env:
48             - name: POSTGRES_PASSWORD
49               value: o2ims123
50             - name: POSTGRES_USER
51               value: o2ims
52             - name: PGDATA
53               value: /var/lib/postgresql/data/pgdata
54           command: ["/bin/bash", "/opt/postgres_start.sh"]
55           volumeMounts:
56             - name: scripts
57               mountPath: /opt
58             - name: db-pv
59               mountPath: /var/lib/postgresql/data
60         - name: redis
61           image: redis:alpine
62           ports:
63             - containerPort: 6379
64         - name: o2pubsub
65           image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}"
66           command: ["/bin/bash", "/opt/o2pubsub_start.sh"]
67           env:
68             - name: DB_HOST
69               value: postgres
70             - name: DB_PASSWORD
71               value: o2ims123
72             - name: LOGGING_CONFIG_LEVEL
73               value: {{ .Values.o2ims.logginglevel }}
74             - name: OS_AUTH_URL
75               value: {{ .Values.ocloud.OS_AUTH_URL }}
76             - name: OS_PASSWORD
77               value: {{ .Values.ocloud.OS_PASSWORD }}
78             - name: OS_USERNAME
79               value: {{ .Values.ocloud.OS_USERNAME }}
80             - name: PYTHONDONTWRITEBYTECODE
81               value: "1"
82             - name: REDIS_HOST
83               value: redis
84             - name: K8S_KUBECONFIG
85               value: {{ .Values.ocloud.K8S_KUBECONFIG }}
86           volumeMounts:
87             - name: scripts
88               mountPath: /opt
89             - name: applicationconfig
90               mountPath: /configs/o2app.conf
91               subPath: config.json
92               readOnly: true
93             - name: smocacrt
94               mountPath: /configs/smoca.crt
95               subPath: config.json
96         - name: watcher
97           image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}"
98           command: ["/bin/bash", "/opt/o2watcher_start.sh"]
99           env:
100             - name: API_HOST_EXTERNAL_FLOATING
101               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
102             - name: DB_HOST
103               value: postgres
104             - name: DB_PASSWORD
105               value: o2ims123
106             - name: LOGGING_CONFIG_LEVEL
107               value: {{ .Values.o2ims.logginglevel }}
108             - name: OS_AUTH_URL
109               value: {{ .Values.ocloud.OS_AUTH_URL }}
110             - name: OS_PASSWORD
111               value: {{ .Values.ocloud.OS_PASSWORD }}
112             - name: OS_USERNAME
113               value: {{ .Values.ocloud.OS_USERNAME }}
114             - name: PYTHONDONTWRITEBYTECODE
115               value: "1"
116             - name: REDIS_HOST
117               value: redis
118           volumeMounts:
119             - name: scripts
120               mountPath: /opt
121             - name: applicationconfig
122               mountPath: /configs/o2app.conf
123               subPath: config.json
124               readOnly: true
125         - name: o2api
126           image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}"
127           ports:
128             - containerPort: 80
129           env:
130             - name: API_HOST_EXTERNAL_FLOATING
131               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
132             - name: DB_HOST
133               value: postgres
134             - name: DB_PASSWORD
135               value: o2ims123
136             - name: FLASK_APP
137               value: /src/o2app/entrypoints/flask_application.py
138             - name: FLASK_DEBUG
139               value: {{ .Values.o2ims.logginglevel }}
140             - name: LOGGING_CONFIG_LEVEL
141               value: {{ .Values.o2ims.logginglevel }}
142             - name: OS_AUTH_URL
143             - name: OS_PASSWORD
144             - name: OS_USERNAME
145             - name: PYTHONDONTWRITEBYTECODE
146               value: "1"
147             - name: PYTHONUNBUFFERED
148               value: "1"
149             - name: REDIS_HOST
150               value: redis
151             - name: HELM_USER_PASSWD
152               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
153           command: ["/bin/bash", "/opt/o2api_start.sh"]
154           volumeMounts:
155             - name: scripts
156               mountPath: /opt
157             # - name: configs
158             #   mountPath: /configs
159             - name: applicationconfig
160               mountPath: /configs/o2app.conf
161               subPath: config.json
162               readOnly: true
163             - name: servercrt
164               mountPath: /configs/server.crt
165               subPath: config.json
166               readOnly: true
167             - name: serverkey
168               mountPath: /configs/server.key
169               subPath: config.json
170               readOnly: true
171         {{- if .Values.o2dms.helm_cli_enable }}
172         - name: helmcli
173           image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}"
174           ports:
175             - containerPort: 22
176           env:
177             - name: API_HOST_EXTERNAL_FLOATING
178               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
179             - name: HELM_USER_PASSWD
180               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
181           command: ["/bin/bash", "/opt/o2_helmcli_start.sh"]
182           volumeMounts:
183             - name: scripts
184               mountPath: /opt
185         {{- end }}
186       volumes:
187         - name: scripts
188           configMap:
189             name: {{ .Chart.Name }}-scripts-configmap
190         # - name: configs
191         #   emptyDir: {}
192         - configMap:
193             name: {{ .Chart.Name }}-application-config
194           name: applicationconfig
195         - configMap:
196             name: {{ .Chart.Name }}-serverkey
197           name: serverkey
198         - configMap:
199             name: {{ .Chart.Name }}-servercrt
200           name: servercrt
201         - configMap:
202             name: {{ .Chart.Name }}-smocacrt
203           name: smocacrt
204         - name: db-pv
205           persistentVolumeClaim:
206             claimName: {{ .Chart.Name }}-db-pv
207 ---