Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 1 | {{/* |
| 2 | # Copyright © 2020 Samsung Electronics |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | |
| 18 | |
| 19 | {{- define "common.certInitializer._aafConfigVolumeName" -}} |
| 20 | {{ include "common.fullname" . }}-aaf-config |
| 21 | {{- end -}} |
| 22 | |
| 23 | {{- define "common.certInitializer._aafAddConfigVolumeName" -}} |
| 24 | {{ print "aaf-add-config" }} |
| 25 | {{- end -}} |
| 26 | |
| 27 | {{/* |
| 28 | common templates to enable cert initialization for applictaions |
| 29 | |
| 30 | In deployments/jobs/stateful include: |
| 31 | initContainers: |
| 32 | {{ include "common.certInitializer.initContainer" . | nindent XX }} |
| 33 | |
| 34 | containers: |
| 35 | volumeMounts: |
| 36 | {{- include "common.certInitializer.volumeMount" . | nindent XX }} |
| 37 | volumes: |
| 38 | {{- include "common.certInitializer.volume" . | nindent XX}} |
| 39 | */}} |
| 40 | {{- define "common.certInitializer._initContainer" -}} |
| 41 | {{- $dot := default . .dot -}} |
| 42 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
| 43 | {{- $initName := default "certInitializer" -}} |
| 44 | {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}} |
Krzysztof Opasiak | 3e5fa9a | 2020-05-19 00:44:12 +0200 | [diff] [blame] | 45 | {{- $subchartDot := mergeOverwrite (deepCopy (omit $dot "Values")) (dict "Chart" (set (fromJson (toJson $dot.Chart)) "Name" $initRoot.nameOverride) "Values" (mergeOverwrite (deepCopy $initRoot) (dict "global" $dot.Values.global))) }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 46 | - name: {{ include "common.name" $dot }}-aaf-readiness |
Krzysztof Opasiak | 3e5fa9a | 2020-05-19 00:44:12 +0200 | [diff] [blame] | 47 | image: "{{ $subchartDot.Values.global.readinessRepository }}/{{ $subchartDot.Values.global.readinessImage }}" |
| 48 | imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 49 | command: |
| 50 | - /root/ready.py |
| 51 | args: |
| 52 | - --container-name |
| 53 | - aaf-locate |
| 54 | - --container-name |
| 55 | - aaf-cm |
| 56 | - --container-name |
| 57 | - aaf-service |
| 58 | env: |
| 59 | - name: NAMESPACE |
| 60 | valueFrom: |
| 61 | fieldRef: |
| 62 | apiVersion: v1 |
| 63 | fieldPath: metadata.namespace |
| 64 | - name: {{ include "common.name" $dot }}-aaf-config |
Krzysztof Opasiak | 3e5fa9a | 2020-05-19 00:44:12 +0200 | [diff] [blame] | 65 | image: {{ (default $subchartDot.Values.repository $subchartDot.Values.global.repository) }}/{{ $subchartDot.Values.global.aafAgentImage }} |
| 66 | imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 67 | volumeMounts: |
| 68 | - mountPath: {{ $initRoot.mountPath }} |
| 69 | name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
Krzysztof Opasiak | 95a5f84 | 2020-05-06 23:27:18 +0200 | [diff] [blame] | 70 | - mountPath: /opt/app/aaf_config/cert/truststoreONAPall.jks.b64 |
| 71 | name: aaf-agent-certs |
| 72 | subPath: truststoreONAPall.jks.b64 |
| 73 | - mountPath: /opt/app/aaf_config/cert/truststoreONAP.p12.b64 |
| 74 | name: aaf-agent-certs |
| 75 | subPath: truststoreONAP.p12.b64 |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 76 | {{- if $initRoot.aaf_add_config }} |
| 77 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 78 | mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh |
| 79 | subPath: aaf-add-config.sh |
| 80 | {{- end }} |
| 81 | command: |
| 82 | - sh |
| 83 | - -c |
| 84 | - | |
| 85 | #!/usr/bin/env bash |
| 86 | /opt/app/aaf_config/bin/agent.sh |
| 87 | {{- if $initRoot.aaf_add_config }} |
| 88 | /opt/app/aaf_config/bin/aaf-add-config.sh |
| 89 | {{- end }} |
| 90 | env: |
| 91 | - name: APP_FQI |
| 92 | value: "{{ $initRoot.fqi }}" |
| 93 | - name: aaf_locate_url |
| 94 | value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095" |
| 95 | - name: aaf_locator_container |
| 96 | value: "oom" |
| 97 | - name: aaf_locator_container_ns |
| 98 | value: "{{ $dot.Release.Namespace }}" |
| 99 | - name: aaf_locator_fqdn |
| 100 | value: "{{ $initRoot.fqdn }}" |
| 101 | - name: aaf_locator_app_ns |
| 102 | value: "{{ $initRoot.app_ns }}" |
| 103 | - name: DEPLOY_FQI |
| 104 | {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "login") | indent 6 }} |
| 105 | - name: DEPLOY_PASSWORD |
| 106 | {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "password") | indent 6 }} |
| 107 | #Note: want to put this on Nodes, eventually |
| 108 | - name: cadi_longitude |
| 109 | value: "{{ default "52.3" $initRoot.cadi_longitude }}" |
| 110 | - name: cadi_latitude |
| 111 | value: "{{ default "13.2" $initRoot.cadi_latitude }}" |
| 112 | #Hello specific. Clients don't don't need this, unless Registering with AAF Locator |
| 113 | - name: aaf_locator_public_fqdn |
| 114 | value: "{{ $initRoot.public_fqdn | default "" }}" |
| 115 | {{- end -}} |
| 116 | |
| 117 | {{- define "common.certInitializer._volumeMount" -}} |
| 118 | {{- $dot := default . .dot -}} |
| 119 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
| 120 | - mountPath: {{ $initRoot.mountPath }} |
| 121 | name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
| 122 | {{- end -}} |
| 123 | |
| 124 | {{- define "common.certInitializer._volumes" -}} |
| 125 | {{- $dot := default . .dot -}} |
| 126 | {{- $initRoot := default $dot.Values.certInitializer .initRoot -}} |
Krzysztof Opasiak | 3e5fa9a | 2020-05-19 00:44:12 +0200 | [diff] [blame] | 127 | {{- $subchartDot := mergeOverwrite (deepCopy (omit $dot "Values")) (dict "Chart" (set (fromJson (toJson $dot.Chart)) "Name" $initRoot.nameOverride) "Values" (mergeOverwrite (deepCopy $initRoot) (dict "global" $dot.Values.global))) }} |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 128 | - name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }} |
| 129 | emptyDir: |
| 130 | medium: Memory |
Krzysztof Opasiak | 95a5f84 | 2020-05-06 23:27:18 +0200 | [diff] [blame] | 131 | - name: aaf-agent-certs |
| 132 | configMap: |
| 133 | name: {{ include "common.fullname" $subchartDot }}-certs |
| 134 | defaultMode: 0700 |
| 135 | |
Krzysztof Opasiak | 108483c | 2020-05-14 01:44:30 +0200 | [diff] [blame] | 136 | {{- if $initRoot.aaf_add_config }} |
| 137 | - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }} |
| 138 | configMap: |
| 139 | name: {{ include "common.fullname" $subchartDot }}-add-config |
| 140 | defaultMode: 0700 |
Krzysztof Opasiak | 020cdb9 | 2020-05-01 01:46:37 +0200 | [diff] [blame] | 141 | {{- end -}} |
| 142 | {{- end -}} |
| 143 | |
| 144 | {{- define "common.certInitializer.initContainer" -}} |
| 145 | {{- $dot := default . .dot -}} |
| 146 | {{- if $dot.Values.global.aafEnabled }} |
| 147 | {{ include "common.certInitializer._initContainer" . }} |
| 148 | {{- end -}} |
| 149 | {{- end -}} |
| 150 | |
| 151 | {{- define "common.certInitializer.volumeMount" -}} |
| 152 | {{- $dot := default . .dot -}} |
| 153 | {{- if $dot.Values.global.aafEnabled }} |
| 154 | {{- include "common.certInitializer._volumeMount" . }} |
| 155 | {{- end -}} |
| 156 | {{- end -}} |
| 157 | |
| 158 | {{- define "common.certInitializer.volumes" -}} |
| 159 | {{- $dot := default . .dot -}} |
| 160 | {{- if $dot.Values.global.aafEnabled }} |
| 161 | {{- include "common.certInitializer._volumes" . }} |
| 162 | {{- end -}} |
| 163 | {{- end -}} |