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