Feature 11032: Integration of OSM Helm Chart with different databases
[osm/devops.git] / installers / helm / osm / templates / lcm / lcm-deployment.yaml
1 {{- if .Values.lcm.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: lcm
22   labels:
23     {{- include "osm.labels" . | nindent 4 }}
24 spec:
25   replicas: {{ .Values.lcm.replicaCount | default .Values.global.replicaCount }}
26   selector:
27     matchLabels:
28       app.kubernetes.io/component: lcm
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: lcm
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-ro-mongo-test
49           image: alpine:latest
50           command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
51       containers:
52         - name: lcm
53           securityContext:
54             # readOnlyRootFilesystem: true
55             allowPrivilegeEscalation: false
56             runAsNonRoot: true
57             {{- toYaml .Values.global.securityContext | nindent 12 }}
58           image: {{ include "osm.lcm.image" . }}
59           imagePullPolicy: {{ .Values.global.image.pullPolicy }}
60           resources:
61             limits:
62               memory: 1024Mi
63             requests:
64               memory: 128Mi
65           envFrom:
66             - configMapRef:
67                 name: {{ include "osm.fullname" . }}-lcm-configmap
68             {{- if not .Values.lcm.useOsmSecret }}
69             - secretRef:
70                 name: {{ .Values.lcm.secretName | default "lcm-secret" }}
71             {{- end }}
72           {{- if or .Values.vca.enabled .Values.lcm.useOsmSecret }}
73           env:
74             {{- if .Values.vca.enabled }}
75             - name: OSMLCM_VCA_HOST
76               valueFrom:
77                 secretKeyRef:
78                   name: {{ include "osm.fullname" . }}-vca-secret
79                   key: OSM_VCA_HOST
80             - name: OSMLCM_VCA_SECRET
81               valueFrom:
82                 secretKeyRef:
83                   name: {{ include "osm.fullname" . }}-vca-secret
84                   key: OSM_VCA_SECRET
85             - name: OSMLCM_VCA_PUBKEY
86               valueFrom:
87                 secretKeyRef:
88                   name: {{ include "osm.fullname" . }}-vca-secret
89                   key: OSM_VCA_PUBKEY
90             - name: OSMLCM_VCA_CACERT
91               valueFrom:
92                 secretKeyRef:
93                   name: {{ include "osm.fullname" . }}-vca-secret
94                   key: OSM_VCA_CACERT
95             {{- end }}
96             {{- if .Values.lcm.useOsmSecret }}
97             - name: OSMLCM_DATABASE_COMMONKEY
98               valueFrom:
99                 secretKeyRef:
100                   name: {{ include "osm.fullname" . }}-secret
101                   key: OSM_DATABASE_COMMONKEY
102             - name: OSMLCM_DATABASE_URI
103               valueFrom:
104                 secretKeyRef:
105                   name: {{ include "osm.fullname" . }}-secret
106                   key: OSM_DATABASE_URI
107             - name: OSMLCM_STORAGE_URI
108               valueFrom:
109                 secretKeyRef:
110                   name: {{ include "osm.fullname" . }}-secret
111                   key: OSM_DATABASE_URI
112             {{- end }}
113           {{- end }}
114           volumeMounts:
115             - mountPath: /etc/ssl/certs/osm-ca.crt
116               name: osm-ca
117               readOnly: true
118               subPath: osm-ca.crt
119             - mountPath: /etc/ssl/lcm-client/
120               name: lcm-client-cert
121               readOnly: true
122       volumes:
123         - name: osm-ca
124           secret:
125             defaultMode: 420
126             items:
127               - key: tls.crt
128                 path: osm-ca.crt
129             secretName: osm-ca
130         - name: lcm-client-cert
131           secret:
132             defaultMode: 420
133             secretName: lcm-client-cert
134       {{- with .Values.global.nodeSelector }}
135       nodeSelector:
136         {{- toYaml . | nindent 8 }}
137       {{- end }}
138       {{- with .Values.global.affinity }}
139       affinity:
140         {{- toYaml . | nindent 8 }}
141       {{- end }}
142       {{- with .Values.global.tolerations }}
143       tolerations:
144         {{- toYaml . | nindent 8 }}
145       {{- end }}
146 {{- end }}