Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 1 | {{/* |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 2 | # Copyright © 2020 Bell Canada, Samsung Electronics |
Sylvain Desbureaux | da711dd | 2021-04-07 17:22:42 +0200 | [diff] [blame] | 3 | # Copyright © 2021 Orange |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | */}} |
| 17 | |
| 18 | |
| 19 | |
| 20 | {{- define "common.certInitializer._aafConfigVolumeName" -}} |
| 21 | {{ include "common.fullname" . }}-aaf-config |
| 22 | {{- end -}} |
| 23 | |
| 24 | {{- define "common.certInitializer._aafAddConfigVolumeName" -}} |
| 25 | {{ print "aaf-add-config" }} |
| 26 | {{- end -}} |
| 27 | |
| 28 | {{/* |
| 29 | common templates to enable cert initialization for applictaions |
| 30 | |
| 31 | In deployments/jobs/stateful include: |
| 32 | initContainers: |
| 33 | {{ include "common.certInitializer.initContainer" . | nindent XX }} |
| 34 | |
| 35 | containers: |
| 36 | volumeMounts: |
| 37 | {{- include "common.certInitializer.volumeMount" . | nindent XX }} |
| 38 | volumes: |
| 39 | {{- include "common.certInitializer.volume" . | nindent XX}} |
| 40 | */}} |
| 41 | {{- define "common.certInitializer._initContainer" -}} |
| 42 | {{- $dot := default . .dot -}} |
| 43 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
| 44 | {{- $initName := default "certInitializer" -}} |
Sylvain Desbureaux | 41cf72f | 2020-05-15 17:25:52 +0200 | [diff] [blame] | 45 | {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }} |
Krzysztof Opasiak | e9754a0 | 2020-07-16 21:06:39 +0200 | [diff] [blame] | 46 | {{ include "common.readinessCheck.waitFor" $subchartDot }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 47 | - name: {{ include "common.name" $dot }}-aaf-config |
Sylvain Desbureaux | 145140b | 2020-11-19 16:48:39 +0100 | [diff] [blame] | 48 | image: {{ include "repositoryGenerator.repository" $subchartDot }}/{{ $subchartDot.Values.global.aafAgentImage }} |
Krzysztof Opasiak | 3e5fa9a | 2020-05-19 00:44:12 +0200 | [diff] [blame] | 49 | imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }} |
rope252 | f2db5c1 | 2022-01-10 14:15:16 +0000 | [diff] [blame] | 50 | securityContext: |
| 51 | runAsUser: 0 |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 52 | volumeMounts: |
| 53 | - mountPath: {{ $initRoot.mountPath }} |
| 54 | name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
Krzysztof Opasiak | 95a5f84 | 2020-05-06 23:27:18 +0200 | [diff] [blame] | 55 | - mountPath: /opt/app/aaf_config/cert/truststoreONAPall.jks.b64 |
| 56 | name: aaf-agent-certs |
| 57 | subPath: truststoreONAPall.jks.b64 |
| 58 | - mountPath: /opt/app/aaf_config/cert/truststoreONAP.p12.b64 |
| 59 | name: aaf-agent-certs |
| 60 | subPath: truststoreONAP.p12.b64 |
Sylvain Desbureaux | b834159 | 2021-02-23 15:54:00 +0100 | [diff] [blame] | 61 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 62 | mountPath: /opt/app/aaf_config/bin/retrieval_check.sh |
| 63 | subPath: retrieval_check.sh |
Sylvain Desbureaux | da711dd | 2021-04-07 17:22:42 +0200 | [diff] [blame] | 64 | {{- if hasKey $initRoot "ingressTlsSecret" }} |
| 65 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 66 | mountPath: /opt/app/aaf_config/bin/tls_certs_configure.sh |
| 67 | subPath: tls_certs_configure.sh |
| 68 | {{- end }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 69 | {{- if $initRoot.aaf_add_config }} |
| 70 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 71 | mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh |
| 72 | subPath: aaf-add-config.sh |
| 73 | {{- end }} |
| 74 | command: |
| 75 | - sh |
| 76 | - -c |
| 77 | - | |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 78 | /opt/app/aaf_config/bin/agent.sh |
Guillaume Lambert | 2b6f82c | 2021-03-02 21:45:00 +0100 | [diff] [blame] | 79 | . /opt/app/aaf_config/bin/retrieval_check.sh |
Sylvain Desbureaux | da711dd | 2021-04-07 17:22:42 +0200 | [diff] [blame] | 80 | {{- if hasKey $initRoot "ingressTlsSecret" }} |
| 81 | /opt/app/aaf_config/bin/tls_certs_configure.sh |
| 82 | {{- end -}} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 83 | {{- if $initRoot.aaf_add_config }} |
| 84 | /opt/app/aaf_config/bin/aaf-add-config.sh |
| 85 | {{- end }} |
| 86 | env: |
| 87 | - name: APP_FQI |
| 88 | value: "{{ $initRoot.fqi }}" |
xuegao | 8055f5a | 2021-12-08 09:26:42 +0100 | [diff] [blame] | 89 | {{- if $initRoot.aaf_namespace }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 90 | - name: aaf_locate_url |
xuegao | 8055f5a | 2021-12-08 09:26:42 +0100 | [diff] [blame] | 91 | value: "https://aaf-locate.{{ $initRoot.aaf_namespace }}:8095" |
| 92 | - name: aaf_locator_container_ns |
| 93 | value: "{{ $initRoot.aaf_namespace }}" |
| 94 | {{- else }} |
| 95 | - name: aaf_locate_url |
| 96 | value: "https://aaf-locate.{{ $dot.Release.Namespace }}:8095" |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 97 | - name: aaf_locator_container_ns |
| 98 | value: "{{ $dot.Release.Namespace }}" |
xuegao | 8055f5a | 2021-12-08 09:26:42 +0100 | [diff] [blame] | 99 | {{- end }} |
| 100 | - name: aaf_locator_container |
| 101 | value: "oom" |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 102 | - name: aaf_locator_fqdn |
| 103 | value: "{{ $initRoot.fqdn }}" |
| 104 | - name: aaf_locator_app_ns |
| 105 | value: "{{ $initRoot.app_ns }}" |
| 106 | - name: DEPLOY_FQI |
| 107 | {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "login") | indent 6 }} |
| 108 | - name: DEPLOY_PASSWORD |
| 109 | {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "password") | indent 6 }} |
| 110 | #Note: want to put this on Nodes, eventually |
| 111 | - name: cadi_longitude |
| 112 | value: "{{ default "52.3" $initRoot.cadi_longitude }}" |
| 113 | - name: cadi_latitude |
| 114 | value: "{{ default "13.2" $initRoot.cadi_latitude }}" |
| 115 | #Hello specific. Clients don't don't need this, unless Registering with AAF Locator |
| 116 | - name: aaf_locator_public_fqdn |
| 117 | value: "{{ $initRoot.public_fqdn | default "" }}" |
| 118 | {{- end -}} |
| 119 | |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 120 | {{/* |
| 121 | This init container will import custom .pem certificates to truststoreONAPall.jks |
| 122 | Custom certificates must be placed in common/certInitializer/resources directory. |
| 123 | |
| 124 | The feature is enabled by setting Values.global.importCustomCertsEnabled = true |
| 125 | It can be used independently of aafEnabled, however it requires the same includes |
| 126 | as describe above for _initContainer. |
| 127 | |
| 128 | When AAF is enabled the truststoreONAPAll.jks (which contains AAF CA) will be used |
| 129 | to import custom certificates, otherwise the default java keystore will be used. |
| 130 | |
| 131 | The updated truststore file will be placed in /updatedTruststore and can be mounted per component |
| 132 | to a specific path by defining Values.certInitializer.truststoreMountpath (see _trustStoreVolumeMount) |
| 133 | The truststore file will be available to mount even if no custom certificates were imported. |
| 134 | */}} |
| 135 | {{- define "common.certInitializer._initImportCustomCertsContainer" -}} |
| 136 | {{- $dot := default . .dot -}} |
| 137 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
| 138 | {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }} |
| 139 | - name: {{ include "common.name" $dot }}-import-custom-certs |
Sylvain Desbureaux | 145140b | 2020-11-19 16:48:39 +0100 | [diff] [blame] | 140 | image: {{ include "repositoryGenerator.image.jre" $subchartDot }} |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 141 | imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }} |
| 142 | securityContext: |
| 143 | runAsUser: 0 |
| 144 | command: |
Sylvain Desbureaux | 3638967 | 2021-01-19 14:51:24 +0100 | [diff] [blame] | 145 | - /bin/sh |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 146 | - -c |
| 147 | - /root/import-custom-certs.sh |
| 148 | env: |
| 149 | - name: AAF_ENABLED |
| 150 | value: "{{ $subchartDot.Values.global.aafEnabled }}" |
| 151 | - name: TRUSTSTORE_OUTPUT_FILENAME |
| 152 | value: "{{ $initRoot.truststoreOutputFileName }}" |
| 153 | - name: TRUSTSTORE_PASSWORD |
| 154 | {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "truststore-creds" "key" "password") | indent 6 }} |
| 155 | volumeMounts: |
| 156 | - mountPath: /certs |
| 157 | name: aaf-agent-certs |
Sylvain Desbureaux | bd94a04 | 2021-04-19 16:00:49 +0200 | [diff] [blame] | 158 | - mountPath: /more_certs |
| 159 | name: provided-custom-certs |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 160 | - mountPath: /root/import-custom-certs.sh |
| 161 | name: aaf-agent-certs |
| 162 | subPath: import-custom-certs.sh |
| 163 | - mountPath: /updatedTruststore |
| 164 | name: updated-truststore |
| 165 | {{- end -}} |
| 166 | |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 167 | {{- define "common.certInitializer._volumeMount" -}} |
| 168 | {{- $dot := default . .dot -}} |
| 169 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
krishnaa96 | edf6f37 | 2020-09-09 09:30:58 +0530 | [diff] [blame] | 170 | - mountPath: {{ $initRoot.appMountPath }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 171 | name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
| 172 | {{- end -}} |
| 173 | |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 174 | {{/* |
| 175 | This is used together with _initImportCustomCertsContainer |
| 176 | It mounts the updated truststore (with imported custom certificates) to the |
| 177 | truststoreMountpath defined in the values file for the component. |
| 178 | */}} |
| 179 | {{- define "common.certInitializer._trustStoreVolumeMount" -}} |
| 180 | {{- $dot := default . .dot -}} |
| 181 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
| 182 | {{- if gt (len $initRoot.truststoreMountpath) 0 }} |
| 183 | - mountPath: {{ $initRoot.truststoreMountpath }}/{{ $initRoot.truststoreOutputFileName }} |
| 184 | name: updated-truststore |
| 185 | subPath: {{ $initRoot.truststoreOutputFileName }} |
Abdelmuhaimen Seaudi | 3dc8cc2 | 2021-09-05 16:32:22 +0200 | [diff] [blame] | 186 | - mountPath: /etc/ssl/certs/ca-certificates.crt |
| 187 | name: updated-truststore |
| 188 | subPath: ca-certificates.crt |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 189 | {{- end -}} |
| 190 | {{- end -}} |
| 191 | |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 192 | {{- define "common.certInitializer._volumes" -}} |
| 193 | {{- $dot := default . .dot -}} |
| 194 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
Krzysztof Opasiak | d36040c | 2021-12-09 21:21:37 +0100 | [diff] [blame] | 195 | {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot))}} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 196 | - name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
| 197 | emptyDir: |
| 198 | medium: Memory |
Krzysztof Opasiak | 95a5f84 | 2020-05-06 23:27:18 +0200 | [diff] [blame] | 199 | - name: aaf-agent-certs |
| 200 | configMap: |
Krzysztof Opasiak | 75f1875 | 2020-09-09 20:32:56 +0200 | [diff] [blame] | 201 | name: {{ tpl $subchartDot.Values.certsCMName $subchartDot }} |
Krzysztof Opasiak | 95a5f84 | 2020-05-06 23:27:18 +0200 | [diff] [blame] | 202 | defaultMode: 0700 |
Sylvain Desbureaux | bd94a04 | 2021-04-19 16:00:49 +0200 | [diff] [blame] | 203 | {{- if $dot.Values.global.importCustomCertsEnabled }} |
| 204 | - name: provided-custom-certs |
| 205 | {{- if $dot.Values.global.customCertsSecret }} |
| 206 | secret: |
| 207 | secretName: {{ $dot.Values.global.customCertsSecret }} |
| 208 | {{- else }} |
| 209 | {{- if $dot.Values.global.customCertsConfigMap }} |
| 210 | configMap: |
| 211 | name: {{ $dot.Values.global.customCertsConfigMap }} |
| 212 | {{- else }} |
| 213 | emptyDir: |
| 214 | medium: Memory |
| 215 | {{- end }} |
| 216 | {{- end }} |
| 217 | {{- end }} |
Krzysztof Opasiak | 108483c | 2020-05-14 01:44:30 +0200 | [diff] [blame] | 218 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 219 | configMap: |
| 220 | name: {{ include "common.fullname" $subchartDot }}-add-config |
| 221 | defaultMode: 0700 |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 222 | {{- if $dot.Values.global.importCustomCertsEnabled }} |
| 223 | - name: updated-truststore |
| 224 | emptyDir: {} |
| 225 | {{- end -}} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 226 | {{- end -}} |
| 227 | |
| 228 | {{- define "common.certInitializer.initContainer" -}} |
| 229 | {{- $dot := default . .dot -}} |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 230 | {{- if $dot.Values.global.importCustomCertsEnabled }} |
| 231 | {{ include "common.certInitializer._initImportCustomCertsContainer" . }} |
| 232 | {{- end -}} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 233 | {{- if $dot.Values.global.aafEnabled }} |
| 234 | {{ include "common.certInitializer._initContainer" . }} |
| 235 | {{- end -}} |
| 236 | {{- end -}} |
| 237 | |
| 238 | {{- define "common.certInitializer.volumeMount" -}} |
| 239 | {{- $dot := default . .dot -}} |
| 240 | {{- if $dot.Values.global.aafEnabled }} |
| 241 | {{- include "common.certInitializer._volumeMount" . }} |
| 242 | {{- end -}} |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 243 | {{- if $dot.Values.global.importCustomCertsEnabled }} |
| 244 | {{- include "common.certInitializer._trustStoreVolumeMount" . }} |
| 245 | {{- end -}} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 246 | {{- end -}} |
| 247 | |
| 248 | {{- define "common.certInitializer.volumes" -}} |
| 249 | {{- $dot := default . .dot -}} |
Jozsef Csongvai | 9d4d5af | 2020-07-13 11:10:25 -0400 | [diff] [blame] | 250 | {{- if or ($dot.Values.global.aafEnabled ) ($dot.Values.global.importCustomCertsEnabled) }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 251 | {{- include "common.certInitializer._volumes" . }} |
| 252 | {{- end -}} |
| 253 | {{- end -}} |