blob: 8738b1099ed71c9b8f6db24ae84673725a287c98 [file] [log] [blame]
Jack Lucasd41dbdb2021-02-16 11:07:28 -05001{{/*
2#============LICENSE_START========================================================
3# ================================================================================
4# Copyright (c) 2021 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:
36 1. As literal string values.
37 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 }}
61 value: {{ $envValue | quote }}
62 {{- else }}
63 {{ if or (not $envValue.secretUid) (not $envValue.key) }}
64 {{ fail (printf "Env %s definition is not a string and does not contain secretUid or key fields" $envName) }}
65 {{- end }}
66- name: {{ $envName }}
67 {{- include "common.secret.envFromSecretFast" (dict "global" $global "uid" $envValue.secretUid "key" $envValue.key) | indent 2 }}
68 {{- end -}}
69 {{- end }}
70 {{- end }}
71{{- end -}}
72{{/*
Jack Lucase5f71602021-05-10 12:00:02 -040073For internal use only!
74
75dcaegen2-services-common._externalVolumes:
76This template generates a list of volumes associated with the pod,
77based on information provided in .Values.externalVolumes. This
78template works in conjunction with dcaegen2-services-common._externalVolumeMounts
79to give the microservice access to data in volumes created else.
80This initial implementation supports ConfigMaps only, as this is the only
81external volume mounting required by current microservices.
82
Jack Lucasb880f892021-06-07 16:40:31 -040083.Values.externalVolumes is a list of objects. Each object has 3 required fields and 2 optional fields:
Jack Lucase5f71602021-05-10 12:00:02 -040084 - name: the name of the resource (in the current implementation, it must be a ConfigMap)
85 that is to be set up as a volume. The value is a case sensitive string. Because the
86 names of resources are sometimes set at deployment time (for instance, to prefix the Helm
87 release to the name), the string can be a Helm template fragment that will be expanded at
88 deployment time.
89 - type: the type of the resource (in the current implementation, only "ConfigMap" is supported).
90 The value is a case-INsensitive string.
91 - mountPoint: the path to the mount point for the volume in the container file system. The
92 value is a case-sensitive string.
93 - readOnly: (Optional) Boolean flag. Set to true to mount the volume as read-only.
94 Defaults to false.
Jack Lucasb880f892021-06-07 16:40:31 -040095 - optional: (Optional) Boolean flag. Set to true to make the configMap optional (i.e., to allow the
96 microservice's pod to start even if the configMap doesn't exist). If set to false, the configMap must
97 be present in order for the microservice's pod to start. Defaults to true. (Note that this
98 default is the opposite of the Kubernetes default. We've done this to be consistent with the behavior
99 of the DCAE Cloudify plugin for Kubernetes [k8splugin], which always set "optional" to true.)
Jack Lucase5f71602021-05-10 12:00:02 -0400100
101Here is an example fragment from a values.yaml file for a microservice:
102
103externalVolumes:
104 - name: my-example-configmap
105 type: configmap
106 mountPath: /opt/app/config
107 - name: '{{ include "common.release" . }}-another-example'
108 type: configmap
109 mountPath: /opt/app/otherconfig
Jack Lucasb880f892021-06-07 16:40:31 -0400110 optional: false
Jack Lucase5f71602021-05-10 12:00:02 -0400111*/}}
112{{- define "dcaegen2-services-common._externalVolumes" -}}
113 {{- $global := . -}}
114 {{- if .Values.externalVolumes }}
115 {{- range $vol := .Values.externalVolumes }}
116 {{- if eq (lower $vol.type) "configmap" }}
Jack Lucasb880f892021-06-07 16:40:31 -0400117 {{- $vname := (tpl $vol.name $global) -}}
118 {{- $opt := hasKey $vol "optional" | ternary $vol.optional true }}
Jack Lucase5f71602021-05-10 12:00:02 -0400119- configMap:
120 defaultMode: 420
121 name: {{ $vname }}
Jack Lucasb880f892021-06-07 16:40:31 -0400122 optional: {{ $opt }}
Jack Lucase5f71602021-05-10 12:00:02 -0400123 name: {{ $vname }}
124 {{- end }}
125 {{- end }}
126 {{- end }}
127{{- end }}
128{{/*
129For internal use only!
130
131dcaegen2-services-common._externalVolumeMounts:
132This template generates a list of volume mounts for the microservice container,
133based on information provided in .Values.externalVolumes. This
134template works in conjunction with dcaegen2-services-common._externalVolumes
135to give the microservice access to data in volumes created else.
136This initial implementation supports ConfigMaps only, as this is the only
137external volume mounting required by current microservices.
138
139See the documentation for dcaegen2-services-common._externalVolumes for
140details on how external volumes are specified in the values.yaml file for
141the microservice.
142*/}}
143{{- define "dcaegen2-services-common._externalVolumeMounts" -}}
144 {{- $global := . -}}
145 {{- if .Values.externalVolumes }}
146 {{- range $vol := .Values.externalVolumes }}
147 {{- if eq (lower $vol.type) "configmap" }}
148 {{- $vname := (tpl $vol.name $global) -}}
149 {{- $readOnly := $vol.readOnly | default false }}
150- mountPath: {{ $vol.mountPath }}
151 name: {{ $vname }}
152 readOnly: {{ $readOnly }}
153 {{- end }}
154 {{- end }}
155 {{- end }}
156{{- end }}
157{{/*
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500158dcaegen2-services-common.microserviceDeployment:
159This template produces a Kubernetes Deployment for a DCAE microservice.
160
161All DCAE microservices currently use very similar Deployments. Having a
162common template eliminates a lot of repetition in the individual charts
163for each microservice.
164
165The template expects the full chart context as input. A chart for a
166DCAE microservice references this template using:
167{{ include "dcaegen2-services-common.microserviceDeployment" . }}
168The template directly references data in .Values, and indirectly (through its
169use of templates from the ONAP "common" collection) references data in
170.Release.
171
172The exact content of the Deployment generated from this template
173depends on the content of .Values.
174
175The Deployment always includes a single Pod, with a container that uses
176the DCAE microservice image.
177
178The Deployment Pod may also include a logging sidecar container.
179The sidecar is included if .Values.logDirectory is set. The
180logging sidecar and the DCAE microservice container share a
181volume where the microservice logs are written.
182
183The Deployment includes an initContainer that pushes the
184microservice's initial configuration (from .Values.applicationConfig)
185into Consul. All DCAE microservices retrieve their initial
186configurations by making an API call to a DCAE platform component called
187the config-binding-service. The config-binding-service currently
188retrieves configuration information from Consul.
189
190The Deployment also includes an initContainer that checks for the
191readiness of other components that the microservice relies on.
192This container is generated by the "common.readinessCheck.waitfor"
193template.
194
195If the microservice acts as a TLS client or server, the Deployment will
196include an initContainer that retrieves certificate information from
197the AAF certificate manager. The information is mounted at the
198mount point specified in .Values.certDirectory. If the microservice is
199a TLS server (indicated by setting .Values.tlsServer to true), the
200certificate information will include a server cert and key, in various
201formats. It will also include the AAF CA cert. If the microservice is
202a TLS client only (indicated by setting .Values.tlsServer to false), the
203certificate information includes only the AAF CA cert.
vv770de8c5c682021-04-15 12:21:36 -0400204
205Deployed POD may also include a Policy-sync sidecar container.
206The sidecar is included if .Values.policies is set. The
207Policy-sync sidecar polls PolicyEngine (PDP) periodically based
208on .Values.policies.duration and configuration retrieved is shared with
209DCAE Microservice container by common volume. Policy can be retrieved based on
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400210list of policyID or filter. An optional policyRelease parameter can be specified
211to override the default policy helm release (used for retreiving the secret containing
212pdp username and password)
213
214Following is example policy config override
215
216dcaePolicySyncImage: onap/org.onap.dcaegen2.deployments.dcae-services-policy-sync:1.0.1
217policies:
218 duration: 300
219 policyRelease: "onap"
220 policyID: |
221 '["onap.vfirewall.tca","onap.vdns.tca"]'
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500222*/}}
223
224{{- define "dcaegen2-services-common.microserviceDeployment" -}}
225{{- $logDir := default "" .Values.logDirectory -}}
226{{- $certDir := default "" .Values.certDirectory . -}}
227{{- $tlsServer := default "" .Values.tlsServer -}}
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400228{{- $commonRelease := print (include "common.release" .) -}}
229{{- $policy := default dict .Values.policies -}}
230{{- $policyRls := default $commonRelease $policy.policyRelease -}}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530231{{- $drFeedConfig := default "" .Values.drFeedConfig -}}
vv770de8c5c682021-04-15 12:21:36 -0400232
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500233apiVersion: apps/v1
234kind: Deployment
235metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
236spec:
237 replicas: 1
238 selector: {{- include "common.selectors" . | nindent 4 }}
239 template:
240 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
241 spec:
242 initContainers:
ajay_dp001cf5232a2021-04-13 20:48:07 +0530243 {{- if not $drFeedConfig }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500244 - command:
245 - sh
246 args:
247 - -c
248 - |
249 {{- range $var := .Values.customEnvVars }}
250 export {{ $var.name }}="{{ $var.value }}";
251 {{- end }}
252 cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done
253 env:
254 {{- range $cred := .Values.credentials }}
255 - name: {{ $cred.name }}
256 {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }}
257 {{- end }}
258 volumeMounts:
259 - mountPath: /config-input
260 name: app-config-input
261 - mountPath: /config
262 name: app-config
263 image: {{ include "repositoryGenerator.image.envsubst" . }}
264 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
265 name: {{ include "common.name" . }}-update-config
ajay_dp001cf5232a2021-04-13 20:48:07 +0530266 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500267 {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530268 {{- include "common.dmaap.provisioning.initContainer" . | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500269 - name: init-consul
270 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.consulLoaderImage }}
271 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
272 args:
273 - --key-yaml
274 - "{{ include "common.name" . }}|/app-config/application_config.yaml"
275 resources: {{ include "common.resources" . | nindent 2 }}
276 volumeMounts:
277 - mountPath: /app-config
278 name: app-config
279 {{- if $certDir }}
280 - name: init-tls
281 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.tlsImage }}
282 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
283 env:
284 - name: TLS_SERVER
285 value: {{ $tlsServer | quote }}
286 - name: POD_IP
287 valueFrom:
288 fieldRef:
289 apiVersion: v1
290 fieldPath: status.podIP
291 resources: {{ include "common.resources" . | nindent 2 }}
292 volumeMounts:
293 - mountPath: /opt/app/osaaf
294 name: tls-info
295 {{- end }}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200296 {{ include "dcaegen2-services-common._certPostProcessor" . | nindent 4 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500297 containers:
298 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
299 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
300 name: {{ include "common.name" . }}
301 env:
Bartosz Gardziejewski041a89a2021-05-19 08:05:00 +0200302 {{- range $cred := .Values.credentials }}
303 - name: {{ $cred.name }}
304 {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }}
305 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500306 {{- if $certDir }}
307 - name: DCAE_CA_CERTPATH
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200308 value: {{ $certDir }}/cacert.pem
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500309 {{- end }}
310 - name: CONSUL_HOST
311 value: consul-server.onap
312 - name: CONFIG_BINDING_SERVICE
313 value: config-binding-service
314 - name: CBS_CONFIG_URL
315 value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }}
316 - name: POD_IP
317 valueFrom:
318 fieldRef:
319 apiVersion: v1
320 fieldPath: status.podIP
Jack Lucascbca57d2021-04-05 09:49:46 -0400321 {{- include "dcaegen2-services-common._ms-specific-env-vars" . | nindent 8 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500322 {{- if .Values.service }}
323 ports: {{ include "common.containerPorts" . | nindent 10 }}
324 {{- end }}
325 {{- if .Values.readiness }}
326 readinessProbe:
327 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }}
328 periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
329 timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }}
330 {{- $probeType := .Values.readiness.type | default "httpGet" -}}
331 {{- if eq $probeType "httpGet" }}
332 httpGet:
333 scheme: {{ .Values.readiness.scheme }}
334 path: {{ .Values.readiness.path }}
335 port: {{ .Values.readiness.port }}
336 {{- end }}
337 {{- if eq $probeType "exec" }}
338 exec:
339 command:
340 {{- range $cmd := .Values.readiness.command }}
341 - {{ $cmd }}
342 {{- end }}
343 {{- end }}
344 {{- end }}
345 resources: {{ include "common.resources" . | nindent 2 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500346 volumeMounts:
Bartosz Gardziejewski4bb3da32021-04-21 12:08:50 +0200347 - mountPath: /app-config
348 name: app-config
Bartosz Gardziejewski041a89a2021-05-19 08:05:00 +0200349 - mountPath: /app-config-input
350 name: app-config-input
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500351 {{- if $logDir }}
352 - mountPath: {{ $logDir}}
353 name: component-log
354 {{- end }}
355 {{- if $certDir }}
356 - mountPath: {{ $certDir }}
357 name: tls-info
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200358 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200359 {{- include "common.certManager.volumeMountsReadOnly" . | nindent 8 -}}
360 {{- end -}}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500361 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400362 {{- if $policy }}
363 - name: policy-shared
364 mountPath: /etc/policies
365 {{- end }}
Jack Lucase5f71602021-05-10 12:00:02 -0400366 {{- include "dcaegen2-services-common._externalVolumeMounts" . | nindent 8 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500367 {{- if $logDir }}
368 - image: {{ include "repositoryGenerator.image.logging" . }}
369 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
370 name: filebeat
371 env:
372 - name: POD_IP
373 valueFrom:
374 fieldRef:
375 apiVersion: v1
376 fieldPath: status.podIP
377 resources: {{ include "common.resources" . | nindent 2 }}
378 volumeMounts:
379 - mountPath: /var/log/onap/{{ include "common.name" . }}
380 name: component-log
381 - mountPath: /usr/share/filebeat/data
382 name: filebeat-data
383 - mountPath: /usr/share/filebeat/filebeat.yml
384 name: filebeat-conf
385 subPath: filebeat.yml
386 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400387 {{- if $policy }}
388 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dcaePolicySyncImage }}
389 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
390 name: policy-sync
391 env:
392 - name: POD_IP
393 valueFrom:
394 fieldRef:
395 apiVersion: v1
396 fieldPath: status.podIP
397 - name: POLICY_SYNC_PDP_USER
398 valueFrom:
399 secretKeyRef:
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400400 name: {{ $policyRls }}-policy-xacml-pdp-api-creds
vv770de8c5c682021-04-15 12:21:36 -0400401 key: login
402 - name: POLICY_SYNC_PDP_PASS
403 valueFrom:
404 secretKeyRef:
Vijay Venkatesh Kumar6259f502021-07-26 16:53:11 -0400405 name: {{ $policyRls }}-policy-xacml-pdp-api-creds
vv770de8c5c682021-04-15 12:21:36 -0400406 key: password
407 - name: POLICY_SYNC_PDP_URL
Piotr Marcinkiewicz70625182021-04-29 17:02:37 +0200408 value : http{{ if (include "common.needTLS" .) }}s{{ end }}://policy-xacml-pdp:6969
vv770de8c5c682021-04-15 12:21:36 -0400409 - name: POLICY_SYNC_OUTFILE
410 value : "/etc/policies/policies.json"
411 - name: POLICY_SYNC_V1_DECISION_ENDPOINT
412 value : "policy/pdpx/v1/decision"
413 {{- if $policy.filter }}
414 - name: POLICY_SYNC_FILTER
415 value: {{ $policy.filter }}
416 {{- end -}}
417 {{- if $policy.policyID }}
418 - name: POLICY_SYNC_ID
419 value: {{ $policy.policyID }}
420 {{- end -}}
421 {{- if $policy.duration }}
422 - name: POLICY_SYNC_DURATION
Vijay Venkatesh Kumarc269b262021-06-29 13:49:15 -0400423 value: "{{ $policy.duration }}"
vv770de8c5c682021-04-15 12:21:36 -0400424 {{- end }}
425 resources: {{ include "common.resources" . | nindent 2 }}
426 volumeMounts:
427 - mountPath: /etc/policies
428 name: policy-shared
429 {{- if $certDir }}
430 - mountPath: /opt/ca-certificates/
431 name: tls-info
432 {{- end }}
433 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500434 hostname: {{ include "common.name" . }}
435 volumes:
436 - configMap:
437 defaultMode: 420
438 name: {{ include "common.fullname" . }}-application-config-configmap
439 name: app-config-input
440 - emptyDir:
441 medium: Memory
442 name: app-config
443 {{- if $logDir }}
444 - emptyDir: {}
445 name: component-log
446 - emptyDir: {}
447 name: filebeat-data
448 - configMap:
449 defaultMode: 420
450 name: {{ include "common.fullname" . }}-filebeat-configmap
451 name: filebeat-conf
452 {{- end }}
453 {{- if $certDir }}
454 - emptyDir: {}
455 name: tls-info
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200456 {{ if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200457 {{ include "common.certManager.volumesReadOnly" . | nindent 6 }}
458 {{- end }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500459 {{- end }}
vv770de8c5c682021-04-15 12:21:36 -0400460 {{- if $policy }}
461 - name: policy-shared
462 emptyDir: {}
463 {{- end }}
ajay_dp001cf5232a2021-04-13 20:48:07 +0530464 {{- include "common.dmaap.provisioning._volumes" . | nindent 6 -}}
Jack Lucase5f71602021-05-10 12:00:02 -0400465 {{- include "dcaegen2-services-common._externalVolumes" . | nindent 6 }}
Jack Lucasd41dbdb2021-02-16 11:07:28 -0500466 imagePullSecrets:
467 - name: "{{ include "common.namespace" . }}-docker-registry-key"
468{{ end -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200469
470{{/*
471 For internal use
472
473 Template to attach CertPostProcessor which merges CMPv2 truststore with AAF truststore
474 and swaps keystore files.
475*/}}
476{{- define "dcaegen2-services-common._certPostProcessor" -}}
477 {{- $certDir := default "" .Values.certDirectory . -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200478 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200479 {{- $cmpv2Certificate := (index .Values.certificates 0) -}}
480 {{- $cmpv2CertificateDir := $cmpv2Certificate.mountPath -}}
481 {{- $certType := "pem" -}}
482 {{- if $cmpv2Certificate.keystore -}}
483 {{- $certType = (index $cmpv2Certificate.keystore.outputType 0) -}}
484 {{- end -}}
Piotr Marcinkiewicz70625182021-04-29 17:02:37 +0200485 {{- $truststoresPaths := printf "%s/%s:%s/%s" $certDir "cacert.pem" $cmpv2CertificateDir "cacert.pem" -}}
486 {{- $truststoresPasswordPaths := ":" -}}
487 {{- $keystoreSourcePaths := printf "%s/%s:%s/%s" $cmpv2CertificateDir "cert.pem" $cmpv2CertificateDir "key.pem" -}}
Remigiusz Janeczek9b00b562021-04-26 14:37:57 +0200488 {{- $keystoreDestinationPaths := printf "%s/%s:%s/%s" $certDir "cert.pem" $certDir "key.pem" -}}
489 {{- if not (eq $certType "pem") -}}
490 {{- $truststoresPaths = printf "%s/%s:%s/%s.%s" $certDir "trust.jks" $cmpv2CertificateDir "truststore" $certType -}}
491 {{- $truststoresPasswordPaths = printf "%s/%s:%s/%s" $certDir "trust.pass" $cmpv2CertificateDir "truststore.pass" -}}
492 {{- $keystoreSourcePaths = printf "%s/%s.%s:%s/%s" $cmpv2CertificateDir "keystore" $certType $cmpv2CertificateDir "keystore.pass" -}}
493 {{- $keystoreDestinationPaths = printf "%s/%s.%s:%s/%s.pass" $certDir "cert" $certType $certDir $certType -}}
494 {{- end }}
495 - name: cert-post-processor
496 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.certPostProcessorImage }}
497 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
498 resources:
499 {{- include "common.resources" . | nindent 4 }}
500 volumeMounts:
501 - mountPath: {{ $certDir }}
502 name: tls-info
503 {{- include "common.certManager.volumeMountsReadOnly" . | nindent 4 }}
504 env:
505 - name: TRUSTSTORES_PATHS
506 value: {{ $truststoresPaths | quote}}
507 - name: TRUSTSTORES_PASSWORDS_PATHS
508 value: {{ $truststoresPasswordPaths | quote }}
509 - name: KEYSTORE_SOURCE_PATHS
510 value: {{ $keystoreSourcePaths | quote }}
511 - name: KEYSTORE_DESTINATION_PATHS
512 value: {{ $keystoreDestinationPaths | quote }}
513 {{- end }}
514{{- end -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200515
516{{/*
517 Template returns string "true" if CMPv2 certificates should be used and nothing (so it can be used in with statements)
518 when they shouldn't. Example use:
519 {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}}
520
521*/}}
522{{- define "dcaegen2-services-common.shouldUseCmpv2Certificates" -}}
523 {{- $certDir := default "" .Values.certDirectory . -}}
Piotr Marcinkiewicz598f2d82021-06-01 12:36:13 +0200524 {{- if (and $certDir .Values.certificates .Values.global.cmpv2Enabled .Values.useCmpv2Certificates) -}}
Remigiusz Janeczek7b095032021-05-20 19:39:44 +0200525 true
526 {{- end -}}
527{{- end -}}