2 ################################################################################
3 # Copyright (C) 2021 Nordix Foundation. #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
20 This template generates a Kubernetes init containers common template to enable applications to provision
21 DMaaP topics (on Message Router) and feeds (on Data Router), with associated authorization (on AAF).
22 DMaap Bus Controller endpoints are used to provision:
23 - Authorized topic on MR, and to create and grant permission for publishers and subscribers.
24 - Feed on DR, with associated user authentication.
26 common.dmaap.provisioning.initContainer:
27 This template make use of Dmaap Bus Controller docker image to create resources on Dmaap Data Router
28 microservice, with the help of dbc-client.sh script it makes use of Bus Controller API to create Feed, Topics.
29 If the resource creation is successful via script response is logged back at particular location with
30 appropriate naming convention.
32 More details can be found at :
33 (https://wiki.onap.org/pages/viewpage.action?pageId=103417564)
35 The template directly references data in .Values, and indirectly (through its
36 use of templates from the ONAP "common" collection) references data in .Release.
38 Parameter for _dmaapProvisioning to be defined in values.yaml
39 # DataRouter Feed Configuration
41 - feedName: bulk_pm_feed
44 asprClassification: unclassified
45 feedDescription: DFC Feed Creation
47 # DataRouter Publisher Configuration
49 - feedName: bulk_pm_feed
50 dcaeLocationName: loc00
52 # DataRouter Subscriber Configuration
54 - feedName: bulk_pm_feed
56 dcaeLocationName: loc00
57 privilegedSubscriber: True
58 deliveryURL: https://dcae-pm-mapper:8443/delivery
60 # MessageRouter Topic, Publisher Configuration
62 - topicName: PERFORMANCE_MEASUREMENTS
63 topicDescription: Description about Topic
67 - dcaeLocationName: san-francisco
68 clientRole: org.onap.dcae.pmPublisher
73 # ConfigMap Configuration for DR Feed, Dr_Publisher, Dr_Subscriber, MR Topics
76 path: /opt/app/config/feeds
78 path: /opt/app/config/dr_pubs
80 path: /opt/app/config/dr_subs
82 path: /opt/app/config/topics
84 In deployments/jobs/stateful include:
86 {{- include "common.dmaap.provisioning.initContainer" . | nindent XX }}
88 {{- include "common.dmaap.provisioning._volumes" . | nindent XX -}}
91 {{- define "common.dmaap.provisioning._volumeMounts" -}}
92 {{- $dot := default . .dot -}}
93 - mountPath: /opt/app/config/cache
94 name: dbc-response-cache
95 {{- range $name, $volume := $dot.Values.volumes }}
96 - name: {{ $volume.name }}
97 mountPath: {{ $volume.path }}
101 {{- define "common.dmaap.provisioning._volumes" -}}
102 {{- $dot := default . .dot -}}
103 - name: dbc-response-cache
105 {{- range $name, $volume := $dot.Values.volumes }}
106 - name: {{ $volume.name }}
109 name: {{ include "common.fullname" $dot }}-{{ printf "%s" $volume.name }}
113 {{- define "common.dmaap.provisioning.initContainer" -}}
114 {{- $dot := default . .dot -}}
115 {{- $drFeedConfig := default $dot.Values.drFeedConfig .drFeedConfig -}}
116 {{- $mrTopicsConfig := default $dot.Values.mrTopicsConfig .mrTopicsConfig -}}
117 {{- if or $drFeedConfig $mrTopicsConfig -}}
118 - name: {{ include "common.name" $dot }}-init-dmaap-provisioning
119 image: {{ include "repositoryGenerator.image.dbcClient" $dot }}
120 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
123 value: /opt/app/config/cache
125 value: "{{ include "common.name" $dot }}-dmaap-provisioning"
126 {{- range $cred := $dot.Values.credentials }}
127 - name: {{ $cred.name }}
128 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $cred.uid "key" $cred.key) | nindent 4 }}
131 {{- include "common.dmaap.provisioning._volumeMounts" $dot | trim | nindent 2 }}
132 resources: {{ include "common.resources" $dot | nindent 1 }}
133 - name: {{ include "common.name" $dot }}-init-merge-config
134 image: {{ include "repositoryGenerator.image.envsubst" $dot }}
135 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
141 if [ -d /opt/app/config/cache ]; then
142 cd /opt/app/config/cache
143 for file in $(ls feed*); do
144 NUM=$(echo "$file" | sed 's/feedConfig-\([0-9]\+\)-resp.json/\1/')
145 export DR_LOG_URL_"$NUM"="$(grep -o '"logURL":"[^"]*' "$file" | cut -d '"' -f4)"
146 export DR_FILES_PUBLISHER_URL_"$NUM"="$(grep -o '"publishURL":"[^"]*' "$file" | cut -d '"' -f4)"
148 for file in $(ls drpub*); do
149 NUM=$(echo "$file" | sed 's/drpubConfig-\([0-9]\+\)-resp.json/\1/')
150 export DR_USERNAME_"$NUM"="$(grep -o '"username":"[^"]*' "$file" | cut -d '"' -f4)"
151 export DR_PASSWORD_"$NUM"="$(grep -o '"userpwd":"[^"]*' "$file" | cut -d '"' -f4)"
152 export DR_FILES_PUBLISHER_ID_"$NUM"="$(grep -o '"pubId":"[^"]*' "$file" | cut -d '"' -f4)"
154 for file in $(ls drsub*); do
155 NUM=$(echo "$file" | sed 's/drsubConfig-\([0-9]\+\)-resp.json/\1/')
156 export DR_FILES_SUBSCRIBER_ID_"$NUM"="$(grep -o '"subId":"[^"]*' "$file" | cut -d '"' -f4)"
158 for file in $(ls topics*); do
159 NUM=$(echo "$file" | sed 's/topicsConfig-\([0-9]\+\)-resp.json/\1/')
160 export MR_FILES_PUBLISHER_CLIENT_ID_"$NUM"="$(grep -o '"mrClientId":"[^"]*' "$file" | cut -d '"' -f4)"
163 echo "No Response logged for Dmaap BusController Http POST Request..!"
165 cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done
167 {{- range $cred := $dot.Values.credentials }}
168 - name: {{ $cred.name }}
169 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $cred.uid "key" $cred.key) | nindent 4 }}
172 - mountPath: /opt/app/config/cache
173 name: dbc-response-cache
174 - mountPath: /config-input
175 name: app-config-input