[POLICY-SDC-DIST] Upgrade policy-distribtuion to use kafka native 83/132483/5
authorefiacor <fiachra.corcoran@est.tech>
Mon, 28 Nov 2022 10:38:56 +0000 (10:38 +0000)
committerFiachra Corcoran <fiachra.corcoran@est.tech>
Tue, 3 Jan 2023 10:16:24 +0000 (10:16 +0000)
Policy dist to use kafka native

Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: Id83dcd6c4af0bff37689178330827ce96246b5ae
Issue-ID: DMAAP-1816

kubernetes/policy/components/policy-distribution/resources/config/config.json
kubernetes/policy/components/policy-distribution/templates/deployment.yaml
kubernetes/policy/components/policy-distribution/templates/policy-dist-kafka-user.yaml [new file with mode: 0644]
kubernetes/policy/components/policy-distribution/values.yaml
kubernetes/policy/values.yaml

index 1aa9044..94fc37b 100755 (executable)
         "sdcConfiguration":{
             "parameterClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandlerConfigurationParameterGroup",
             "parameters":{
-                "asdcAddress": "sdc-be.{{ include "common.namespace" . }}:{{ (eq "true" (include "common.needTLS" .)) | ternary 8443 8080 }}",
-                "messageBusAddress": [
-                    "message-router.{{ include "common.namespace" . }}"
-                 ],
+                "environmentName": "AUTO",
+                "isUseHttpsWithSDC": {{ (eq "true" (include "common.needTLS" .)) | ternary true false }},
+                "keyStorePath": "null",
+                "keyStorePassword": "null",
+                "activeserverTlsAuth": false,
+                "sdcAddress": "sdc-be.{{ include "common.namespace" . }}:{{ (eq "true" (include "common.needTLS" .)) | ternary 8443 8080 }}",
                 "user": "${SDCBE_USER}",
                 "password": "${SDCBE_PASSWORD}",
+                "consumerGroup": "{{ .Values.config.kafka.sdcTopic.consumerGroup }}",
+                "consumerId": "{{ .Values.config.kafka.sdcTopic.clientId }}",
                 "pollingInterval":20,
                 "pollingTimeout":30,
-                "consumerId": "policy-id",
                 "artifactTypes": [
                     "TOSCA_CSAR",
                     "HEAT"
                 ],
-                "consumerGroup": "policy-group",
-                "environmentName": "AUTO",
-                "keyStorePath": "null",
-                "keyStorePassword": "null",
-                "activeserverTlsAuth": false,
-                "isFilterinEmptyResources": true,
-                "isUseHttpsWithDmaap": {{ (eq "true" (include "common.needTLS" .)) | ternary true false }},
-                "isUseHttpsWithSDC": {{ (eq "true" (include "common.needTLS" .)) | ternary true false }}
+                "isFilterinEmptyResources": true
             }
         }
     },
index 4745aac..9c71ac1 100755 (executable)
@@ -75,6 +75,13 @@ spec:
         - name: {{ include "common.name" . }}
           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+          env:
+          - name: SECURITY_PROTOCOL
+            value: {{ .Values.config.kafka.securityProtocol }}
+          - name: SASL_MECHANISM
+            value: {{ .Values.config.kafka.saslMechanism }}
+          - name: SASL_JAAS_CONFIG
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "policy-dist-kafka-user" "key" "sasl.jaas.config") | indent 12 }}
 {{- if .Values.global.aafEnabled }}
           command: ["sh","-c"]
           args: ["source {{ .Values.certInitializer.credsPath }}/.ci;\
diff --git a/kubernetes/policy/components/policy-distribution/templates/policy-dist-kafka-user.yaml b/kubernetes/policy/components/policy-distribution/templates/policy-dist-kafka-user.yaml
new file mode 100644 (file)
index 0000000..eb721b0
--- /dev/null
@@ -0,0 +1,36 @@
+{{/*
+# Copyright © 2022 Nordix Foundation
+#
+# 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.
+*/}}
+apiVersion: kafka.strimzi.io/v1beta2
+kind: KafkaUser
+metadata:
+  name: {{ include "common.release" . }}-{{ .Values.global.policyDistKafkaUser }}
+  labels:
+    strimzi.io/cluster: {{ include "common.release" . }}-strimzi
+spec:
+  authentication:
+    type: {{ .Values.config.kafka.saslMechanism | lower }}
+  authorization:
+    type: {{ .Values.config.kafka.authType }}
+    acls:
+    - resource:
+        type: group
+        name: {{ .Values.config.kafka.sdcTopic.consumerGroup }}
+      operation: Read
+    - resource:
+        type: topic
+        patternType: prefix
+        name: {{ .Values.config.kafka.sdcTopic.pattern }}
+      operation: All
index d9df88c..5cdda2f 100755 (executable)
@@ -55,7 +55,13 @@ secrets:
     externalSecret: '{{ tpl (default "" .Values.certStores.trustStorePasswordExternalSecret) . }}'
     password: '{{ .Values.certStores.trustStorePassword }}'
     passwordPolicy: required
-
+  - uid: policy-dist-kafka-user
+    externalSecret: '{{ tpl (default "" .Values.config.jaasConfExternalSecret) . }}'
+    type: genericKV
+    envs:
+      - name: sasl.jaas.config
+        value: '{{ .Values.config.someConfig }}'
+        policy: generate
 #################################################################
 # Global configuration defaults.
 #################################################################
@@ -67,13 +73,24 @@ global:
 # Application configuration defaults.
 #################################################################
 # application image
-image: onap/policy-distribution:2.8.2
+image: onap/policy-distribution:2.9.0
 pullPolicy: Always
 
 # flag to enable debugging - application support required
 debugEnabled: false
 
 # application configuration
+config:
+  someConfig: blah
+  kafka:
+    bootstrapServer: strimzi-kafka-bootstrap:9092
+    securityProtocol: SASL_PLAINTEXT
+    saslMechanism: SCRAM-SHA-512
+    authType: simple
+    sdcTopic:
+      pattern: SDC-DIST
+      consumerGroup: policy-group
+      clientId: policy-distribution
 
 restServer:
   user: healthcheck
index 45ade02..c9e236a 100755 (executable)
@@ -38,6 +38,7 @@ global:
       name: postgres
   kafkaBootstrap: strimzi-kafka-bootstrap
   policyKafkaUser: policy-kafka-user
+  policyDistKafkaUser: policy-dist-kafka-user
 
 #################################################################
 # Secrets metaconfig
@@ -128,7 +129,7 @@ policy-distribution:
   enabled: true
   db: *dbSecretsHook
   config:
-    jaasConfExternalSecret: '{{ include "common.release" . }}-{{ .Values.global.policyKafkaUser }}'
+    jaasConfExternalSecret: '{{ include "common.release" . }}-{{ .Values.global.policyDistKafkaUser }}'
 policy-clamp-ac-k8s-ppnt:
   enabled: true
   config: