2 #============LICENSE_START========================================================
3 # ================================================================================
4 # Copyright (c) 2021 J. F. Lucas. All rights reserved.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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 implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=========================================================
20 dcaegen2-services-common.microserviceDeployment:
21 This template produces a Kubernetes Deployment for a DCAE microservice.
23 All DCAE microservices currently use very similar Deployments. Having a
24 common template eliminates a lot of repetition in the individual charts
25 for each microservice.
27 The template expects the full chart context as input. A chart for a
28 DCAE microservice references this template using:
29 {{ include "dcaegen2-services-common.microserviceDeployment" . }}
30 The template directly references data in .Values, and indirectly (through its
31 use of templates from the ONAP "common" collection) references data in
34 The exact content of the Deployment generated from this template
35 depends on the content of .Values.
37 The Deployment always includes a single Pod, with a container that uses
38 the DCAE microservice image.
40 The Deployment Pod may also include a logging sidecar container.
41 The sidecar is included if .Values.logDirectory is set. The
42 logging sidecar and the DCAE microservice container share a
43 volume where the microservice logs are written.
45 The Deployment includes an initContainer that pushes the
46 microservice's initial configuration (from .Values.applicationConfig)
47 into Consul. All DCAE microservices retrieve their initial
48 configurations by making an API call to a DCAE platform component called
49 the config-binding-service. The config-binding-service currently
50 retrieves configuration information from Consul.
52 The Deployment also includes an initContainer that checks for the
53 readiness of other components that the microservice relies on.
54 This container is generated by the "common.readinessCheck.waitfor"
57 If the microservice acts as a TLS client or server, the Deployment will
58 include an initContainer that retrieves certificate information from
59 the AAF certificate manager. The information is mounted at the
60 mount point specified in .Values.certDirectory. If the microservice is
61 a TLS server (indicated by setting .Values.tlsServer to true), the
62 certificate information will include a server cert and key, in various
63 formats. It will also include the AAF CA cert. If the microservice is
64 a TLS client only (indicated by setting .Values.tlsServer to false), the
65 certificate information includes only the AAF CA cert.
68 {{- define "dcaegen2-services-common.microserviceDeployment" -}}
69 {{- $logDir := default "" .Values.logDirectory -}}
70 {{- $certDir := default "" .Values.certDirectory . -}}
71 {{- $tlsServer := default "" .Values.tlsServer -}}
74 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
77 selector: {{- include "common.selectors" . | nindent 4 }}
79 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
87 {{- range $var := .Values.customEnvVars }}
88 export {{ $var.name }}="{{ $var.value }}";
90 cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done
92 {{- range $cred := .Values.credentials }}
93 - name: {{ $cred.name }}
94 {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }}
97 - mountPath: /config-input
98 name: app-config-input
101 image: {{ include "repositoryGenerator.image.envsubst" . }}
102 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
103 name: {{ include "common.name" . }}-update-config
105 {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
107 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.consulLoaderImage }}
108 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
111 - "{{ include "common.name" . }}|/app-config/application_config.yaml"
112 resources: {{ include "common.resources" . | nindent 2 }}
114 - mountPath: /app-config
118 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.tlsImage }}
119 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
122 value: {{ $tlsServer | quote }}
127 fieldPath: status.podIP
128 resources: {{ include "common.resources" . | nindent 2 }}
130 - mountPath: /opt/app/osaaf
134 - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
135 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
136 name: {{ include "common.name" . }}
139 - name: DCAE_CA_CERTPATH
140 value: {{ $certDir}}/cacert.pem
143 value: consul-server.onap
144 - name: CONFIG_BINDING_SERVICE
145 value: config-binding-service
146 - name: CBS_CONFIG_URL
147 value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }}
152 fieldPath: status.podIP
153 {{- if .Values.applicationEnv }}
154 {{- range $envName, $envValue := .Values.applicationEnv }}
155 - name: {{ $envName }}
156 value: {{ $envValue | quote }}
159 {{- if .Values.service }}
160 ports: {{ include "common.containerPorts" . | nindent 10 }}
162 {{- if .Values.readiness }}
164 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }}
165 periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
166 timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }}
167 {{- $probeType := .Values.readiness.type | default "httpGet" -}}
168 {{- if eq $probeType "httpGet" }}
170 scheme: {{ .Values.readiness.scheme }}
171 path: {{ .Values.readiness.path }}
172 port: {{ .Values.readiness.port }}
174 {{- if eq $probeType "exec" }}
177 {{- range $cmd := .Values.readiness.command }}
182 resources: {{ include "common.resources" . | nindent 2 }}
183 {{- if or $logDir $certDir }}
186 - mountPath: {{ $logDir}}
190 - mountPath: {{ $certDir }}
195 - image: {{ include "repositoryGenerator.image.logging" . }}
196 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
203 fieldPath: status.podIP
204 resources: {{ include "common.resources" . | nindent 2 }}
206 - mountPath: /var/log/onap/{{ include "common.name" . }}
208 - mountPath: /usr/share/filebeat/data
210 - mountPath: /usr/share/filebeat/filebeat.yml
212 subPath: filebeat.yml
214 hostname: {{ include "common.name" . }}
218 name: {{ include "common.fullname" . }}-application-config-configmap
219 name: app-config-input
230 name: {{ include "common.fullname" . }}-filebeat-configmap
238 - name: "{{ include "common.namespace" . }}-docker-registry-key"