Merge "Fix name convention issue (SDC-WORKFLOW)"
[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 (fromJson (toJson $dot)) (dict "Chart" (set (fromJson (toJson .Chart)) "Name" $initRoot.nameOverride) "Values" $initRoot) }}
46 - name: {{ include "common.name" $dot }}-aaf-readiness
47   image: "{{ $dot.Values.global.readinessRepository }}/{{ $dot.Values.global.readinessImage }}"
48   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.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 $dot.Values.repository $dot.Values.global.repository) }}/{{ $dot.Values.global.aafAgentImage }}
66   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
67   volumeMounts:
68   - mountPath: {{ $initRoot.mountPath }}
69     name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
70 {{-     if $initRoot.aaf_add_config }}
71   - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }}
72     mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh
73     subPath: aaf-add-config.sh
74 {{-     end }}
75   command:
76     - sh
77     - -c
78     - |
79       #!/usr/bin/env bash
80       /opt/app/aaf_config/bin/agent.sh
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 }}"
87     - name: aaf_locate_url
88       value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095"
89     - name: aaf_locator_container
90       value: "oom"
91     - name: aaf_locator_container_ns
92       value: "{{ $dot.Release.Namespace }}"
93     - name: aaf_locator_fqdn
94       value: "{{ $initRoot.fqdn }}"
95     - name: aaf_locator_app_ns
96       value: "{{ $initRoot.app_ns }}"
97     - name: DEPLOY_FQI
98     {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "login") | indent 6 }}
99     - name: DEPLOY_PASSWORD
100     {{- include "common.secret.envFromSecretFast" (dict "global" $subchartDot "uid" "deployer-creds" "key" "password") | indent 6 }}
101   #Note: want to put this on Nodes, eventually
102     - name: cadi_longitude
103       value: "{{ default "52.3" $initRoot.cadi_longitude }}"
104     - name: cadi_latitude
105       value: "{{ default "13.2" $initRoot.cadi_latitude }}"
106   #Hello specific.  Clients don't don't need this, unless Registering with AAF Locator
107     - name: aaf_locator_public_fqdn
108       value: "{{ $initRoot.public_fqdn | default "" }}"
109 {{- end -}}
110
111 {{- define "common.certInitializer._volumeMount" -}}
112 {{-   $dot := default . .dot -}}
113 {{-   $initRoot := default $dot.Values.certInitializer .initRoot -}}
114 - mountPath: {{ $initRoot.mountPath }}
115   name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
116 {{- end -}}
117
118 {{- define "common.certInitializer._volumes" -}}
119 {{-   $dot := default . .dot -}}
120 {{-   $initRoot := default $dot.Values.certInitializer .initRoot -}}
121 {{- $subchartDot := mergeOverwrite (fromJson (toJson $dot)) (dict "Chart" (set (fromJson (toJson .Chart)) "Name" $initRoot.nameOverride) "Values" $initRoot) }}
122 - name: {{ include "common.certInitializer._aafConfigVolumeName" $dot }}
123   emptyDir:
124     medium: Memory
125 {{-     if $initRoot.aaf_add_config }}
126 - name: {{ include "common.certInitializer._aafAddConfigVolumeName" $dot }}
127   configMap:
128     name: {{ include "common.fullname" $subchartDot }}-add-config
129     defaultMode: 0700
130 {{-     end -}}
131 {{- end -}}
132
133 {{- define "common.certInitializer.initContainer" -}}
134 {{-   $dot := default . .dot -}}
135   {{- if $dot.Values.global.aafEnabled }}
136     {{ include "common.certInitializer._initContainer" . }}
137   {{- end -}}
138 {{- end -}}
139
140 {{- define "common.certInitializer.volumeMount" -}}
141 {{-   $dot := default . .dot -}}
142   {{- if $dot.Values.global.aafEnabled }}
143     {{- include "common.certInitializer._volumeMount" . }}
144   {{- end -}}
145 {{- end -}}
146
147 {{- define "common.certInitializer.volumes" -}}
148 {{-   $dot := default . .dot -}}
149   {{- if $dot.Values.global.aafEnabled }}
150     {{- include "common.certInitializer._volumes" . }}
151   {{- end -}}
152 {{- end -}}