33f06495ccbc28889b1e6ed43c92c16bf730f72f
[oom.git] / kubernetes / common / certInitializer / templates / _certInitializer.yaml
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 */}}
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))) }}
46 - name: {{ include "common.name" $dot }}-aaf-readiness
47   image: "{{ $subchartDot.Values.global.readinessRepository }}/{{ $subchartDot.Values.global.readinessImage }}"
48   imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }}
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
65   image: {{ (default $subchartDot.Values.repository $subchartDot.Values.global.repository) }}/{{ $subchartDot.Values.global.aafAgentImage }}
66   imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }}
67   volumeMounts:
68   - mountPath: {{ $initRoot.mountPath }}
69     name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
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
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 -}}
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))) }}
128 - name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
129   emptyDir:
130     medium: Memory
131 - name: aaf-agent-certs
132   configMap:
133     name: {{ include "common.fullname" $subchartDot }}-certs
134     defaultMode: 0700
135 {{-     if $initRoot.aaf_add_config }}
136 - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }}
137   configMap:
138     name: {{ include "common.fullname" $subchartDot }}-add-config
139     defaultMode: 0700
140 {{-     end -}}
141 {{- end -}}
142
143 {{- define "common.certInitializer.initContainer" -}}
144 {{-   $dot := default . .dot -}}
145   {{- if $dot.Values.global.aafEnabled }}
146     {{ include "common.certInitializer._initContainer" . }}
147   {{- end -}}
148 {{- end -}}
149
150 {{- define "common.certInitializer.volumeMount" -}}
151 {{-   $dot := default . .dot -}}
152   {{- if $dot.Values.global.aafEnabled }}
153     {{- include "common.certInitializer._volumeMount" . }}
154   {{- end -}}
155 {{- end -}}
156
157 {{- define "common.certInitializer.volumes" -}}
158 {{-   $dot := default . .dot -}}
159   {{- if $dot.Values.global.aafEnabled }}
160     {{- include "common.certInitializer._volumes" . }}
161   {{- end -}}
162 {{- end -}}