Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 1 | {{/* |
| 2 | #============LICENSE_START======================================================== |
| 3 | # ================================================================================ |
Jack Lucas | 64da4e7 | 2023-03-03 14:46:05 -0500 | [diff] [blame] | 4 | # Copyright (c) 2021-2023 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: |
Jack Lucas | f86f629 | 2022-06-08 09:12:29 -0400 | [diff] [blame] | 36 | 1. As literal string values. (The values can also be Helm template fragments.) |
Jack Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 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 }} |
efiacor | 26c1f7a | 2022-04-25 13:27:18 +0100 | [diff] [blame] | 61 | value: {{ tpl $envValue $global | quote }} |
Jack Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 62 | {{- else }} |
efiacor | 5c0678f | 2023-03-06 09:21:57 +0000 | [diff] [blame] | 63 | {{- 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 Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 73 | - name: {{ $envName }} |
| 74 | {{- include "common.secret.envFromSecretFast" (dict "global" $global "uid" $envValue.secretUid "key" $envValue.key) | indent 2 }} |
efiacor | 5c0678f | 2023-03-06 09:21:57 +0000 | [diff] [blame] | 75 | {{- end }} |
Jack Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 76 | {{- end -}} |
| 77 | {{- end }} |
| 78 | {{- end }} |
| 79 | {{- end -}} |
| 80 | {{/* |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 81 | For internal use only! |
| 82 | |
| 83 | dcaegen2-services-common._externalVolumes: |
| 84 | This template generates a list of volumes associated with the pod, |
| 85 | based on information provided in .Values.externalVolumes. This |
| 86 | template works in conjunction with dcaegen2-services-common._externalVolumeMounts |
| 87 | to give the microservice access to data in volumes created else. |
| 88 | This initial implementation supports ConfigMaps only, as this is the only |
| 89 | external volume mounting required by current microservices. |
| 90 | |
Jack Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 91 | .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] | 92 | - 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 103 | - 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 Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 108 | |
| 109 | Here is an example fragment from a values.yaml file for a microservice: |
| 110 | |
| 111 | externalVolumes: |
| 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 118 | optional: false |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 119 | */}} |
| 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 Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 125 | {{- $vname := (tpl $vol.name $global) -}} |
| 126 | {{- $opt := hasKey $vol "optional" | ternary $vol.optional true }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 127 | - configMap: |
| 128 | defaultMode: 420 |
| 129 | name: {{ $vname }} |
Jack Lucas | b880f89 | 2021-06-07 16:40:31 -0400 | [diff] [blame] | 130 | optional: {{ $opt }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 131 | name: {{ $vname }} |
| 132 | {{- end }} |
| 133 | {{- end }} |
| 134 | {{- end }} |
| 135 | {{- end }} |
| 136 | {{/* |
| 137 | For internal use only! |
| 138 | |
| 139 | dcaegen2-services-common._externalVolumeMounts: |
| 140 | This template generates a list of volume mounts for the microservice container, |
| 141 | based on information provided in .Values.externalVolumes. This |
| 142 | template works in conjunction with dcaegen2-services-common._externalVolumes |
| 143 | to give the microservice access to data in volumes created else. |
| 144 | This initial implementation supports ConfigMaps only, as this is the only |
| 145 | external volume mounting required by current microservices. |
| 146 | |
| 147 | See the documentation for dcaegen2-services-common._externalVolumes for |
| 148 | details on how external volumes are specified in the values.yaml file for |
| 149 | the 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 Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 166 | dcaegen2-services-common.microserviceDeployment: |
| 167 | This template produces a Kubernetes Deployment for a DCAE microservice. |
| 168 | |
| 169 | All DCAE microservices currently use very similar Deployments. Having a |
| 170 | common template eliminates a lot of repetition in the individual charts |
| 171 | for each microservice. |
| 172 | |
| 173 | The template expects the full chart context as input. A chart for a |
| 174 | DCAE microservice references this template using: |
| 175 | {{ include "dcaegen2-services-common.microserviceDeployment" . }} |
| 176 | The template directly references data in .Values, and indirectly (through its |
| 177 | use of templates from the ONAP "common" collection) references data in |
| 178 | .Release. |
| 179 | |
| 180 | The exact content of the Deployment generated from this template |
| 181 | depends on the content of .Values. |
| 182 | |
| 183 | The Deployment always includes a single Pod, with a container that uses |
Jack Lucas | 47c0745 | 2022-08-02 09:39:34 -0400 | [diff] [blame] | 184 | the 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 |
| 187 | repository for the microservice image can be set using |
| 188 | .Values.imageRepositoryOverride. Note that this repository must not |
| 189 | require authentication, because there is no way to specify credentials for |
| 190 | the override repository. imageRepositoryOverride is intended primarily |
| 191 | for testing purposes. |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 192 | |
| 193 | The Deployment Pod may also include a logging sidecar container. |
Jack Lucas | 1e18421 | 2022-03-08 13:35:24 -0500 | [diff] [blame] | 194 | The sidecar is included if .Values.log.path is set. The |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 195 | logging sidecar and the DCAE microservice container share a |
| 196 | volume where the microservice logs are written. |
| 197 | |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 198 | Deployed POD may also include a Policy-sync sidecar container. |
| 199 | The sidecar is included if .Values.policies is set. The |
| 200 | Policy-sync sidecar polls PolicyEngine (PDP) periodically based |
| 201 | on .Values.policies.duration and configuration retrieved is shared with |
| 202 | DCAE Microservice container by common volume. Policy can be retrieved based on |
guillaume.lambert | 30ec390 | 2021-09-14 12:32:24 +0200 | [diff] [blame] | 203 | list of policyID or filter. An optional policyRelease parameter can be specified |
Vijay Venkatesh Kumar | 6259f50 | 2021-07-26 16:53:11 -0400 | [diff] [blame] | 204 | to override the default policy helm release (used for retreiving the secret containing |
| 205 | pdp username and password) |
| 206 | |
| 207 | Following is example policy config override |
| 208 | |
| 209 | dcaePolicySyncImage: onap/org.onap.dcaegen2.deployments.dcae-services-policy-sync:1.0.1 |
| 210 | policies: |
| 211 | duration: 300 |
| 212 | policyRelease: "onap" |
| 213 | policyID: | |
| 214 | '["onap.vfirewall.tca","onap.vdns.tca"]' |
Jack Lucas | f86f629 | 2022-06-08 09:12:29 -0400 | [diff] [blame] | 215 | |
| 216 | The Deployment includes an initContainer that checks for the |
| 217 | readiness of other components that the microservice relies on. |
| 218 | This container is generated by the "common.readinessCheck.waitfor" |
| 219 | template. See the documentation for this template |
| 220 | (oom/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl). |
| 221 | |
| 222 | If the microservice uses a DMaaP Data Router (DR) feed, the Deployment |
| 223 | includes an initContainer that makes provisioning requests to the DMaaP |
| 224 | bus controller (dmaap-bc) to create the feed and to set up a publisher |
| 225 | and/or subscriber to the feed. The Deployment also includes a second |
| 226 | initContainer that merges the information returned by the provisioning |
| 227 | process into the microservice's configuration. See the documentation for |
| 228 | the common DMaaP provisioning template |
| 229 | (oom/kubernetes/common/common/templates/_dmaapProvisioning.tpl). |
| 230 | |
Jack Lucas | f86f629 | 2022-06-08 09:12:29 -0400 | [diff] [blame] | 231 | If the microservice uses certificates from an external CMPv2 provider, |
| 232 | the Deployment will include an initContainer that performs certificate |
| 233 | post-processing. |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 234 | */}} |
| 235 | |
| 236 | {{- define "dcaegen2-services-common.microserviceDeployment" -}} |
Jack Lucas | 1e18421 | 2022-03-08 13:35:24 -0500 | [diff] [blame] | 237 | {{- $log := default dict .Values.log -}} |
| 238 | {{- $logDir := default "" $log.path -}} |
rope252 | 5a7fbee | 2022-07-25 20:00:36 +0100 | [diff] [blame] | 239 | {{- $certDir := (eq "true" (include "common.needTLS" .)) | ternary (default "" .Values.certDirectory . ) "" -}} |
Vijay Venkatesh Kumar | 6259f50 | 2021-07-26 16:53:11 -0400 | [diff] [blame] | 240 | {{- $commonRelease := print (include "common.release" .) -}} |
| 241 | {{- $policy := default dict .Values.policies -}} |
| 242 | {{- $policyRls := default $commonRelease $policy.policyRelease -}} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame] | 243 | {{- $drFeedConfig := default "" .Values.drFeedConfig -}} |
Jack Lucas | 4b22da9 | 2021-12-09 21:54:10 -0500 | [diff] [blame] | 244 | {{- $dcaeName := print (include "common.fullname" .) }} |
| 245 | {{- $dcaeLabel := (dict "dcaeMicroserviceName" $dcaeName) -}} |
| 246 | {{- $dot := . -}} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 247 | apiVersion: apps/v1 |
| 248 | kind: Deployment |
Jack Lucas | 4b22da9 | 2021-12-09 21:54:10 -0500 | [diff] [blame] | 249 | metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "labels" $dcaeLabel) | nindent 2 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 250 | spec: |
| 251 | replicas: 1 |
| 252 | selector: {{- include "common.selectors" . | nindent 4 }} |
| 253 | template: |
| 254 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
| 255 | spec: |
| 256 | initContainers: |
rope252 | 5a7fbee | 2022-07-25 20:00:36 +0100 | [diff] [blame] | 257 | {{- if .Values.readinessCheck }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 258 | {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }} |
rope252 | 5a7fbee | 2022-07-25 20:00:36 +0100 | [diff] [blame] | 259 | {{- end }} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame] | 260 | {{- include "common.dmaap.provisioning.initContainer" . | nindent 6 }} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 261 | {{ include "dcaegen2-services-common._certPostProcessor" . | nindent 4 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 262 | containers: |
Jack Lucas | 47c0745 | 2022-08-02 09:39:34 -0400 | [diff] [blame] | 263 | - image: {{ default ( include "repositoryGenerator.repository" . ) .Values.imageRepositoryOverride }}/{{ .Values.image }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 264 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 265 | name: {{ include "common.name" . }} |
| 266 | env: |
Bartosz Gardziejewski | 041a89a | 2021-05-19 08:05:00 +0200 | [diff] [blame] | 267 | {{- range $cred := .Values.credentials }} |
| 268 | - name: {{ $cred.name }} |
| 269 | {{- include "common.secret.envFromSecretFast" (dict "global" $ "uid" $cred.uid "key" $cred.key) | indent 10 }} |
| 270 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 271 | {{- if $certDir }} |
| 272 | - name: DCAE_CA_CERTPATH |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 273 | value: {{ $certDir }}/cacert.pem |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 274 | {{- end }} |
| 275 | - name: CONSUL_HOST |
| 276 | value: consul-server.onap |
| 277 | - name: CONFIG_BINDING_SERVICE |
| 278 | value: config-binding-service |
| 279 | - name: CBS_CONFIG_URL |
| 280 | value: https://config-binding-service:10443/service_component_all/{{ include "common.name" . }} |
| 281 | - name: POD_IP |
| 282 | valueFrom: |
| 283 | fieldRef: |
| 284 | apiVersion: v1 |
| 285 | fieldPath: status.podIP |
Jack Lucas | cbca57d | 2021-04-05 09:49:46 -0400 | [diff] [blame] | 286 | {{- include "dcaegen2-services-common._ms-specific-env-vars" . | nindent 8 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 287 | {{- if .Values.service }} |
| 288 | ports: {{ include "common.containerPorts" . | nindent 10 }} |
| 289 | {{- end }} |
| 290 | {{- if .Values.readiness }} |
| 291 | readinessProbe: |
| 292 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds | default 5 }} |
| 293 | periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }} |
| 294 | timeoutSeconds: {{ .Values.readiness.timeoutSeconds | default 1 }} |
| 295 | {{- $probeType := .Values.readiness.type | default "httpGet" -}} |
| 296 | {{- if eq $probeType "httpGet" }} |
| 297 | httpGet: |
| 298 | scheme: {{ .Values.readiness.scheme }} |
| 299 | path: {{ .Values.readiness.path }} |
| 300 | port: {{ .Values.readiness.port }} |
| 301 | {{- end }} |
| 302 | {{- if eq $probeType "exec" }} |
| 303 | exec: |
| 304 | command: |
| 305 | {{- range $cmd := .Values.readiness.command }} |
| 306 | - {{ $cmd }} |
| 307 | {{- end }} |
| 308 | {{- end }} |
| 309 | {{- end }} |
miroslavmasaryk | a7ac7f0 | 2023-03-01 14:12:26 +0100 | [diff] [blame] | 310 | resources: {{ include "common.resources" . | nindent 10 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 311 | volumeMounts: |
Bartosz Gardziejewski | 4bb3da3 | 2021-04-21 12:08:50 +0200 | [diff] [blame] | 312 | - mountPath: /app-config |
Jack Lucas | f86f629 | 2022-06-08 09:12:29 -0400 | [diff] [blame] | 313 | name: {{ ternary "app-config-input" "app-config" (not $drFeedConfig) }} |
Bartosz Gardziejewski | 041a89a | 2021-05-19 08:05:00 +0200 | [diff] [blame] | 314 | - mountPath: /app-config-input |
| 315 | name: app-config-input |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 316 | {{- if $logDir }} |
| 317 | - mountPath: {{ $logDir}} |
Maciej Wereski | 7000a7c | 2021-12-16 12:24:06 +0100 | [diff] [blame] | 318 | name: logs |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 319 | {{- end }} |
| 320 | {{- if $certDir }} |
| 321 | - mountPath: {{ $certDir }} |
| 322 | name: tls-info |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 323 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 324 | {{- include "common.certManager.volumeMountsReadOnly" . | nindent 8 -}} |
| 325 | {{- end -}} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 326 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 327 | {{- if $policy }} |
| 328 | - name: policy-shared |
| 329 | mountPath: /etc/policies |
| 330 | {{- end }} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 331 | {{- include "dcaegen2-services-common._externalVolumeMounts" . | nindent 8 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 332 | {{- if $logDir }} |
Maciej Wereski | 7000a7c | 2021-12-16 12:24:06 +0100 | [diff] [blame] | 333 | {{ include "common.log.sidecar" . | nindent 6 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 334 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 335 | {{- if $policy }} |
| 336 | - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dcaePolicySyncImage }} |
| 337 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 338 | name: policy-sync |
| 339 | env: |
| 340 | - name: POD_IP |
| 341 | valueFrom: |
| 342 | fieldRef: |
| 343 | apiVersion: v1 |
| 344 | fieldPath: status.podIP |
| 345 | - name: POLICY_SYNC_PDP_USER |
| 346 | valueFrom: |
| 347 | secretKeyRef: |
Prativa Dora | 5408022 | 2022-03-29 09:29:23 +0000 | [diff] [blame] | 348 | name: {{ $policyRls }}-policy-xacml-pdp-restserver-creds |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 349 | key: login |
| 350 | - name: POLICY_SYNC_PDP_PASS |
| 351 | valueFrom: |
| 352 | secretKeyRef: |
Prativa Dora | 5408022 | 2022-03-29 09:29:23 +0000 | [diff] [blame] | 353 | name: {{ $policyRls }}-policy-xacml-pdp-restserver-creds |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 354 | key: password |
| 355 | - name: POLICY_SYNC_PDP_URL |
Piotr Marcinkiewicz | 7062518 | 2021-04-29 17:02:37 +0200 | [diff] [blame] | 356 | value : http{{ if (include "common.needTLS" .) }}s{{ end }}://policy-xacml-pdp:6969 |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 357 | - name: POLICY_SYNC_OUTFILE |
| 358 | value : "/etc/policies/policies.json" |
| 359 | - name: POLICY_SYNC_V1_DECISION_ENDPOINT |
| 360 | value : "policy/pdpx/v1/decision" |
| 361 | {{- if $policy.filter }} |
| 362 | - name: POLICY_SYNC_FILTER |
| 363 | value: {{ $policy.filter }} |
| 364 | {{- end -}} |
| 365 | {{- if $policy.policyID }} |
| 366 | - name: POLICY_SYNC_ID |
| 367 | value: {{ $policy.policyID }} |
| 368 | {{- end -}} |
| 369 | {{- if $policy.duration }} |
| 370 | - name: POLICY_SYNC_DURATION |
Vijay Venkatesh Kumar | c269b26 | 2021-06-29 13:49:15 -0400 | [diff] [blame] | 371 | value: "{{ $policy.duration }}" |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 372 | {{- end }} |
miroslavmasaryk | a7ac7f0 | 2023-03-01 14:12:26 +0100 | [diff] [blame] | 373 | resources: {{ include "common.resources" . | nindent 10 }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 374 | volumeMounts: |
| 375 | - mountPath: /etc/policies |
| 376 | name: policy-shared |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 377 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 378 | hostname: {{ include "common.name" . }} |
farida azmy | cb03ac7 | 2021-09-12 16:14:12 +0200 | [diff] [blame] | 379 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 380 | volumes: |
| 381 | - configMap: |
| 382 | defaultMode: 420 |
| 383 | name: {{ include "common.fullname" . }}-application-config-configmap |
| 384 | name: app-config-input |
| 385 | - emptyDir: |
| 386 | medium: Memory |
| 387 | name: app-config |
| 388 | {{- if $logDir }} |
| 389 | - emptyDir: {} |
Maciej Wereski | 7000a7c | 2021-12-16 12:24:06 +0100 | [diff] [blame] | 390 | name: logs |
| 391 | {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix . )) | nindent 6 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 392 | {{- end }} |
| 393 | {{- if $certDir }} |
| 394 | - emptyDir: {} |
| 395 | name: tls-info |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 396 | {{ if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 397 | {{ include "common.certManager.volumesReadOnly" . | nindent 6 }} |
| 398 | {{- end }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 399 | {{- end }} |
vv770d | e8c5c68 | 2021-04-15 12:21:36 -0400 | [diff] [blame] | 400 | {{- if $policy }} |
| 401 | - name: policy-shared |
| 402 | emptyDir: {} |
| 403 | {{- end }} |
ajay_dp001 | cf5232a | 2021-04-13 20:48:07 +0530 | [diff] [blame] | 404 | {{- include "common.dmaap.provisioning._volumes" . | nindent 6 -}} |
Jack Lucas | e5f7160 | 2021-05-10 12:00:02 -0400 | [diff] [blame] | 405 | {{- include "dcaegen2-services-common._externalVolumes" . | nindent 6 }} |
Jack Lucas | d41dbdb | 2021-02-16 11:07:28 -0500 | [diff] [blame] | 406 | imagePullSecrets: |
| 407 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
| 408 | {{ end -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 409 | |
| 410 | {{/* |
| 411 | For internal use |
| 412 | |
| 413 | Template to attach CertPostProcessor which merges CMPv2 truststore with AAF truststore |
| 414 | and swaps keystore files. |
| 415 | */}} |
| 416 | {{- define "dcaegen2-services-common._certPostProcessor" -}} |
| 417 | {{- $certDir := default "" .Values.certDirectory . -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 418 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 419 | {{- $cmpv2Certificate := (index .Values.certificates 0) -}} |
| 420 | {{- $cmpv2CertificateDir := $cmpv2Certificate.mountPath -}} |
| 421 | {{- $certType := "pem" -}} |
| 422 | {{- if $cmpv2Certificate.keystore -}} |
| 423 | {{- $certType = (index $cmpv2Certificate.keystore.outputType 0) -}} |
| 424 | {{- end -}} |
Piotr Marcinkiewicz | 7062518 | 2021-04-29 17:02:37 +0200 | [diff] [blame] | 425 | {{- $truststoresPaths := printf "%s/%s:%s/%s" $certDir "cacert.pem" $cmpv2CertificateDir "cacert.pem" -}} |
| 426 | {{- $truststoresPasswordPaths := ":" -}} |
| 427 | {{- $keystoreSourcePaths := printf "%s/%s:%s/%s" $cmpv2CertificateDir "cert.pem" $cmpv2CertificateDir "key.pem" -}} |
Remigiusz Janeczek | 9b00b56 | 2021-04-26 14:37:57 +0200 | [diff] [blame] | 428 | {{- $keystoreDestinationPaths := printf "%s/%s:%s/%s" $certDir "cert.pem" $certDir "key.pem" -}} |
| 429 | {{- if not (eq $certType "pem") -}} |
| 430 | {{- $truststoresPaths = printf "%s/%s:%s/%s.%s" $certDir "trust.jks" $cmpv2CertificateDir "truststore" $certType -}} |
| 431 | {{- $truststoresPasswordPaths = printf "%s/%s:%s/%s" $certDir "trust.pass" $cmpv2CertificateDir "truststore.pass" -}} |
| 432 | {{- $keystoreSourcePaths = printf "%s/%s.%s:%s/%s" $cmpv2CertificateDir "keystore" $certType $cmpv2CertificateDir "keystore.pass" -}} |
| 433 | {{- $keystoreDestinationPaths = printf "%s/%s.%s:%s/%s.pass" $certDir "cert" $certType $certDir $certType -}} |
| 434 | {{- end }} |
| 435 | - name: cert-post-processor |
| 436 | image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.certPostProcessorImage }} |
| 437 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 438 | resources: |
| 439 | {{- include "common.resources" . | nindent 4 }} |
| 440 | volumeMounts: |
| 441 | - mountPath: {{ $certDir }} |
| 442 | name: tls-info |
| 443 | {{- include "common.certManager.volumeMountsReadOnly" . | nindent 4 }} |
| 444 | env: |
| 445 | - name: TRUSTSTORES_PATHS |
| 446 | value: {{ $truststoresPaths | quote}} |
| 447 | - name: TRUSTSTORES_PASSWORDS_PATHS |
| 448 | value: {{ $truststoresPasswordPaths | quote }} |
| 449 | - name: KEYSTORE_SOURCE_PATHS |
| 450 | value: {{ $keystoreSourcePaths | quote }} |
| 451 | - name: KEYSTORE_DESTINATION_PATHS |
| 452 | value: {{ $keystoreDestinationPaths | quote }} |
| 453 | {{- end }} |
| 454 | {{- end -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 455 | |
| 456 | {{/* |
| 457 | Template returns string "true" if CMPv2 certificates should be used and nothing (so it can be used in with statements) |
| 458 | when they shouldn't. Example use: |
| 459 | {{- if (include "dcaegen2-services-common.shouldUseCmpv2Certificates" .) -}} |
| 460 | |
| 461 | */}} |
| 462 | {{- define "dcaegen2-services-common.shouldUseCmpv2Certificates" -}} |
| 463 | {{- $certDir := default "" .Values.certDirectory . -}} |
Piotr Marcinkiewicz | 598f2d8 | 2021-06-01 12:36:13 +0200 | [diff] [blame] | 464 | {{- if (and $certDir .Values.certificates .Values.global.cmpv2Enabled .Values.useCmpv2Certificates) -}} |
Remigiusz Janeczek | 7b09503 | 2021-05-20 19:39:44 +0200 | [diff] [blame] | 465 | true |
| 466 | {{- end -}} |
| 467 | {{- end -}} |