Feature 11006: make juju installation optional in community installer
[osm/devops.git] / installers / helm / osm / templates / mon / mon-deployment.yaml
1 {{- if .Values.mon.enabled -}}
2 #######################################################################################
3 # Copyright ETSI Contributors and Others.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #######################################################################################
18 apiVersion: apps/v1
19 kind: Deployment
20 metadata:
21   name: mon
22   labels:
23     {{- include "osm.labels" . | nindent 4 }}
24 spec:
25   replicas: {{ .Values.mon.replicaCount | default .Values.global.replicaCount }}
26   selector:
27     matchLabels:
28       app.kubernetes.io/component: mon
29       {{- include "osm.selectorLabels" . | nindent 6 }}
30   template:
31     metadata:
32       {{- with .Values.global.podAnnotations }}
33       annotations:
34         {{- toYaml . | nindent 8 }}
35       {{- end }}
36       labels:
37         app.kubernetes.io/component: mon
38         {{- include "osm.selectorLabels" . | nindent 8 }}
39     spec:
40       {{- with .Values.global.imagePullSecrets }}
41       imagePullSecrets:
42         {{- toYaml . | nindent 8 }}
43       {{- end }}
44       serviceAccountName: {{ include "osm.serviceAccountName" . }}
45       securityContext:
46         {{- toYaml .Values.global.podSecurityContext | nindent 8 }}
47       initContainers:
48         - name: kafka-mongo-test
49           image: alpine:latest
50           command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
51       containers:
52         - name: mon
53           securityContext:
54             # readOnlyRootFilesystem: true
55             allowPrivilegeEscalation: false
56             runAsNonRoot: true
57             {{- toYaml .Values.global.securityContext | nindent 12 }}
58           image: {{ include "osm.mon.image" . }}
59           imagePullPolicy: {{ .Values.global.image.pullPolicy }}
60           {{- if not .Values.global.oldServiceAssurance }}
61           command: ["/bin/bash"]
62           args: ["scripts/dashboarder-start.sh"]
63           {{- end }}
64           ports:
65             - containerPort: 8662
66               protocol: TCP
67           resources:
68             limits:
69               memory: 1024Mi
70             requests:
71               memory: 128Mi
72           envFrom:
73             - configMapRef:
74                 name: {{ include "osm.fullname" . }}-mon-configmap
75           {{- if not .Values.mon.useOsmSecret }}
76             - secretRef:
77                 name: {{ .Values.mon.secretName | default "mon-secret" }}
78           {{- end }}
79           {{- if or .Values.vca.enabled .Values.mon.useOsmSecret }}
80           env:
81             {{- if .Values.vca.enabled }}
82             - name: OSMMON_VCA_HOST
83               valueFrom:
84                 secretKeyRef:
85                   name: {{ include "osm.fullname" . }}-vca-secret
86                   key: OSM_VCA_HOST
87             - name: OSMMON_VCA_SECRET
88               valueFrom:
89                 secretKeyRef:
90                   name: {{ include "osm.fullname" . }}-vca-secret
91                   key: OSM_VCA_SECRET
92             - name: OSMMON_VCA_CACERT
93               valueFrom:
94                 secretKeyRef:
95                   name: {{ include "osm.fullname" . }}-vca-secret
96                   key: OSM_VCA_CACERT
97             {{- end }}
98             {{- if .Values.mon.useOsmSecret }}
99             - name: OSMMON_DATABASE_COMMONKEY
100               valueFrom:
101                 secretKeyRef:
102                   name: {{ include "osm.fullname" . }}-secret
103                   key: OSM_DATABASE_COMMONKEY
104             {{- end }}
105           {{- end }}
106       {{- with .Values.global.nodeSelector }}
107       nodeSelector:
108         {{- toYaml . | nindent 8 }}
109       {{- end }}
110       {{- with .Values.global.affinity }}
111       affinity:
112         {{- toYaml . | nindent 8 }}
113       {{- end }}
114       {{- with .Values.global.tolerations }}
115       tolerations:
116         {{- toYaml . | nindent 8 }}
117       {{- end }}
118 {{- end }}