blob: 6713031d9a0e2604158c9945c8d8e1776f158171 [file] [log] [blame]
Jack Lucasd41dbdb2021-02-16 11:07:28 -05001{{/*
2#============LICENSE_START========================================================
3# ================================================================================
Jack Lucas1e184212022-03-08 13:35:24 -05004# Copyright (c) 2021-2022 J. F. Lucas. All rights reserved.
vv770de8c5c682021-04-15 12:21:36 -04005# Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
Piotr Marcinkiewicz70625182021-04-29 17:02:37 +02006# Copyright (c) 2021 Nokia. All rights reserved.
ajay_dp001cf5232a2021-04-13 20:48:07 +05307# Copyright (c) 2021 Nordix Foundation.
Jack Lucasd41dbdb2021-02-16 11:07:28 -05008# ================================================================================
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13# http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20# ============LICENSE_END=========================================================
21*/}}
22{{/*
Jack Lucascbca57d2021-04-05 09:49:46 -040023For internal use only!
24
25dcaegen2-services-common._ms-specific-env-vars:
26This template generates a list of microservice-specific environment variables
27as specified in .Values.applicationEnv. The
28dcaegen2-services-common.microServiceDeployment uses this template
29to add the microservice-specific environment variables to the microservice's container.
30These environment variables are in addition to a standard set of environment variables
31provided to all microservices.
32
33The template expects a single argument, pointing to the caller's global context.
34
35Microservice-specific environment variables can be specified in two ways:
Jack Lucasf86f6292022-06-08 09:12:29 -040036 1. As literal string values. (The values can also be Helm template fragments.)
Jack Lucascbca57d2021-04-05 09:49:46 -040037 2. As values that are sourced from a secret, identified by the secret's
38 uid and the key within the secret that provides the value.
39
40The following example shows an example of each type. The example assumes
41that a secret has been created using the OOM common secret mechanism, with
42a secret uid "example-secret" and a key called "password".
43
44applicationEnv:
45 APPLICATION_PASSWORD:
46 secretUid: example-secret
47 key: password
48 APPLICATION_EXAMPLE: "An example value"
49
50The example would set two environment variables on the microservice's container,
51one called "APPLICATION_PASSWORD" with the value set from the "password" key in
52the secret with uid "example-secret", and one called "APPLICATION_EXAMPLE" set to
53the the literal string "An example value".
54*/}}
55{{- define "dcaegen2-services-common._ms-specific-env-vars" -}}
56 {{- $global := . }}
57 {{- if .Values.applicationEnv }}
58 {{- range $envName, $envValue := .Values.applicationEnv }}
59 {{- if kindIs "string" $envValue }}
60- name: {{ $envName }}
efiacor26c1f7a2022-04-25 13:27:18 +010061 value: {{ tpl $envValue $global | quote }}
Jack Lucascbca57d2021-04-05 09:49:46 -040062 {{- else }}
efiacor5c0678f2023-03-06 09:21:57 +000063 {{- if and (hasKey $envValue "externalSecret") ($envValue.externalSecret) }}
64- name: {{ $envName }}
65 valueFrom:
66 secretKeyRef:
67 name: {{ tpl $envValue.externalSecretUid $global | quote }}
68 key: {{ tpl $envValue.key $global | quote }}
69 {{- else }}
70 {{ if or (not $envValue.secretUid) (not $envValue.key) }}
71 {{ fail (printf "Env %s definition is not a string and does not contain secretUid or key fields" $envName) }}
72 {{- end }}
Jack Lucascbca57d2021-04-05 09:49:46 -040073- name: {{ $envName }}
74 {{- include "common.secret.envFromSecretFast" (dict "global" $global "uid" $envValue.secretUid "key" $envValue.key) | indent 2 }}
efiacor5c0678f2023-03-06 09:21:57 +000075 {{- end }}
Jack Lucascbca57d2021-04-05 09:49:46 -040076 {{- end -}}
77 {{- end }}
78 {{- end }}
79{{- end -}}
80{{/*
Jack Lucase5f71602021-05-10 12:00:02 -040081For internal use only!
82
83dcaegen2-services-common._externalVolumes:
84This template generates a list of volumes associated with the pod,
85based on information provided in .Values.externalVolumes. This
86template works in conjunction with dcaegen2-services-common._externalVolumeMounts
87to give the microservice access to data in volumes created else.
88This initial implementation supports ConfigMaps only, as this is the only
89external volume mounting required by current microservices.
90
Jack Lucasb880f892021-06-07 16:40:31 -040091.Values.externalVolumes is a list of objects. Each object has 3 required fields and 2 optional fields:
Jack Lucase5f71602021-05-10 12:00:02 -040092 - name: the name of the resource (in the current implementation, it must be a ConfigMap)
93 that is to be set up as a volume. The value is a case sensitive string. Because the
94 names of resources are sometimes set at deployment time (for instance, to prefix the Helm
95 release to the name), the string can be a Helm template fragment that will be expanded at
96 deployment time.
97 - type: the type of the resource (in the current implementation, only "ConfigMap" is supported).
98 The value is a case-INsensitive string.
99 - mountPoint: the path to the mount point for the volume in the container file system. The
100 value is a case-sensitive string.
101 - readOnly: (Optional) Boolean flag. Set to true to mount the volume as read-only.
102 Defaults to false.
Jack Lucasb880f892021-06-07 16:40:31 -0400103 - optional: (Optional) Boolean flag. Set to true to make the configMap optional (i.e., to allow the
104 microservice's pod to start even if the configMap doesn't exist). If set to false, the configMap must
105 be present in order for the microservice's pod to start. Defaults to true. (Note that this
106 default is the opposite of the Kubernetes default. We've done this to be consistent with the behavior
107 of the DCAE Cloudify plugin for Kubernetes [k8splugin], which always set "optional" to true.)
Jack Lucase5f71602021-05-10 12:00:02 -0400108
109Here is an example fragment from a values.yaml file for a microservice:
110
111externalVolumes:
112 - name: my-example-configmap
113 type: configmap
114 mountPath: /opt/app/config
115 - name: '{{ include "common.release" . }}-another-example'
116 type: configmap
117 mountPath: /opt/app/otherconfig
Jack Lucasb880f892021-06-07 16:40:31 -0400118 optional: false
Jack Lucase5f71602021-05-10 12:00:02 -0400119*/}}
120{{- define "dcaegen2-services-common._externalVolumes" -}}
121 {{- $global := . -}}
122 {{- if .Values.externalVolumes }}
123 {{- range $vol := .Values.externalVolumes }}
124 {{- if eq (lower $vol.type) "configmap" }}
Jack Lucasb880f892021-06-07 16:40:31 -0400125 {{- $vname := (tpl $vol.name $global) -}}
126 {{- $opt := hasKey $vol "optional" | ternary $vol.optional true }}
Jack Lucase5f71602021-05-10 12:00:02 -0400127- configMap:
128 defaultMode: 420
129 name: {{ $vname }}
Jack Lucasb880f892021-06-07 16:40:31 -0400130 optional: {{ $opt }}
Jack Lucase5f71602021-05-10 12:00:02 -0400131 name: {{ $vname }}
132 {{- end }}
133 {{- end }}
134 {{- end }}
135{{- end }}
136{{/*
137For internal use only!
138
139dcaegen2-services-common._externalVolumeMounts:
140This template generates a list of volume mounts for the microservice container,
141based on information provided in .Values.externalVolumes. This
142template works in conjunction with dcaegen2-services-common._externalVolumes
143to give the microservice access to data in volumes created else.
144This initial implementation supports ConfigMaps only, as this is the only
145external volume mounting required by current microservices.
146
147See the documentation for dcaegen2-services-common._externalVolumes for
148details on how external volumes are specified in the values.yaml file for
149the microservice.
150*/}}
151{{- define "dcaegen2-services-common._externalVolumeMounts" -}}
152 {{- $global := . -}}
153 {{- if .Values.externalVolumes }}
154 {{- range $vol := .Values.externalVolumes }}
155 {{- if eq (lower $vol.type) "configmap" }}
156 {{- $vname := (tpl $vol.name $global) -}}
157 {{- $readOnly := $vol.readOnly | default false }}
158- mountPath: {{ $vol.mountPath }}
159 name: {{ $vname }}
160 readOnly: {{ $readOnly }}
161 {{- end }}
162 {{- end }}
163 {{- end }}
164{{- end }}
165{{/*
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500166dcaegen2-services-common.microserviceDeployment:
167This template produces a Kubernetes Deployment for a DCAE microservice.
168
169All DCAE microservices currently use very similar Deployments. Having a
170common template eliminates a lot of repetition in the individual charts
171for each microservice.
172
173The template expects the full chart context as input. A chart for a
174DCAE microservice references this template using:
175{{ include "dcaegen2-services-common.microserviceDeployment" . }}
176The template directly references data in .Values, and indirectly (through its
177use of templates from the ONAP "common" collection) references data in
178.Release.
179
180The exact content of the Deployment generated from this template
181depends on the content of .Values.
182
183The Deployment always includes a single Pod, with a container that uses
Jack Lucas47c07452022-08-02 09:39:34 -0400184the DCAE microservice image. The image name and tag are specified by
185.Values.image. By default, the image comes from the ONAP repository
186(registry) set up by the common repositoryGenerator template. A different
187repository for the microservice image can be set using
188.Values.imageRepositoryOverride. Note that this repository must not
189require authentication, because there is no way to specify credentials for
190the override repository. imageRepositoryOverride is intended primarily
191for testing purposes.
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500192
193The Deployment Pod may also include a logging sidecar container.
Jack Lucas1e184212022-03-08 13:35:24 -0500194The sidecar is included if .Values.log.path is set. The
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500195logging sidecar and the DCAE microservice container share a
196volume where the microservice logs are written.
197
vv770de8c5c682021-04-15 12:21:36 -0400198Deployed POD may also include a Policy-sync sidecar container.
199The sidecar is included if .Values.policies is set. The
200Policy-sync sidecar polls PolicyEngine (PDP) periodically based
201on .Values.policies.duration and configuration retrieved is shared with
202DCAE Microservice container by common volume. Policy can be retrieved based on
guillaume.lambert30ec3902021-09-14 12:32:24 +0200203list of policyID or filter. An optional policyRelease parameter can be specified
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400204to override the default policy helm release (used for retreiving the secret containing
205pdp username and password)
206
207Following is example policy config override
208
209dcaePolicySyncImage: onap/org.onap.dcaegen2.deployments.dcae-services-policy-sync:1.0.1
210policies:
211 duration: 300
212 policyRelease: "onap"
213 policyID: |
214 '["onap.vfirewall.tca","onap.vdns.tca"]'
Jack Lucasf86f6292022-06-08 09:12:29 -0400215
216The Deployment includes an initContainer that checks for the
217readiness of other components that the microservice relies on.
218This container is generated by the "common.readinessCheck.waitfor"
219template. See the documentation for this template
220(oom/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl).
221
222If the microservice uses a DMaaP Data Router (DR) feed, the Deployment
223includes an initContainer that makes provisioning requests to the DMaaP
224bus controller (dmaap-bc) to create the feed and to set up a publisher
225and/or subscriber to the feed. The Deployment also includes a second
226initContainer that merges the information returned by the provisioning
227process into the microservice's configuration. See the documentation for
228the common DMaaP provisioning template
229(oom/kubernetes/common/common/templates/_dmaapProvisioning.tpl).
230
231If the microservice acts as a TLS client or server, the Deployment will
232include an initContainer that retrieves certificate information from
233the AAF certificate manager. The information is mounted at the
234mount point specified in .Values.certDirectory. If the microservice is
235a TLS server (indicated by setting .Values.tlsServer to true), the
236certificate information will include a server cert and key, in various
237formats. It will also include the AAF CA cert. If the microservice is
238a TLS client only (indicated by setting .Values.tlsServer to false), the
239certificate information includes only the AAF CA cert.
240
241If the microservice uses certificates from an external CMPv2 provider,
242the Deployment will include an initContainer that performs certificate
243post-processing.
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500244*/}}
245
246{{- define "dcaegen2-services-common.microserviceDeployment" -}}
Jack Lucas1e184212022-03-08 13:35:24 -0500247{{- $log := default dict .Values.log -}}
248{{- $logDir := default "" $log.path -}}
rope2525a7fbee2022-07-25 20:00:36 +0100249{{- $certDir := (eq "true" (include "common.needTLS" .)) | ternary (default "" .Values.certDirectory . ) "" -}}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500250{{- $tlsServer := default "" .Values.tlsServer -}}
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400251{{- $commonRelease := print (include "common.release" .) -}}
252{{- $policy := default dict .Values.policies -}}
253{{- $policyRls := default $commonRelease $policy.policyRelease -}}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530254{{- $drFeedConfig := default "" .Values.drFeedConfig -}}
Jack Lucas4b22da92021-12-09 21:54:10 -0500255{{- $dcaeName := print (include "common.fullname" .) }}
256{{- $dcaeLabel := (dict "dcaeMicroserviceName" $dcaeName) -}}
257{{- $dot := . -}}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500258apiVersion: apps/v1
259kind: Deployment
Jack Lucas4b22da92021-12-09 21:54:10 -0500260metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "labels" $dcaeLabel) | nindent 2 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500261spec:
262 replicas: 1
263 selector: {{- include "common.selectors" . | nindent 4 }}
264 template:
265 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
266 spec:
267 initContainers:
rope2525a7fbee2022-07-25 20:00:36 +0100268 {{- if .Values.readinessCheck }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500269 {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
rope2525a7fbee2022-07-25 20:00:36 +0100270 {{- end }}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530271 {{- include "common.dmaap.provisioning.initContainer" . | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500272 {{- if $certDir }}
rope2525a7fbee2022-07-25 20:00:36 +0100273 - name: {{ include "common.name" . }}-aaf-init-readiness
274 image: {{ include "repositoryGenerator.image.readiness" . }}
275 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
276 command:
277 - /app/ready.py
278 args:
279 - --container-name
280 - aaf-cm
281 env:
282 - name: NAMESPACE
283 valueFrom:
284 fieldRef:
285 apiVersion: v1
286 fieldPath: metadata.namespace
287 resources:
288 limits:
289 cpu: 100m
290 memory: 100Mi
291 requests:
292 cpu: 3m
293 memory: 20Mi
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500294 - name: init-tls
295 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.tlsImage }}
296 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
297 env:
298 - name: TLS_SERVER
299 value: {{ $tlsServer | quote }}
300 - name: POD_IP
301 valueFrom:
302 fieldRef:
303 apiVersion: v1
304 fieldPath: status.podIP
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100305 resources: {{ include "common.resources" . | nindent 10 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500306 volumeMounts:
307 - mountPath: /opt/app/osaaf
308 name: tls-info
309 {{- end }}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200310 {{ include "dcaegen2-services-common._certPostProcessor" . | nindent 4 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500311 containers:
Jack Lucas47c07452022-08-02 09:39:34 -0400312 - image: {{ default ( include "repositoryGenerator.repository" . ) .Values.imageRepositoryOverride }}/{{ .Values.image }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500313 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
314 name: {{ include "common.name" . }}
315 env:
Bartosz Gardziejewski041a89a2021-05-19 08:05:00 +0200316 {{- range $cred := .Values.credentials }}
317 - name: {{ $cred.name }}
318 {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }}
319 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500320 {{- if $certDir }}
321 - name: DCAE_CA_CERTPATH
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200322 value: {{ $certDir }}/cacert.pem
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500323 {{- end }}
324 - name: CONSUL_HOST
325 value: consul-server.onap
326 - name: CONFIG_BINDING_SERVICE
327 value: config-binding-service
328 - name: CBS_CONFIG_URL
329 value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }}
330 - name: POD_IP
331 valueFrom:
332 fieldRef:
333 apiVersion: v1
334 fieldPath: status.podIP
Jack Lucascbca57d2021-04-05 09:49:46 -0400335 {{- include "dcaegen2-services-common._ms-specific-env-vars" . | nindent 8 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500336 {{- if .Values.service }}
337 ports: {{ include "common.containerPorts" . | nindent 10 }}
338 {{- end }}
339 {{- if .Values.readiness }}
340 readinessProbe:
341 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }}
342 periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
343 timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }}
344 {{- $probeType := .Values.readiness.type | default "httpGet" -}}
345 {{- if eq $probeType "httpGet" }}
346 httpGet:
347 scheme: {{ .Values.readiness.scheme }}
348 path: {{ .Values.readiness.path }}
349 port: {{ .Values.readiness.port }}
350 {{- end }}
351 {{- if eq $probeType "exec" }}
352 exec:
353 command:
354 {{- range $cmd := .Values.readiness.command }}
355 - {{ $cmd }}
356 {{- end }}
357 {{- end }}
358 {{- end }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100359 resources: {{ include "common.resources" . | nindent 10 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500360 volumeMounts:
Bartosz Gardziejewski4bb3da32021-04-21 12:08:50 +0200361 - mountPath: /app-config
Jack Lucasf86f6292022-06-08 09:12:29 -0400362 name: {{ ternary "app-config-input" "app-config" (not $drFeedConfig) }}
Bartosz Gardziejewski041a89a2021-05-19 08:05:00 +0200363 - mountPath: /app-config-input
364 name: app-config-input
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500365 {{- if $logDir }}
366 - mountPath: {{ $logDir}}
Maciej Wereski7000a7c2021-12-16 12:24:06 +0100367 name: logs
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500368 {{- end }}
369 {{- if $certDir }}
370 - mountPath: {{ $certDir }}
371 name: tls-info
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200372 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200373 {{- include "common.certManager.volumeMountsReadOnly" . | nindent 8 -}}
374 {{- end -}}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500375 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400376 {{- if $policy }}
377 - name: policy-shared
378 mountPath: /etc/policies
379 {{- end }}
Jack Lucase5f71602021-05-10 12:00:02 -0400380 {{- include "dcaegen2-services-common._externalVolumeMounts" . | nindent 8 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500381 {{- if $logDir }}
Maciej Wereski7000a7c2021-12-16 12:24:06 +0100382 {{ include "common.log.sidecar" . | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500383 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400384 {{- if $policy }}
385 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dcaePolicySyncImage }}
386 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
387 name: policy-sync
388 env:
389 - name: POD_IP
390 valueFrom:
391 fieldRef:
392 apiVersion: v1
393 fieldPath: status.podIP
394 - name: POLICY_SYNC_PDP_USER
395 valueFrom:
396 secretKeyRef:
Prativa Dora54080222022-03-29 09:29:23 +0000397 name: {{ $policyRls }}-policy-xacml-pdp-restserver-creds
vv770de8c5c682021-04-15 12:21:36 -0400398 key: login
399 - name: POLICY_SYNC_PDP_PASS
400 valueFrom:
401 secretKeyRef:
Prativa Dora54080222022-03-29 09:29:23 +0000402 name: {{ $policyRls }}-policy-xacml-pdp-restserver-creds
vv770de8c5c682021-04-15 12:21:36 -0400403 key: password
404 - name: POLICY_SYNC_PDP_URL
Piotr Marcinkiewicz70625182021-04-29 17:02:37 +0200405 value : http{{ if (include "common.needTLS" .) }}s{{ end }}://policy-xacml-pdp:6969
vv770de8c5c682021-04-15 12:21:36 -0400406 - name: POLICY_SYNC_OUTFILE
407 value : "/etc/policies/policies.json"
408 - name: POLICY_SYNC_V1_DECISION_ENDPOINT
409 value : "policy/pdpx/v1/decision"
410 {{- if $policy.filter }}
411 - name: POLICY_SYNC_FILTER
412 value: {{ $policy.filter }}
413 {{- end -}}
414 {{- if $policy.policyID }}
415 - name: POLICY_SYNC_ID
416 value: {{ $policy.policyID }}
417 {{- end -}}
418 {{- if $policy.duration }}
419 - name: POLICY_SYNC_DURATION
Vijay Venkatesh Kumarc269b262021-06-29 13:49:15 -0400420 value: "{{ $policy.duration }}"
vv770de8c5c682021-04-15 12:21:36 -0400421 {{- end }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100422 resources: {{ include "common.resources" . | nindent 10 }}
vv770de8c5c682021-04-15 12:21:36 -0400423 volumeMounts:
424 - mountPath: /etc/policies
425 name: policy-shared
426 {{- if $certDir }}
427 - mountPath: /opt/ca-certificates/
428 name: tls-info
429 {{- end }}
430 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500431 hostname: {{ include "common.name" . }}
farida azmycb03ac72021-09-12 16:14:12 +0200432 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500433 volumes:
434 - configMap:
435 defaultMode: 420
436 name: {{ include "common.fullname" . }}-application-config-configmap
437 name: app-config-input
438 - emptyDir:
439 medium: Memory
440 name: app-config
441 {{- if $logDir }}
442 - emptyDir: {}
Maciej Wereski7000a7c2021-12-16 12:24:06 +0100443 name: logs
444 {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix . )) | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500445 {{- end }}
446 {{- if $certDir }}
447 - emptyDir: {}
448 name: tls-info
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200449 {{ if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200450 {{ include "common.certManager.volumesReadOnly" . | nindent 6 }}
451 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500452 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400453 {{- if $policy }}
454 - name: policy-shared
455 emptyDir: {}
456 {{- end }}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530457 {{- include "common.dmaap.provisioning._volumes" . | nindent 6 -}}
Jack Lucase5f71602021-05-10 12:00:02 -0400458 {{- include "dcaegen2-services-common._externalVolumes" . | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500459 imagePullSecrets:
460 - name: "{{ include "common.namespace" . }}-docker-registry-key"
461{{ end -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200462
463{{/*
464 For internal use
465
466 Template to attach CertPostProcessor which merges CMPv2 truststore with AAF truststore
467 and swaps keystore files.
468*/}}
469{{- define "dcaegen2-services-common._certPostProcessor" -}}
470 {{- $certDir := default "" .Values.certDirectory . -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200471 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200472 {{- $cmpv2Certificate := (index .Values.certificates 0) -}}
473 {{- $cmpv2CertificateDir := $cmpv2Certificate.mountPath -}}
474 {{- $certType := "pem" -}}
475 {{- if $cmpv2Certificate.keystore -}}
476 {{- $certType = (index $cmpv2Certificate.keystore.outputType 0) -}}
477 {{- end -}}
Piotr Marcinkiewicz70625182021-04-29 17:02:37 +0200478 {{- $truststoresPaths := printf "%s/%s:%s/%s" $certDir "cacert.pem" $cmpv2CertificateDir "cacert.pem" -}}
479 {{- $truststoresPasswordPaths := ":" -}}
480 {{- $keystoreSourcePaths := printf "%s/%s:%s/%s" $cmpv2CertificateDir "cert.pem" $cmpv2CertificateDir "key.pem" -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200481 {{- $keystoreDestinationPaths := printf "%s/%s:%s/%s" $certDir "cert.pem" $certDir "key.pem" -}}
482 {{- if not (eq $certType "pem") -}}
483 {{- $truststoresPaths = printf "%s/%s:%s/%s.%s" $certDir "trust.jks" $cmpv2CertificateDir "truststore" $certType -}}
484 {{- $truststoresPasswordPaths = printf "%s/%s:%s/%s" $certDir "trust.pass" $cmpv2CertificateDir "truststore.pass" -}}
485 {{- $keystoreSourcePaths = printf "%s/%s.%s:%s/%s" $cmpv2CertificateDir "keystore" $certType $cmpv2CertificateDir "keystore.pass" -}}
486 {{- $keystoreDestinationPaths = printf "%s/%s.%s:%s/%s.pass" $certDir "cert" $certType $certDir $certType -}}
487 {{- end }}
488 - name: cert-post-processor
489 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.certPostProcessorImage }}
490 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
491 resources:
492 {{- include "common.resources" . | nindent 4 }}
493 volumeMounts:
494 - mountPath: {{ $certDir }}
495 name: tls-info
496 {{- include "common.certManager.volumeMountsReadOnly" . | nindent 4 }}
497 env:
498 - name: TRUSTSTORES_PATHS
499 value: {{ $truststoresPaths | quote}}
500 - name: TRUSTSTORES_PASSWORDS_PATHS
501 value: {{ $truststoresPasswordPaths | quote }}
502 - name: KEYSTORE_SOURCE_PATHS
503 value: {{ $keystoreSourcePaths | quote }}
504 - name: KEYSTORE_DESTINATION_PATHS
505 value: {{ $keystoreDestinationPaths | quote }}
506 {{- end }}
507{{- end -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200508
509{{/*
510 Template returns string "true" if CMPv2 certificates should be used and nothing (so it can be used in with statements)
511 when they shouldn't. Example use:
512 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
513
514*/}}
515{{- define "dcaegen2-services-common.shouldUseCmpv2Certificates" -}}
516 {{- $certDir := default "" .Values.certDirectory . -}}
Piotr Marcinkiewicz598f2d82021-06-01 12:36:13 +0200517 {{- if (and $certDir .Values.certificates .Values.global.cmpv2Enabled .Values.useCmpv2Certificates) -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200518 true
519 {{- end -}}
520{{- end -}}