Patch VES collector with new schemas 97/14497/1
authoraravind.est <aravindhan.a@est.tech>
Thu, 22 May 2025 14:58:06 +0000 (15:58 +0100)
committeraravind.est <aravindhan.a@est.tech>
Thu, 22 May 2025 15:03:49 +0000 (16:03 +0100)
VES collector's init container patched to download additional files and update the schema-map accordingly.

Issue-ID: NONRTRIC-1020
Change-Id: I3e6fbd78e18e20898c0ba679c2b97d4f408e8dc3
Signed-off-by: aravind.est <aravindhan.a@est.tech>
smo-install/oran_oom/smo/common/resources/patch-ves-collector.sh [new file with mode: 0755]
smo-install/oran_oom/smo/common/templates/vescollector-patch-configmap.yaml [new file with mode: 0644]
smo-install/oran_oom/smo/common/templates/vescollector-patch-rbac.yaml [new file with mode: 0644]
smo-install/oran_oom/smo/common/templates/vescollector-patch.yaml [new file with mode: 0644]

diff --git a/smo-install/oran_oom/smo/common/resources/patch-ves-collector.sh b/smo-install/oran_oom/smo/common/resources/patch-ves-collector.sh
new file mode 100755 (executable)
index 0000000..9f878c9
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+# ============LICENSE_START=======================================================
+# Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+# ============LICENSE_END============================================
+#
+
+# This will add additional configuration to ves-collector deployment.
+
+kubectl patch deployment onap-dcae-ves-collector -n onap --type=json \
+  -p='[{"op": "replace", "path": "/spec/template/spec/initContainers/0/command", "value": ["sh", "-c", "
+  cp -R /opt/app/VESCollector/etc/. /opt/app/VESCollector/etc_rw/;
+
+  REL_18_FOLDER=/opt/app/VESCollector/etc_rw/externalRepo/3gpp/rep/sa5/MnS/blob/Rel-18/OpenAPI;
+  mkdir -p $REL_18_FOLDER;
+  wget https://forge.3gpp.org/rep/sa5/MnS/-/archive/Rel-18/MnS-Rel-18.tar?path=OpenAPI -O $REL_18_FOLDER/MnS-Rel-18.tar;
+  tar -tf $REL_18_FOLDER/MnS-Rel-18.tar | grep '\.yaml$' | xargs tar -xf $REL_18_FOLDER/MnS-Rel-18.tar --strip-components 2 -C $REL_18_FOLDER/;
+  rm $REL_18_FOLDER/MnS-Rel-18.tar;
+
+  for file in $REL_18_FOLDER/*.yaml; do
+    filename=$(basename $file);
+    schemaElement=\'{\\"publicURL\\": \\"https://forge.3gpp.org/rep/sa5/MnS/blob/Rel-18/OpenAPI/\'$filename\'\\",\\"localURL\\": \\"3gpp/rep/sa5/MnS/blob/Rel-18/OpenAPI/\'$filename\'\\"}\';
+    if [ -z \\"$schemaElementStr\\" ]; then
+      schemaElementStr=\\"$schemaElement\\";
+    else
+      schemaElementStr=\\"$schemaElementStr,$schemaElement\\";
+    fi;
+  done;
+  echo \\"schemaElementStr=\\"$schemaElementStr\\"\\";
+
+  if [ -n \\"$schemaElementStr\\" ]; then
+    sed -i \\"$ s|]|,${schemaElementStr}]|\\" /opt/app/VESCollector/etc_rw/externalRepo/schema-map.json;
+  fi;
+"]}]'
+
+
diff --git a/smo-install/oran_oom/smo/common/templates/vescollector-patch-configmap.yaml b/smo-install/oran_oom/smo/common/templates/vescollector-patch-configmap.yaml
new file mode 100644 (file)
index 0000000..7f872d6
--- /dev/null
@@ -0,0 +1,26 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+#  ============LICENSE_END=================================================
+#
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: vescollector-patch-config
+  annotations:
+    "helm.sh/hook": pre-install
+    "helm.sh/hook-weight": "2"
+data:
+{{ tpl (.Files.Glob "resources/patch-ves-collector.sh").AsConfig . | indent 2 }}
\ No newline at end of file
diff --git a/smo-install/oran_oom/smo/common/templates/vescollector-patch-rbac.yaml b/smo-install/oran_oom/smo/common/templates/vescollector-patch-rbac.yaml
new file mode 100644 (file)
index 0000000..7ec5d3d
--- /dev/null
@@ -0,0 +1,53 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+#  ============LICENSE_END=================================================
+
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: vescollector-patch-sa
+  namespace: smo
+  annotations:
+    "helm.sh/hook": pre-install
+    "helm.sh/hook-weight": "1"
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+  name: vescollector-patch-role
+  annotations:
+    "helm.sh/hook": pre-install
+    "helm.sh/hook-weight": "1"
+rules:
+  - apiGroups:      ['kafka.strimzi.io']
+    resources:      ['kafkausers']
+    verbs:          ["get","list","watch","patch","update"]
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: vescollector-patch-rb
+  namespace: onap
+  annotations:
+    "helm.sh/hook": pre-install
+    "helm.sh/hook-weight": "1"
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: vescollector-patch-role
+subjects:
+- kind: ServiceAccount
+  name: vescollector-patch-sa
+  namespace: smo
\ No newline at end of file
diff --git a/smo-install/oran_oom/smo/common/templates/vescollector-patch.yaml b/smo-install/oran_oom/smo/common/templates/vescollector-patch.yaml
new file mode 100644 (file)
index 0000000..5422c3e
--- /dev/null
@@ -0,0 +1,43 @@
+################################################################################
+#   Copyright (C) 2025 OpenInfra Foundation Europe                             #
+#                                                                              #
+#   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: batch/v1
+kind: Job
+metadata:
+  name: vescollector-patch
+  annotations:
+    "helm.sh/hook": pre-install
+    "helm.sh/hook-weight": "4"
+spec:
+  template:
+    spec:
+      serviceAccountName: vescollector-patch-sa
+      containers:
+      - name: vescollector-patch-container
+        image: bitnami/kubectl:1.32.2
+        command: ["bash","/scripts/patch-ves-collector.sh"]
+        securityContext:
+          allowPrivilegeEscalation: false
+          runAsUser: 0
+        volumeMounts:
+          - name: vescollector-patch-config-volume
+            mountPath: /scripts
+      volumes:
+        - name: vescollector-patch-config-volume
+          configMap:
+            name: vescollector-patch-config
+            defaultMode: 0755
+      restartPolicy: Never