[COMMON] Use readinessCheck template inside certInitializer
[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 {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
45 {{ include "common.readinessCheck.waitFor" $subchartDot }}
46 - name: {{ include "common.name" $dot }}-aaf-config
47   image: {{ include "common.repository" $subchartDot }}/{{ $subchartDot.Values.global.aafAgentImage }}
48   imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }}
49   volumeMounts:
50   - mountPath: {{ $initRoot.mountPath }}
51     name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
52   - mountPath: /opt/app/aaf_config/cert/truststoreONAPall.jks.b64
53     name: aaf-agent-certs
54     subPath: truststoreONAPall.jks.b64
55   - mountPath: /opt/app/aaf_config/cert/truststoreONAP.p12.b64
56     name: aaf-agent-certs
57     subPath: truststoreONAP.p12.b64
58 {{-     if $initRoot.aaf_add_config }}
59   - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }}
60     mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh
61     subPath: aaf-add-config.sh
62 {{-     end }}
63   command:
64     - sh
65     - -c
66     - |
67       #!/usr/bin/env bash
68       /opt/app/aaf_config/bin/agent.sh
69 {{-     if $initRoot.aaf_add_config }}
70       /opt/app/aaf_config/bin/aaf-add-config.sh
71 {{-     end }}
72   env:
73     - name: APP_FQI
74       value: "{{ $initRoot.fqi }}"
75     - name: aaf_locate_url
76       value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095"
77     - name: aaf_locator_container
78       value: "oom"
79     - name: aaf_locator_container_ns
80       value: "{{ $dot.Release.Namespace }}"
81     - name: aaf_locator_fqdn
82       value: "{{ $initRoot.fqdn }}"
83     - name: aaf_locator_app_ns
84       value: "{{ $initRoot.app_ns }}"
85     - name: DEPLOY_FQI
86     {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "login") | indent 6 }}
87     - name: DEPLOY_PASSWORD
88     {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "password") | indent 6 }}
89   #Note: want to put this on Nodes, eventually
90     - name: cadi_longitude
91       value: "{{ default "52.3" $initRoot.cadi_longitude }}"
92     - name: cadi_latitude
93       value: "{{ default "13.2" $initRoot.cadi_latitude }}"
94   #Hello specific.  Clients don't don't need this, unless Registering with AAF Locator
95     - name: aaf_locator_public_fqdn
96       value: "{{ $initRoot.public_fqdn | default "" }}"
97 {{- end -}}
98
99 {{- define "common.certInitializer._volumeMount" -}}
100 {{-   $dot := default . .dot -}}
101 {{-   $initRoot := default $dot.Values.certInitializer .initRoot -}}
102 - mountPath: {{ $initRoot.mountPath }}
103   name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
104 {{- end -}}
105
106 {{- define "common.certInitializer._volumes" -}}
107 {{-   $dot := default . .dot -}}
108 {{-   $initRoot := default $dot.Values.certInitializer .initRoot -}}
109 {{- $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))) }}
110 - name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
111   emptyDir:
112     medium: Memory
113 - name: aaf-agent-certs
114   configMap:
115     name: {{ include "common.fullname" $subchartDot }}-certs
116     defaultMode: 0700
117
118 {{-     if $initRoot.aaf_add_config }}
119 - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }}
120   configMap:
121     name: {{ include "common.fullname" $subchartDot }}-add-config
122     defaultMode: 0700
123 {{-     end -}}
124 {{- end -}}
125
126 {{- define "common.certInitializer.initContainer" -}}
127 {{-   $dot := default . .dot -}}
128   {{- if $dot.Values.global.aafEnabled }}
129     {{ include "common.certInitializer._initContainer" . }}
130   {{- end -}}
131 {{- end -}}
132
133 {{- define "common.certInitializer.volumeMount" -}}
134 {{-   $dot := default . .dot -}}
135   {{- if $dot.Values.global.aafEnabled }}
136     {{- include "common.certInitializer._volumeMount" . }}
137   {{- end -}}
138 {{- end -}}
139
140 {{- define "common.certInitializer.volumes" -}}
141 {{-   $dot := default . .dot -}}
142   {{- if $dot.Values.global.aafEnabled }}
143     {{- include "common.certInitializer._volumes" . }}
144   {{- end -}}
145 {{- end -}}