aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/common/common/templates/_dmaapProvisioning.tpl
blob: 3cf5bf120737b4f74d6496310363571507b2e320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{{/*
################################################################################
#   Copyright (C) 2021 Nordix Foundation.                                      #
#   Copyright (c) 2022-2023 J. F. Lucas.  All rights reserved.                      #
#                                                                              #
#   Licensed under the Apache License, Version 2.0 (the "License");            #
#   you may not use this file except in compliance with the License.           #
#   You may obtain a copy of the License at                                    #
#                                                                              #
#       http://www.apache.org/licenses/LICENSE-2.0                             #
#                                                                              #
#   Unless required by applicable law or agreed to in writing, software        #
#   distributed under the License is distributed on an "AS IS" BASIS,          #
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
#   See the License for the specific language governing permissions and        #
#   limitations under the License.                                             #
################################################################################
*/}}

{{/*
  This template generates a Kubernetes init containers common template to enable applications to provision
  DMaaP feeds (on Data Router) for DCAE microservices, with associated authorization.
  DMaap Data Router (DR) endpoints are used to provision:
  - Feeds on DR, with associated user authentication.
  - Subscribers to feeds on DR, to provide DR with username, password, and URL needed to deliver
    files to subscribers.

  common.dmaap.provisioning.initContainer:
  This template creates an initContainer with some associated volumes.  The initContainer
  (oom/kubernetes/dmaap-datarouter/drprov-client) runs a script (drprov-client.sh) that uses the
  DR provisioning API to create the feeds and subscribers needed by a microservice.  The script
  updates the microservice's configuration to supply information needed to access the feeds. The
  configuration information comes from two volumes that are created by the dcaegen2-services-common
  templates.
  - app-config-input: comes from a configMap generated from the microservice's values.yaml file.
    It may contain references to environment variables as placeholders for feed information that
    will become available after feeds are provisioned.
  - app-config: this template will copy the configuration file from the app-config-input volume,
    replaced the environment variable references with the actual values for feed information, based
    on data returned by the DR provisioning API.

  The template directly references data in .Values, and indirectly (through its
  use of templates from the ONAP "common" collection) references data in .Release.

  Parameters for _dmaapProvisioning to be defined in values.yaml:

  # DataRouter Feed Configuration
  # (Note that DR configures publishers as part of the feed.)
  drFeedConfig:
    - feedName: bulk_pm_feed
      feedVersion: 0.0
      classification: unclassified
      feedDescription: DFC Feed Creation
      publisher:
        username: xyz
        password: xyz

  # DataRouter Subscriber Configuration
  drSubConfig:
    - feedName: bulk_pm_feed
      feedVersion: 0.0
      decompress: True
      privilegedSubscriber: True
      deliveryURL: https://dcae-pm-mapper:8443/delivery

  # ConfigMap Configuration for DR Feed, Dr_Subscriber
  volumes:
    - name: feeds-config
      path: /opt/app/config/feeds
    - name: drsub-config
      path: /opt/app/config/dr_subs

  In deployments/jobs/stateful include:
  initContainers:
  {{- include "common.dmaap.provisioning.initContainer" . | nindent XX }}
  volumes:
  {{- include "common.dmaap.provisioning._volumes" . | nindent XX -}}
*/}}

{{- define "common.dmaap.provisioning._volumeMounts" -}}
{{- $dot := default . .dot -}}
- mountPath: /config-input
  name: app-config-input
- mountPath: /config
  name: app-config
{{- range $name, $volume := $dot.Values.volumes }}
- name: {{ $volume.name }}
  mountPath: {{ $volume.path }}
{{- end }}
{{- end -}}

{{- define "common.dmaap.provisioning._volumes" -}}
{{- $dot := default . .dot -}}
{{- range $name, $volume := $dot.Values.volumes }}
- name: {{ $volume.name }}
  configMap:
    defaultMode: 420
    name: {{ include "common.fullname" $dot }}-{{ printf "%s" $volume.name }}
{{- end }}
{{- end -}}

{{- define "common.dmaap.provisioning.initContainer" -}}
{{- $dot := default . .dot -}}
{{- $drNeedProvisioning := or $dot.Values.drFeedConfig $dot.Values.drSubConfig -}}
{{- if $drNeedProvisioning -}}
- name: {{ include "common.name" $dot }}-init-dmaap-provisioning
  image: {{ include "repositoryGenerator.image.drProvClient" $dot }}
  imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
  env:
  - name: ONBEHALFHDR
    value: "X-DMAAP-DR-ON-BEHALF-OF: drprovcl"
  {{- range $cred := $dot.Values.credentials }}
  - name: {{ $cred.name }}
    {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" $cred.uid "key" $cred.key) | nindent 4 }}
  {{- end }}
  volumeMounts:
  {{- include "common.dmaap.provisioning._volumeMounts" $dot | trim | nindent 2 }}
  resources: {{ include "common.resources" $dot | nindent 4 }}
{{- end -}}
{{- end -}}