Merge "Bump up clamp to 5.0.3"
[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: "{{ $dot.Values.global.readinessRepository }}/{{ $dot.Values.global.readinessImage }}"
63   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
64   command:
65   - /root/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 - name: {{ include "common.name" $dot }}-aaf-config
80   image: {{ (default $dot.Values.repository $dot.Values.global.repository) }}/{{ $dot.Values.global.aafAgentImage }}
81   imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
82   volumeMounts:
83   - mountPath: "/opt/app/osaaf"
84     name: {{ include "common.fullname" $dot }}-aaf-config
85 {{-     if $aafRoot.addconfig }}
86   - name: aaf-add-config
87     mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh
88     subPath: aaf-add-config.sh
89 {{-     end }}
90   command:
91     - sh
92     - -c
93     - |
94       #!/usr/bin/env bash
95       /opt/app/aaf_config/bin/agent.sh
96 {{-     if $aafRoot.addconfig }}
97       /opt/app/aaf_config/bin/aaf-add-config.sh
98 {{-     end }}
99   env:
100     - name: APP_FQI
101       value: "{{ $aafRoot.fqi }}"
102     - name: aaf_locate_url
103       value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095"
104     - name: aaf_locator_container
105       value: "oom"
106     - name: aaf_locator_container_ns
107       value: "{{ $dot.Release.Namespace }}"
108     - name: aaf_locator_fqdn
109       value: "{{ $aafRoot.fqdn }}"
110     - name: aaf_locator_app_ns
111       value: "{{ $aafRoot.app_ns }}"
112     - name: DEPLOY_FQI
113     {{- include "common.secret.envFromSecret" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "login") | indent 6 }}
114     - name: DEPLOY_PASSWORD
115     {{- include "common.secret.envFromSecret" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "password") | indent 6 }}
116   #Note: want to put this on Nodes, eventually
117     - name: cadi_longitude
118       value: "{{ default "52.3" $aafRoot.cadi_longitude }}"
119     - name: cadi_latitude
120       value: "{{ default "13.2" $aafRoot.cadi_latitude }}"
121   #Hello specific.  Clients don't don't need this, unless Registering with AAF Locator
122     - name: aaf_locator_public_fqdn
123       value: "{{ $aafRoot.public_fqdn | default "" }}"
124 {{-   end -}}
125 {{- end -}}
126
127 {{- define "common.aaf-config-volume-mountpath" -}}
128 {{-   if .Values.global.aafEnabled -}}
129 - mountPath: "/opt/app/osaaf"
130   name: {{ include "common.fullname" . }}-aaf-config
131 {{-   end -}}
132 {{- end -}}
133
134 {{- define "common.aaf-config-volumes" -}}
135 {{-   $dot := default . .dot -}}
136 {{-   $aafRoot := default $dot.Values.aafConfig .aafRoot -}}
137 {{-   if $dot.Values.global.aafEnabled -}}
138 - name: {{ include "common.fullname" $dot }}-aaf-config
139   emptyDir:
140     medium: Memory
141 {{-     if $aafRoot.addconfig }}
142 - name: aaf-add-config
143   configMap:
144     name: {{ include "common.fullname" $dot }}-aaf-add-config
145     defaultMode: 0700
146 {{-     end -}}
147 {{-   end -}}
148 {{- end -}}