2 ################################################################################
3 # Copyright (C) 2021 Nordix Foundation. #
4 # Copyright (c) 2022 J. F. Lucas. All rights reserved. #
6 # Licensed under the Apache License, Version 2.0 (the "License"); #
7 # you may not use this file except in compliance with the License. #
8 # You may obtain a copy of the License at #
10 # http://www.apache.org/licenses/LICENSE-2.0 #
12 # Unless required by applicable law or agreed to in writing, software #
13 # distributed under the License is distributed on an "AS IS" BASIS, #
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15 # See the License for the specific language governing permissions and #
16 # limitations under the License. #
17 ################################################################################
21 This template generates a Kubernetes init containers common template to enable applications to provision
22 DMaaP feeds (on Data Router), with associated authorization.
23 DMaap Bus Controller endpoints are used to provision:
25 - Feed on DR, with associated user authentication.
27 common.dmaap.provisioning.initContainer:
28 This template make use of Dmaap Bus Controller docker image to create resources on Dmaap Data Router
29 microservice, with the help of dbc-client.sh script it makes use of Bus Controller API to create Feeds.
30 If the resource creation is successful via script response is logged back at particular location with
31 appropriate naming convention.
33 More details can be found at :
34 (https://wiki.onap.org/pages/viewpage.action?pageId=103417564)
36 The template directly references data in .Values, and indirectly (through its
37 use of templates from the ONAP "common" collection) references data in .Release.
39 Parameter for _dmaapProvisioning to be defined in values.yaml
40 # DataRouter Feed Configuration
42 - feedName: bulk_pm_feed
45 asprClassification: unclassified
46 feedDescription: DFC Feed Creation
48 # DataRouter Publisher Configuration
50 - feedName: bulk_pm_feed
51 dcaeLocationName: loc00
53 # DataRouter Subscriber Configuration
55 - feedName: bulk_pm_feed
57 dcaeLocationName: loc00
58 privilegedSubscriber: True
59 deliveryURL: https://dcae-pm-mapper:8443/delivery
61 # ConfigMap Configuration for DR Feed, Dr_Publisher, Dr_Subscriber
64 path: /opt/app/config/feeds
66 path: /opt/app/config/dr_pubs
68 path: /opt/app/config/dr_subs
70 In deployments/jobs/stateful include:
72 {{- include "common.dmaap.provisioning.initContainer" . | nindent XX }}
74 {{- include "common.dmaap.provisioning._volumes" . | nindent XX -}}
77 {{- define "common.dmaap.provisioning._volumeMounts" -}}
78 {{- $dot := default . .dot -}}
79 - mountPath: /opt/app/config/cache
80 name: dbc-response-cache
81 {{- range $name, $volume := $dot.Values.volumes }}
82 - name: {{ $volume.name }}
83 mountPath: {{ $volume.path }}
87 {{- define "common.dmaap.provisioning._volumes" -}}
88 {{- $dot := default . .dot -}}
89 - name: dbc-response-cache
91 {{- range $name, $volume := $dot.Values.volumes }}
92 - name: {{ $volume.name }}
95 name: {{ include "common.fullname" $dot }}-{{ printf "%s" $volume.name }}
99 {{- define "common.dmaap.provisioning.initContainer" -}}
100 {{- $dot := default . .dot -}}
101 {{- $drFeedConfig := default $dot.Values.drFeedConfig .drFeedConfig -}}
102 {{- if $drFeedConfig -}}
103 - name: {{ include "common.name" $dot }}-init-dmaap-provisioning
104 image: {{ include "repositoryGenerator.image.dbcClient" $dot }}
105 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
112 value: /opt/app/config/cache
114 value: "{{ include "common.name" $dot }}-dmaap-provisioning"
115 {{- range $cred := $dot.Values.credentials }}
116 - name: {{ $cred.name }}
117 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $cred.uid "key" $cred.key) | nindent 4 }}
120 {{- include "common.dmaap.provisioning._volumeMounts" $dot | trim | nindent 2 }}
121 resources: {{ include "common.resources" $dot | nindent 4 }}
122 - name: {{ include "common.name" $dot }}-init-merge-config
123 image: {{ include "repositoryGenerator.image.envsubst" $dot }}
124 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
131 if [ -d /opt/app/config/cache ]; then
132 cd /opt/app/config/cache
133 for file in $(ls feed*); do
134 NUM=$(echo "$file" | sed 's/feedConfig-\([0-9]\+\)-resp.json/\1/')
135 export DR_LOG_URL_"$NUM"="$(grep -o '"logURL":"[^"]*' "$file" | grep -w "feedlog" | cut -d '"' -f4)"
136 export DR_FILES_PUBLISHER_URL_"$NUM"="$(grep -o '"publishURL":"[^"]*' "$file" | cut -d '"' -f4)"
138 for file in $(ls drpub*); do
139 NUM=$(echo "$file" | sed 's/drpubConfig-\([0-9]\+\)-resp.json/\1/')
140 export DR_FILES_PUBLISHER_ID_"$NUM"="$(grep -o '"pubId":"[^"]*' "$file" | cut -d '"' -f4)"
142 for file in $(ls drsub*); do
143 NUM=$(echo "$file" | sed 's/drsubConfig-\([0-9]\+\)-resp.json/\1/')
144 export DR_FILES_SUBSCRIBER_ID_"$NUM"="$(grep -o '"subId":"[^"]*' "$file" | cut -d '"' -f4)"
146 for file in $(ls topics*); do
147 NUM=$(echo "$file" | sed 's/topicsConfig-\([0-9]\+\)-resp.json/\1/')
148 export MR_FILES_PUBLISHER_CLIENT_ID_"$NUM"="$(grep -o '"mrClientId":"[^"]*' "$file" | cut -d '"' -f4)"
151 echo "No Response logged for Dmaap BusController Http POST Request..!"
153 cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done
155 {{- range $cred := $dot.Values.credentials }}
156 - name: {{ $cred.name }}
157 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $cred.uid "key" $cred.key) | nindent 4 }}
160 - mountPath: /opt/app/config/cache
161 name: dbc-response-cache
162 - mountPath: /config-input
163 name: app-config-input