Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / common / common / templates / _aafconfig.tpl
1 {{/*
2 # Copyright © 2020 Amdocs, Bell Canada, highstreet technologies GmbH
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   common templates to enable aaf configs for applictaions
19
20   Parameter for aafConfig to be defined in values.yaml
21   aafConfig:   --> if a different key is used, call templates with argument (dict "aafRoot" .Values.<yourkey> "dot" .)
22     # additional scripts can be defined to handle certs
23     addconfig: true|false
24     fqdn: "sdnc"
25     app_ns: "org.osaaf.aaf"
26     fqi: "sdnc@sdnc.onap.org"
27     fqi_namespace: org.onap.sdnc
28     public_fqdn: "aaf.osaaf.org"
29     aafDeployFqi: "deployer@people.osaaf.org"
30     aafDeployPass: demo123456!
31     cadi_latitude: "38.0"
32     cadi_longitude: "-72.0"
33     secret_uid: &aaf_secret_uid my-component-aaf-deploy-creds
34
35   # secrets configuration, Note: create a secrets template
36   secrets:
37     - uid: *aaf_secret_uid
38       type: basicAuth
39       externalSecret: '{{ ternary (tpl (default "" .Values.aafConfig.aafDeployCredsExternalSecret) .) "aafIsDisabled" .Values.global.aafEnabled }}'
40       login: '{{ .Values.aafConfig.aafDeployFqi }}'
41       password: '{{ .Values.aafConfig.aafDeployPass }}'
42       passwordPolicy: required
43
44   In deployments/jobs/stateful include:
45   initContainers:
46     {{ include "common.aaf-config" . | nindent XX}}
47
48   containers:
49     volumeMounts:
50     {{- if .Values.global.aafEnabled }}
51      - mountPath: "/opt/app/osaaf"
52        name: {{ include "common.fullname" . }}-aaf-config
53        {{- end }}
54   volumes:
55   {{- include "common.aaf-config-volumes" . | nindent XX}}
56 */}}
57 {{- define "common.aaf-config" -}}
58 {{-   $dot := default . .dot -}}
59 {{-   $aafRoot := default $dot.Values.aafConfig .aafRoot -}}
60 {{-   if $dot.Values.global.aafEnabled -}}
61 - name: {{ include "common.name" $dot }}-aaf-readiness
62   image: {{ include "common.repository" $dot }}/{{ $dot.Values.global.readinessImage }}
63   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
64   command:
65   - /app/ready.py
66   args:
67   - --container-name
68   - aaf-locate
69   - --container-name
70   - aaf-cm
71   - --container-name
72   - aaf-service
73   env:
74   - name: NAMESPACE
75     valueFrom:
76       fieldRef:
77         apiVersion: v1
78         fieldPath: metadata.namespace
79   resources:
80     limits:
81       cpu: 100m
82       memory: 100Mi
83     requests:
84       cpu: 3m
85       memory: 20Mi
86 - name: {{ include "common.name" $dot }}-aaf-config
87   image: {{ (default $dot.Values.repository $dot.Values.global.repository) }}/{{ $dot.Values.global.aafAgentImage }}
88   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
89   volumeMounts:
90   - mountPath: "/opt/app/osaaf"
91     name: {{ include "common.fullname" $dot }}-aaf-config
92 {{-     if $aafRoot.addconfig }}
93   - name: aaf-add-config
94     mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh
95     subPath: aaf-add-config.sh
96 {{-     end }}
97   command:
98     - sh
99     - -c
100     - |
101       #!/usr/bin/env bash
102       /opt/app/aaf_config/bin/agent.sh
103 {{-     if $aafRoot.addconfig }}
104       /opt/app/aaf_config/bin/aaf-add-config.sh
105 {{-     end }}
106   env:
107     - name: APP_FQI
108       value: "{{ $aafRoot.fqi }}"
109     - name: aaf_locate_url
110       value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095"
111     - name: aaf_locator_container
112       value: "oom"
113     - name: aaf_locator_container_ns
114       value: "{{ $dot.Release.Namespace }}"
115     - name: aaf_locator_fqdn
116       value: "{{ $aafRoot.fqdn }}"
117     - name: aaf_locator_app_ns
118       value: "{{ $aafRoot.app_ns }}"
119     - name: DEPLOY_FQI
120     {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "login") | indent 6 }}
121     - name: DEPLOY_PASSWORD
122     {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "password") | indent 6 }}
123   #Note: want to put this on Nodes, eventually
124     - name: cadi_longitude
125       value: "{{ default "52.3" $aafRoot.cadi_longitude }}"
126     - name: cadi_latitude
127       value: "{{ default "13.2" $aafRoot.cadi_latitude }}"
128   #Hello specific.  Clients don't don't need this, unless Registering with AAF Locator
129     - name: aaf_locator_public_fqdn
130       value: "{{ $aafRoot.public_fqdn | default "" }}"
131   resources:
132     limits:
133       cpu: 100m
134       memory: 100Mi
135     requests:
136       cpu: 3m
137       memory: 20Mi
138 {{-   end -}}
139 {{- end -}}
140
141 {{- define "common.aaf-config-volume-mountpath" -}}
142 {{-   if .Values.global.aafEnabled -}}
143 - mountPath: "/opt/app/osaaf"
144   name: {{ include "common.fullname" . }}-aaf-config
145 {{-   end -}}
146 {{- end -}}
147
148 {{- define "common.aaf-config-volumes" -}}
149 {{-   $dot := default . .dot -}}
150 {{-   $aafRoot := default $dot.Values.aafConfig .aafRoot -}}
151 {{-   if $dot.Values.global.aafEnabled -}}
152 - name: {{ include "common.fullname" $dot }}-aaf-config
153   emptyDir:
154     medium: Memory
155 {{-     if $aafRoot.addconfig }}
156 - name: aaf-add-config
157   configMap:
158     name: {{ include "common.fullname" $dot }}-aaf-add-config
159     defaultMode: 0700
160 {{-     end -}}
161 {{-   end -}}
162 {{- end -}}