Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 1 | {{/* |
| 2 | #============LICENSE_START======================================================== |
| 3 | # ================================================================================ |
| 4 | # Copyright (c) 2021 J. F. Lucas. All rights reserved. |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 5 | # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. |
Piotr Marcinkiewicz | 7062518 | 2021-04-29 17:02:37 +0200 | [diff] [blame] | 6 | # Copyright (c) 2021 Nokia. All rights reserved. |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 7 | # Copyright (c) 2021 Nordix Foundation. |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 8 | # ================================================================================ |
| 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 Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 23 | For internal use only! |
| 24 | |
| 25 | dcaegen2-services-common._ms-specific-env-vars: |
| 26 | This template generates a list of microservice-specific environment variables |
| 27 | as specified in .Values.applicationEnv. The |
| 28 | dcaegen2-services-common.microServiceDeployment uses this template |
| 29 | to add the microservice-specific environment variables to the microservice's container. |
| 30 | These environment variables are in addition to a standard set of environment variables |
| 31 | provided to all microservices. |
| 32 | |
| 33 | The template expects a single argument, pointing to the caller's global context. |
| 34 | |
| 35 | Microservice-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 | |
| 40 | The following example shows an example of each type. The example assumes |
| 41 | that a secret has been created using the OOM common secret mechanism, with |
| 42 | a secret uid "example-secret" and a key called "password". |
| 43 | |
| 44 | applicationEnv: |
| 45 | APPLICATION_PASSWORD: |
| 46 | secretUid: example-secret |
| 47 | key: password |
| 48 | APPLICATION_EXAMPLE: "An example value" |
| 49 | |
| 50 | The example would set two environment variables on the microservice's container, |
| 51 | one called "APPLICATION_PASSWORD" with the value set from the "password" key in |
| 52 | the secret with uid "example-secret", and one called "APPLICATION_EXAMPLE" set to |
| 53 | the 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 Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 73 | For internal use only! |
| 74 | |
| 75 | dcaegen2-services-common._externalVolumes: |
| 76 | This template generates a list of volumes associated with the pod, |
| 77 | based on information provided in .Values.externalVolumes. This |
| 78 | template works in conjunction with dcaegen2-services-common._externalVolumeMounts |
| 79 | to give the microservice access to data in volumes created else. |
| 80 | This initial implementation supports ConfigMaps only, as this is the only |
| 81 | external volume mounting required by current microservices. |
| 82 | |
Jack Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 83 | .Values.externalVolumes is a list of objects. Each object has 3 required fields and 2 optional fields: |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 84 | - 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 95 | - 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 Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 100 | |
| 101 | Here is an example fragment from a values.yaml file for a microservice: |
| 102 | |
| 103 | externalVolumes: |
| 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 110 | optional: false |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 111 | */}} |
| 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 117 | {{- $vname := (tpl $vol.name $global) -}} |
| 118 | {{- $opt := hasKey $vol "optional" | ternary $vol.optional true }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 119 | - configMap: |
| 120 | defaultMode: 420 |
| 121 | name: {{ $vname }} |
Jack Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 122 | optional: {{ $opt }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 123 | name: {{ $vname }} |
| 124 | {{- end }} |
| 125 | {{- end }} |
| 126 | {{- end }} |
| 127 | {{- end }} |
| 128 | {{/* |
| 129 | For internal use only! |
| 130 | |
| 131 | dcaegen2-services-common._externalVolumeMounts: |
| 132 | This template generates a list of volume mounts for the microservice container, |
| 133 | based on information provided in .Values.externalVolumes. This |
| 134 | template works in conjunction with dcaegen2-services-common._externalVolumes |
| 135 | to give the microservice access to data in volumes created else. |
| 136 | This initial implementation supports ConfigMaps only, as this is the only |
| 137 | external volume mounting required by current microservices. |
| 138 | |
| 139 | See the documentation for dcaegen2-services-common._externalVolumes for |
| 140 | details on how external volumes are specified in the values.yaml file for |
| 141 | the 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 Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 158 | dcaegen2-services-common.microserviceDeployment: |
| 159 | This template produces a Kubernetes Deployment for a DCAE microservice. |
| 160 | |
| 161 | All DCAE microservices currently use very similar Deployments. Having a |
| 162 | common template eliminates a lot of repetition in the individual charts |
| 163 | for each microservice. |
| 164 | |
| 165 | The template expects the full chart context as input. A chart for a |
| 166 | DCAE microservice references this template using: |
| 167 | {{ include "dcaegen2-services-common.microserviceDeployment" . }} |
| 168 | The template directly references data in .Values, and indirectly (through its |
| 169 | use of templates from the ONAP "common" collection) references data in |
| 170 | .Release. |
| 171 | |
| 172 | The exact content of the Deployment generated from this template |
| 173 | depends on the content of .Values. |
| 174 | |
| 175 | The Deployment always includes a single Pod, with a container that uses |
| 176 | the DCAE microservice image. |
| 177 | |
| 178 | The Deployment Pod may also include a logging sidecar container. |
| 179 | The sidecar is included if .Values.logDirectory is set. The |
| 180 | logging sidecar and the DCAE microservice container share a |
| 181 | volume where the microservice logs are written. |
| 182 | |
| 183 | The Deployment includes an initContainer that pushes the |
| 184 | microservice's initial configuration (from .Values.applicationConfig) |
| 185 | into Consul. All DCAE microservices retrieve their initial |
| 186 | configurations by making an API call to a DCAE platform component called |
| 187 | the config-binding-service. The config-binding-service currently |
| 188 | retrieves configuration information from Consul. |
| 189 | |
| 190 | The Deployment also includes an initContainer that checks for the |
| 191 | readiness of other components that the microservice relies on. |
| 192 | This container is generated by the "common.readinessCheck.waitfor" |
| 193 | template. |
| 194 | |
| 195 | If the microservice acts as a TLS client or server, the Deployment will |
| 196 | include an initContainer that retrieves certificate information from |
| 197 | the AAF certificate manager. The information is mounted at the |
| 198 | mount point specified in .Values.certDirectory. If the microservice is |
| 199 | a TLS server (indicated by setting .Values.tlsServer to true), the |
| 200 | certificate information will include a server cert and key, in various |
| 201 | formats. It will also include the AAF CA cert. If the microservice is |
| 202 | a TLS client only (indicated by setting .Values.tlsServer to false), the |
| 203 | certificate information includes only the AAF CA cert. |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 204 | |
| 205 | Deployed POD may also include a Policy-sync sidecar container. |
| 206 | The sidecar is included if .Values.policies is set. The |
| 207 | Policy-sync sidecar polls PolicyEngine (PDP) periodically based |
| 208 | on .Values.policies.duration and configuration retrieved is shared with |
| 209 | DCAE Microservice container by common volume. Policy can be retrieved based on |
| 210 | list of policyID or filter |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 211 | */}} |
| 212 | |
| 213 | {{- define "dcaegen2-services-common.microserviceDeployment" -}} |
| 214 | {{- $logDir := default "" .Values.logDirectory -}} |
| 215 | {{- $certDir := default "" .Values.certDirectory . -}} |
| 216 | {{- $tlsServer := default "" .Values.tlsServer -}} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 217 | {{- $policy := default "" .Values.policies -}} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 218 | {{- $drFeedConfig := default "" .Values.drFeedConfig -}} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 219 | |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 220 | apiVersion: apps/v1 |
| 221 | kind: Deployment |
| 222 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
| 223 | spec: |
| 224 | replicas: 1 |
| 225 | selector: {{- include "common.selectors" . | nindent 4 }} |
| 226 | template: |
| 227 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
| 228 | spec: |
| 229 | initContainers: |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 230 | {{- if not $drFeedConfig }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 231 | - command: |
| 232 | - sh |
| 233 | args: |
| 234 | - -c |
| 235 | - | |
| 236 | {{- range $var := .Values.customEnvVars }} |
| 237 | export {{ $var.name }}="{{ $var.value }}"; |
| 238 | {{- end }} |
| 239 | cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done |
| 240 | env: |
| 241 | {{- range $cred := .Values.credentials }} |
| 242 | - name: {{ $cred.name }} |
| 243 | {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }} |
| 244 | {{- end }} |
| 245 | volumeMounts: |
| 246 | - mountPath: /config-input |
| 247 | name: app-config-input |
| 248 | - mountPath: /config |
| 249 | name: app-config |
| 250 | image: {{ include "repositoryGenerator.image.envsubst" . }} |
| 251 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 252 | name: {{ include "common.name" . }}-update-config |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 253 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 254 | {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 255 | {{- include "common.dmaap.provisioning.initContainer" . | nindent 6 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 256 | - name: init-consul |
| 257 | image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.consulLoaderImage }} |
| 258 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 259 | args: |
| 260 | - --key-yaml |
| 261 | - "{{ include "common.name" . }}|/app-config/application_config.yaml" |
| 262 | resources: {{ include "common.resources" . | nindent 2 }} |
| 263 | volumeMounts: |
| 264 | - mountPath: /app-config |
| 265 | name: app-config |
| 266 | {{- if $certDir }} |
| 267 | - name: init-tls |
| 268 | image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.tlsImage }} |
| 269 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 270 | env: |
| 271 | - name: TLS_SERVER |
| 272 | value: {{ $tlsServer | quote }} |
| 273 | - name: POD_IP |
| 274 | valueFrom: |
| 275 | fieldRef: |
| 276 | apiVersion: v1 |
| 277 | fieldPath: status.podIP |
| 278 | resources: {{ include "common.resources" . | nindent 2 }} |
| 279 | volumeMounts: |
| 280 | - mountPath: /opt/app/osaaf |
| 281 | name: tls-info |
| 282 | {{- end }} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 283 | {{ include "dcaegen2-services-common._certPostProcessor" . | nindent 4 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 284 | containers: |
| 285 | - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }} |
| 286 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 287 | name: {{ include "common.name" . }} |
| 288 | env: |
Bartosz Gardziejewski | 041a89a | 2021-05-19 08:05:00 +0200 | [diff] [blame] | 289 | {{- range $cred := .Values.credentials }} |
| 290 | - name: {{ $cred.name }} |
| 291 | {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }} |
| 292 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 293 | {{- if $certDir }} |
| 294 | - name: DCAE_CA_CERTPATH |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 295 | value: {{ $certDir }}/cacert.pem |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 296 | {{- end }} |
| 297 | - name: CONSUL_HOST |
| 298 | value: consul-server.onap |
| 299 | - name: CONFIG_BINDING_SERVICE |
| 300 | value: config-binding-service |
| 301 | - name: CBS_CONFIG_URL |
| 302 | value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }} |
| 303 | - name: POD_IP |
| 304 | valueFrom: |
| 305 | fieldRef: |
| 306 | apiVersion: v1 |
| 307 | fieldPath: status.podIP |
Jack Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 308 | {{- include "dcaegen2-services-common._ms-specific-env-vars" . | nindent 8 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 309 | {{- if .Values.service }} |
| 310 | ports: {{ include "common.containerPorts" . | nindent 10 }} |
| 311 | {{- end }} |
| 312 | {{- if .Values.readiness }} |
| 313 | readinessProbe: |
| 314 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }} |
| 315 | periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }} |
| 316 | timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }} |
| 317 | {{- $probeType := .Values.readiness.type | default "httpGet" -}} |
| 318 | {{- if eq $probeType "httpGet" }} |
| 319 | httpGet: |
| 320 | scheme: {{ .Values.readiness.scheme }} |
| 321 | path: {{ .Values.readiness.path }} |
| 322 | port: {{ .Values.readiness.port }} |
| 323 | {{- end }} |
| 324 | {{- if eq $probeType "exec" }} |
| 325 | exec: |
| 326 | command: |
| 327 | {{- range $cmd := .Values.readiness.command }} |
| 328 | - {{ $cmd }} |
| 329 | {{- end }} |
| 330 | {{- end }} |
| 331 | {{- end }} |
| 332 | resources: {{ include "common.resources" . | nindent 2 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 333 | volumeMounts: |
Bartosz Gardziejewski | 4bb3da3 | 2021-04-21 12:08:50 +0200 | [diff] [blame] | 334 | - mountPath: /app-config |
| 335 | name: app-config |
Bartosz Gardziejewski | 041a89a | 2021-05-19 08:05:00 +0200 | [diff] [blame] | 336 | - mountPath: /app-config-input |
| 337 | name: app-config-input |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 338 | {{- if $logDir }} |
| 339 | - mountPath: {{ $logDir}} |
| 340 | name: component-log |
| 341 | {{- end }} |
| 342 | {{- if $certDir }} |
| 343 | - mountPath: {{ $certDir }} |
| 344 | name: tls-info |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 345 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 346 | {{- include "common.certManager.volumeMountsReadOnly" . | nindent 8 -}} |
| 347 | {{- end -}} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 348 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 349 | {{- if $policy }} |
| 350 | - name: policy-shared |
| 351 | mountPath: /etc/policies |
| 352 | {{- end }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 353 | {{- include "dcaegen2-services-common._externalVolumeMounts" . | nindent 8 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 354 | {{- if $logDir }} |
| 355 | - image: {{ include "repositoryGenerator.image.logging" . }} |
| 356 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 357 | name: filebeat |
| 358 | env: |
| 359 | - name: POD_IP |
| 360 | valueFrom: |
| 361 | fieldRef: |
| 362 | apiVersion: v1 |
| 363 | fieldPath: status.podIP |
| 364 | resources: {{ include "common.resources" . | nindent 2 }} |
| 365 | volumeMounts: |
| 366 | - mountPath: /var/log/onap/{{ include "common.name" . }} |
| 367 | name: component-log |
| 368 | - mountPath: /usr/share/filebeat/data |
| 369 | name: filebeat-data |
| 370 | - mountPath: /usr/share/filebeat/filebeat.yml |
| 371 | name: filebeat-conf |
| 372 | subPath: filebeat.yml |
| 373 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 374 | {{- if $policy }} |
| 375 | - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dcaePolicySyncImage }} |
| 376 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 377 | name: policy-sync |
| 378 | env: |
| 379 | - name: POD_IP |
| 380 | valueFrom: |
| 381 | fieldRef: |
| 382 | apiVersion: v1 |
| 383 | fieldPath: status.podIP |
| 384 | - name: POLICY_SYNC_PDP_USER |
| 385 | valueFrom: |
| 386 | secretKeyRef: |
| 387 | name: onap-policy-xacml-pdp-api-creds |
| 388 | key: login |
| 389 | - name: POLICY_SYNC_PDP_PASS |
| 390 | valueFrom: |
| 391 | secretKeyRef: |
| 392 | name: onap-policy-xacml-pdp-api-creds |
| 393 | key: password |
| 394 | - name: POLICY_SYNC_PDP_URL |
Piotr Marcinkiewicz | 7062518 | 2021-04-29 17:02:37 +0200 | [diff] [blame] | 395 | value : http{{ if (include "common.needTLS" .) }}s{{ end }}://policy-xacml-pdp:6969 |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 396 | - name: POLICY_SYNC_OUTFILE |
| 397 | value : "/etc/policies/policies.json" |
| 398 | - name: POLICY_SYNC_V1_DECISION_ENDPOINT |
| 399 | value : "policy/pdpx/v1/decision" |
| 400 | {{- if $policy.filter }} |
| 401 | - name: POLICY_SYNC_FILTER |
| 402 | value: {{ $policy.filter }} |
| 403 | {{- end -}} |
| 404 | {{- if $policy.policyID }} |
| 405 | - name: POLICY_SYNC_ID |
| 406 | value: {{ $policy.policyID }} |
| 407 | {{- end -}} |
| 408 | {{- if $policy.duration }} |
| 409 | - name: POLICY_SYNC_DURATION |
| 410 | value: {{ $policy.duration }} |
| 411 | {{- end }} |
| 412 | resources: {{ include "common.resources" . | nindent 2 }} |
| 413 | volumeMounts: |
| 414 | - mountPath: /etc/policies |
| 415 | name: policy-shared |
| 416 | {{- if $certDir }} |
| 417 | - mountPath: /opt/ca-certificates/ |
| 418 | name: tls-info |
| 419 | {{- end }} |
| 420 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 421 | hostname: {{ include "common.name" . }} |
| 422 | volumes: |
| 423 | - configMap: |
| 424 | defaultMode: 420 |
| 425 | name: {{ include "common.fullname" . }}-application-config-configmap |
| 426 | name: app-config-input |
| 427 | - emptyDir: |
| 428 | medium: Memory |
| 429 | name: app-config |
| 430 | {{- if $logDir }} |
| 431 | - emptyDir: {} |
| 432 | name: component-log |
| 433 | - emptyDir: {} |
| 434 | name: filebeat-data |
| 435 | - configMap: |
| 436 | defaultMode: 420 |
| 437 | name: {{ include "common.fullname" . }}-filebeat-configmap |
| 438 | name: filebeat-conf |
| 439 | {{- end }} |
| 440 | {{- if $certDir }} |
| 441 | - emptyDir: {} |
| 442 | name: tls-info |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 443 | {{ if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 444 | {{ include "common.certManager.volumesReadOnly" . | nindent 6 }} |
| 445 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 446 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 447 | {{- if $policy }} |
| 448 | - name: policy-shared |
| 449 | emptyDir: {} |
| 450 | {{- end }} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame^] | 451 | {{- include "common.dmaap.provisioning._volumes" . | nindent 6 -}} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 452 | {{- include "dcaegen2-services-common._externalVolumes" . | nindent 6 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 453 | imagePullSecrets: |
| 454 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
| 455 | {{ end -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 456 | |
| 457 | {{/* |
| 458 | For internal use |
| 459 | |
| 460 | Template to attach CertPostProcessor which merges CMPv2 truststore with AAF truststore |
| 461 | and swaps keystore files. |
| 462 | */}} |
| 463 | {{- define "dcaegen2-services-common._certPostProcessor" -}} |
| 464 | {{- $certDir := default "" .Values.certDirectory . -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 465 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 466 | {{- $cmpv2Certificate := (index .Values.certificates 0) -}} |
| 467 | {{- $cmpv2CertificateDir := $cmpv2Certificate.mountPath -}} |
| 468 | {{- $certType := "pem" -}} |
| 469 | {{- if $cmpv2Certificate.keystore -}} |
| 470 | {{- $certType = (index $cmpv2Certificate.keystore.outputType 0) -}} |
| 471 | {{- end -}} |
Piotr Marcinkiewicz | 7062518 | 2021-04-29 17:02:37 +0200 | [diff] [blame] | 472 | {{- $truststoresPaths := printf "%s/%s:%s/%s" $certDir "cacert.pem" $cmpv2CertificateDir "cacert.pem" -}} |
| 473 | {{- $truststoresPasswordPaths := ":" -}} |
| 474 | {{- $keystoreSourcePaths := printf "%s/%s:%s/%s" $cmpv2CertificateDir "cert.pem" $cmpv2CertificateDir "key.pem" -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 475 | {{- $keystoreDestinationPaths := printf "%s/%s:%s/%s" $certDir "cert.pem" $certDir "key.pem" -}} |
| 476 | {{- if not (eq $certType "pem") -}} |
| 477 | {{- $truststoresPaths = printf "%s/%s:%s/%s.%s" $certDir "trust.jks" $cmpv2CertificateDir "truststore" $certType -}} |
| 478 | {{- $truststoresPasswordPaths = printf "%s/%s:%s/%s" $certDir "trust.pass" $cmpv2CertificateDir "truststore.pass" -}} |
| 479 | {{- $keystoreSourcePaths = printf "%s/%s.%s:%s/%s" $cmpv2CertificateDir "keystore" $certType $cmpv2CertificateDir "keystore.pass" -}} |
| 480 | {{- $keystoreDestinationPaths = printf "%s/%s.%s:%s/%s.pass" $certDir "cert" $certType $certDir $certType -}} |
| 481 | {{- end }} |
| 482 | - name: cert-post-processor |
| 483 | image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.certPostProcessorImage }} |
| 484 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 485 | resources: |
| 486 | {{- include "common.resources" . | nindent 4 }} |
| 487 | volumeMounts: |
| 488 | - mountPath: {{ $certDir }} |
| 489 | name: tls-info |
| 490 | {{- include "common.certManager.volumeMountsReadOnly" . | nindent 4 }} |
| 491 | env: |
| 492 | - name: TRUSTSTORES_PATHS |
| 493 | value: {{ $truststoresPaths | quote}} |
| 494 | - name: TRUSTSTORES_PASSWORDS_PATHS |
| 495 | value: {{ $truststoresPasswordPaths | quote }} |
| 496 | - name: KEYSTORE_SOURCE_PATHS |
| 497 | value: {{ $keystoreSourcePaths | quote }} |
| 498 | - name: KEYSTORE_DESTINATION_PATHS |
| 499 | value: {{ $keystoreDestinationPaths | quote }} |
| 500 | {{- end }} |
| 501 | {{- end -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 502 | |
| 503 | {{/* |
| 504 | Template returns string "true" if CMPv2 certificates should be used and nothing (so it can be used in with statements) |
| 505 | when they shouldn't. Example use: |
| 506 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
| 507 | |
| 508 | */}} |
| 509 | {{- define "dcaegen2-services-common.shouldUseCmpv2Certificates" -}} |
| 510 | {{- $certDir := default "" .Values.certDirectory . -}} |
Piotr Marcinkiewicz | 598f2d8 | 2021-06-01 12:36:13 +0200 | [diff] [blame] | 511 | {{- if (and $certDir .Values.certificates .Values.global.cmpv2Enabled .Values.useCmpv2Certificates) -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 512 | true |
| 513 | {{- end -}} |
| 514 | {{- end -}} |