Add template support for pod labels and annotations
[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           volumeMounts:
128             - name: scripts
129               mountPath: /opt
130             - name: applicationconfig
131               mountPath: /configs/o2app.conf
132               subPath: config.json
133               readOnly: true
134         - name: o2api
135           image: "{{ .Values.o2ims.images.tags.o2service }}"
136           ports:
137             - containerPort: 80
138           env:
139             - name: API_HOST_EXTERNAL_FLOATING
140               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
141             - name: DB_HOST
142               value: localhost
143             - name: DB_PASSWORD
144               value: o2ims123
145             # - name: FLASK_APP
146             #   value: /src/o2app/entrypoints/flask_application.py
147             # - name: FLASK_DEBUG
148             #   value: {{ .Values.o2ims.logginglevel }}
149             - name: LOGGING_CONFIG_LEVEL
150               value: {{ .Values.o2ims.logginglevel }}
151             - name: OS_AUTH_URL
152             - name: OS_PASSWORD
153             - name: OS_USERNAME
154             - name: PYTHONDONTWRITEBYTECODE
155               value: "1"
156             - name: PYTHONUNBUFFERED
157               value: "1"
158             - name: REDIS_HOST
159               value: localhost
160             - name: HELM_USER_PASSWD
161               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
162           command: ["/bin/bash", "/opt/o2api_start.sh"]
163           volumeMounts:
164             - name: scripts
165               mountPath: /opt
166             {{- if .Values.o2dms.helm_cli_enable }}
167             - name: share
168               mountPath: /share
169             {{- end }}
170             - name: applicationconfig
171               mountPath: /configs/o2app.conf
172               subPath: config.json
173               readOnly: true
174             - name: servercrt
175               mountPath: /configs/server.crt
176               subPath: config.json
177               readOnly: true
178             - name: serverkey
179               mountPath: /configs/server.key
180               subPath: config.json
181               readOnly: true
182         {{- if .Values.o2dms.helm_cli_enable }}
183         - name: helmcli
184           image: "{{ .Values.o2ims.images.tags.o2service }}"
185           ports:
186             - containerPort: 22
187           env:
188             - name: API_HOST_EXTERNAL_FLOATING
189               value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}
190             - name: HELM_USER_PASSWD
191               value: {{ .Values.ocloud.HELM_USER_PASSWD }}
192           command: ["/bin/bash", "/opt/o2_helmcli_start.sh"]
193           volumeMounts:
194             - name: scripts
195               mountPath: /opt
196             - name: share
197               mountPath: /share
198         {{- end }}
199       volumes:
200         - name: scripts
201           configMap:
202             name: {{ .Chart.Name }}-scripts-configmap
203         {{- if .Values.o2dms.helm_cli_enable }}
204         - name: share
205           emptyDir: {}
206         {{- end }}
207         - configMap:
208             name: {{ .Chart.Name }}-application-config
209           name: applicationconfig
210         - configMap:
211             name: {{ .Chart.Name }}-serverkey
212           name: serverkey
213         - configMap:
214             name: {{ .Chart.Name }}-servercrt
215           name: servercrt
216         - configMap:
217             name: {{ .Chart.Name }}-smocacrt
218           name: smocacrt
219         - name: db-pv
220           persistentVolumeClaim:
221             claimName: {{ .Chart.Name }}-db-pv
222 ---