2 #============LICENSE_START========================================================
3 # ================================================================================
4 # Copyright (c) 2021 J. F. Lucas. All rights reserved.
5 # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
21 For internal use only!
23 dcaegen2-services-common._ms-specific-env-vars:
24 This template generates a list of microservice-specific environment variables
25 as specified in .Values.applicationEnv. The
26 dcaegen2-services-common.microServiceDeployment uses this template
27 to add the microservice-specific environment variables to the microservice's container.
28 These environment variables are in addition to a standard set of environment variables
29 provided to all microservices.
31 The template expects a single argument, pointing to the caller's global context.
33 Microservice-specific environment variables can be specified in two ways:
34 1. As literal string values.
35 2. As values that are sourced from a secret, identified by the secret's
36 uid and the key within the secret that provides the value.
38 The following example shows an example of each type. The example assumes
39 that a secret has been created using the OOM common secret mechanism, with
40 a secret uid "example-secret" and a key called "password".
44 secretUid: example-secret
46 APPLICATION_EXAMPLE: "An example value"
48 The example would set two environment variables on the microservice's container,
49 one called "APPLICATION_PASSWORD" with the value set from the "password" key in
50 the secret with uid "example-secret", and one called "APPLICATION_EXAMPLE" set to
51 the the literal string "An example value".
53 {{- define "dcaegen2-services-common._ms-specific-env-vars" -}}
55 {{- if .Values.applicationEnv }}
56 {{- range $envName, $envValue := .Values.applicationEnv }}
57 {{- if kindIs "string" $envValue }}
58 - name: {{ $envName }}
59 value: {{ $envValue | quote }}
61 {{ if or (not $envValue.secretUid) (not $envValue.key) }}
62 {{ fail (printf "Env %s definition is not a string and does not contain secretUid or key fields" $envName) }}
64 - name: {{ $envName }}
65 {{- include "common.secret.envFromSecretFast" (dict "global" $global "uid" $envValue.secretUid "key" $envValue.key) | indent 2 }}
71 For internal use only!
73 dcaegen2-services-common._externalVolumes:
74 This template generates a list of volumes associated with the pod,
75 based on information provided in .Values.externalVolumes. This
76 template works in conjunction with dcaegen2-services-common._externalVolumeMounts
77 to give the microservice access to data in volumes created else.
78 This initial implementation supports ConfigMaps only, as this is the only
79 external volume mounting required by current microservices.
81 .Values.externalValues is a list of objects. Each object has 3 required fields and 1 optional field:
82 - name: the name of the resource (in the current implementation, it must be a ConfigMap)
83 that is to be set up as a volume. The value is a case sensitive string. Because the
84 names of resources are sometimes set at deployment time (for instance, to prefix the Helm
85 release to the name), the string can be a Helm template fragment that will be expanded at
87 - type: the type of the resource (in the current implementation, only "ConfigMap" is supported).
88 The value is a case-INsensitive string.
89 - mountPoint: the path to the mount point for the volume in the container file system. The
90 value is a case-sensitive string.
91 - readOnly: (Optional) Boolean flag. Set to true to mount the volume as read-only.
94 Here is an example fragment from a values.yaml file for a microservice:
97 - name: my-example-configmap
99 mountPath: /opt/app/config
100 - name: '{{ include "common.release" . }}-another-example'
102 mountPath: /opt/app/otherconfig
104 {{- define "dcaegen2-services-common._externalVolumes" -}}
106 {{- if .Values.externalVolumes }}
107 {{- range $vol := .Values.externalVolumes }}
108 {{- if eq (lower $vol.type) "configmap" }}
109 {{- $vname := (tpl $vol.name $global) }}
119 For internal use only!
121 dcaegen2-services-common._externalVolumeMounts:
122 This template generates a list of volume mounts for the microservice container,
123 based on information provided in .Values.externalVolumes. This
124 template works in conjunction with dcaegen2-services-common._externalVolumes
125 to give the microservice access to data in volumes created else.
126 This initial implementation supports ConfigMaps only, as this is the only
127 external volume mounting required by current microservices.
129 See the documentation for dcaegen2-services-common._externalVolumes for
130 details on how external volumes are specified in the values.yaml file for
133 {{- define "dcaegen2-services-common._externalVolumeMounts" -}}
135 {{- if .Values.externalVolumes }}
136 {{- range $vol := .Values.externalVolumes }}
137 {{- if eq (lower $vol.type) "configmap" }}
138 {{- $vname := (tpl $vol.name $global) -}}
139 {{- $readOnly := $vol.readOnly | default false }}
140 - mountPath: {{ $vol.mountPath }}
142 readOnly: {{ $readOnly }}
148 dcaegen2-services-common.microserviceDeployment:
149 This template produces a Kubernetes Deployment for a DCAE microservice.
151 All DCAE microservices currently use very similar Deployments. Having a
152 common template eliminates a lot of repetition in the individual charts
153 for each microservice.
155 The template expects the full chart context as input. A chart for a
156 DCAE microservice references this template using:
157 {{ include "dcaegen2-services-common.microserviceDeployment" . }}
158 The template directly references data in .Values, and indirectly (through its
159 use of templates from the ONAP "common" collection) references data in
162 The exact content of the Deployment generated from this template
163 depends on the content of .Values.
165 The Deployment always includes a single Pod, with a container that uses
166 the DCAE microservice image.
168 The Deployment Pod may also include a logging sidecar container.
169 The sidecar is included if .Values.logDirectory is set. The
170 logging sidecar and the DCAE microservice container share a
171 volume where the microservice logs are written.
173 The Deployment includes an initContainer that pushes the
174 microservice's initial configuration (from .Values.applicationConfig)
175 into Consul. All DCAE microservices retrieve their initial
176 configurations by making an API call to a DCAE platform component called
177 the config-binding-service. The config-binding-service currently
178 retrieves configuration information from Consul.
180 The Deployment also includes an initContainer that checks for the
181 readiness of other components that the microservice relies on.
182 This container is generated by the "common.readinessCheck.waitfor"
185 If the microservice acts as a TLS client or server, the Deployment will
186 include an initContainer that retrieves certificate information from
187 the AAF certificate manager. The information is mounted at the
188 mount point specified in .Values.certDirectory. If the microservice is
189 a TLS server (indicated by setting .Values.tlsServer to true), the
190 certificate information will include a server cert and key, in various
191 formats. It will also include the AAF CA cert. If the microservice is
192 a TLS client only (indicated by setting .Values.tlsServer to false), the
193 certificate information includes only the AAF CA cert.
195 Deployed POD may also include a Policy-sync sidecar container.
196 The sidecar is included if .Values.policies is set. The
197 Policy-sync sidecar polls PolicyEngine (PDP) periodically based
198 on .Values.policies.duration and configuration retrieved is shared with
199 DCAE Microservice container by common volume. Policy can be retrieved based on
200 list of policyID or filter
203 {{- define "dcaegen2-services-common.microserviceDeployment" -}}
204 {{- $logDir := default "" .Values.logDirectory -}}
205 {{- $certDir := default "" .Values.certDirectory . -}}
206 {{- $tlsServer := default "" .Values.tlsServer -}}
207 {{- $policy := default "" .Values.policies -}}
211 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
214 selector: {{- include "common.selectors" . | nindent 4 }}
216 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
224 {{- range $var := .Values.customEnvVars }}
225 export {{ $var.name }}="{{ $var.value }}";
227 cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done
229 {{- range $cred := .Values.credentials }}
230 - name: {{ $cred.name }}
231 {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }}
234 - mountPath: /config-input
235 name: app-config-input
238 image: {{ include "repositoryGenerator.image.envsubst" . }}
239 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
240 name: {{ include "common.name" . }}-update-config
242 {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
244 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.consulLoaderImage }}
245 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
248 - "{{ include "common.name" . }}|/app-config/application_config.yaml"
249 resources: {{ include "common.resources" . | nindent 2 }}
251 - mountPath: /app-config
255 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.tlsImage }}
256 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
259 value: {{ $tlsServer | quote }}
264 fieldPath: status.podIP
265 resources: {{ include "common.resources" . | nindent 2 }}
267 - mountPath: /opt/app/osaaf
271 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
272 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
273 name: {{ include "common.name" . }}
276 - name: DCAE_CA_CERTPATH
277 value: {{ $certDir}}/cacert.pem
280 value: consul-server.onap
281 - name: CONFIG_BINDING_SERVICE
282 value: config-binding-service
283 - name: CBS_CONFIG_URL
284 value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }}
289 fieldPath: status.podIP
290 {{- include "dcaegen2-services-common._ms-specific-env-vars" . | nindent 8 }}
291 {{- if .Values.service }}
292 ports: {{ include "common.containerPorts" . | nindent 10 }}
294 {{- if .Values.readiness }}
296 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }}
297 periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
298 timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }}
299 {{- $probeType := .Values.readiness.type | default "httpGet" -}}
300 {{- if eq $probeType "httpGet" }}
302 scheme: {{ .Values.readiness.scheme }}
303 path: {{ .Values.readiness.path }}
304 port: {{ .Values.readiness.port }}
306 {{- if eq $probeType "exec" }}
309 {{- range $cmd := .Values.readiness.command }}
314 resources: {{ include "common.resources" . | nindent 2 }}
316 - mountPath: /app-config
319 - mountPath: {{ $logDir}}
323 - mountPath: {{ $certDir }}
327 - name: policy-shared
328 mountPath: /etc/policies
330 {{- include "dcaegen2-services-common._externalVolumeMounts" . | nindent 8 }}
332 - image: {{ include "repositoryGenerator.image.logging" . }}
333 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
340 fieldPath: status.podIP
341 resources: {{ include "common.resources" . | nindent 2 }}
343 - mountPath: /var/log/onap/{{ include "common.name" . }}
345 - mountPath: /usr/share/filebeat/data
347 - mountPath: /usr/share/filebeat/filebeat.yml
349 subPath: filebeat.yml
352 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dcaePolicySyncImage }}
353 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
360 fieldPath: status.podIP
361 - name: POLICY_SYNC_PDP_USER
364 name: onap-policy-xacml-pdp-api-creds
366 - name: POLICY_SYNC_PDP_PASS
369 name: onap-policy-xacml-pdp-api-creds
371 - name: POLICY_SYNC_PDP_URL
372 value : http{{ if (include "common.needTLS" .) }}s{{ end }}://policy-xacml-pdp:6969
373 - name: POLICY_SYNC_OUTFILE
374 value : "/etc/policies/policies.json"
375 - name: POLICY_SYNC_V1_DECISION_ENDPOINT
376 value : "policy/pdpx/v1/decision"
377 {{- if $policy.filter }}
378 - name: POLICY_SYNC_FILTER
379 value: {{ $policy.filter }}
381 {{- if $policy.policyID }}
382 - name: POLICY_SYNC_ID
383 value: {{ $policy.policyID }}
385 {{- if $policy.duration }}
386 - name: POLICY_SYNC_DURATION
387 value: {{ $policy.duration }}
389 resources: {{ include "common.resources" . | nindent 2 }}
391 - mountPath: /etc/policies
394 - mountPath: /opt/ca-certificates/
398 hostname: {{ include "common.name" . }}
402 name: {{ include "common.fullname" . }}-application-config-configmap
403 name: app-config-input
414 name: {{ include "common.fullname" . }}-filebeat-configmap
422 - name: policy-shared
425 {{- include "dcaegen2-services-common._externalVolumes" . | nindent 6 }}
427 - name: "{{ include "common.namespace" . }}-docker-registry-key"