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