From c1bdafcd3da68a0a490106e28007a2ef12c288da Mon Sep 17 00:00:00 2001 From: "aravind.est" Date: Thu, 22 May 2025 15:58:06 +0100 Subject: [PATCH] Patch VES collector with new schemas 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 --- .../smo/common/resources/patch-ves-collector.sh | 47 +++++++++++++++++++ .../templates/vescollector-patch-configmap.yaml | 26 +++++++++++ .../common/templates/vescollector-patch-rbac.yaml | 53 ++++++++++++++++++++++ .../smo/common/templates/vescollector-patch.yaml | 43 ++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100755 smo-install/oran_oom/smo/common/resources/patch-ves-collector.sh create mode 100644 smo-install/oran_oom/smo/common/templates/vescollector-patch-configmap.yaml create mode 100644 smo-install/oran_oom/smo/common/templates/vescollector-patch-rbac.yaml create mode 100644 smo-install/oran_oom/smo/common/templates/vescollector-patch.yaml 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 index 00000000..9f878c94 --- /dev/null +++ b/smo-install/oran_oom/smo/common/resources/patch-ves-collector.sh @@ -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 index 00000000..7f872d60 --- /dev/null +++ b/smo-install/oran_oom/smo/common/templates/vescollector-patch-configmap.yaml @@ -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 index 00000000..7ec5d3db --- /dev/null +++ b/smo-install/oran_oom/smo/common/templates/vescollector-patch-rbac.yaml @@ -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 index 00000000..5422c3ee --- /dev/null +++ b/smo-install/oran_oom/smo/common/templates/vescollector-patch.yaml @@ -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 -- 2.16.6