Add flag to control strimzi secret copy 26/14326/1
authoraravind.est <aravindhan.a@est.tech>
Thu, 17 Apr 2025 14:02:36 +0000 (15:02 +0100)
committeraravind.est <aravindhan.a@est.tech>
Thu, 17 Apr 2025 14:02:36 +0000 (15:02 +0100)
New flag added based on which the decision to copy the secret is taken.
If the specific service is not enabled. The respective secret will not be copied to the smo namespace.

Issue-ID: NORTRIC-1020
Change-Id: I794120b4d0de6b4c3d0687aa4574d2230b80c83b
Signed-off-by: aravind.est <aravindhan.a@est.tech>
smo-install/helm-override/default/oran-override.yaml
smo-install/scripts/sub-scripts/install-smo.sh

index e96ce31..c724693 100644 (file)
@@ -139,8 +139,12 @@ dashboard:
 ######### SMO #########
 smo:
   installTeiv: true
-  #List of secrets to be copied from ONAP namespace to SMO
+  # List of secrets to be copied from ONAP namespace to SMO
+  # Based on the dependsOn value, the secrets will be copied to the SMO namespace
   secrets:
-    - topology-exposure-ku
-    - topology-ingestion-ku
-    - redpanda-console-ku
\ No newline at end of file
+    - name: topology-exposure-ku
+      dependsOn: smo.installTeiv
+    - name: topology-ingestion-ku
+      dependsOn: smo.installTeiv
+    - name: redpanda-console-ku
+      dependsOn: nonrtric.installRanpm
\ No newline at end of file
index b676af4..1b64dec 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
-# Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+# Copyright (C) 2024-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.
@@ -39,13 +39,26 @@ check_for_secrets() {
     done
     echo "$1 found"
 }
+
 # Copying kafka secrets from onap namespace
 # SMO installation uses ONAP strimzi kafka
 # All KafkaUser and KafkaTopic resources should be created as part of ONAP namespace
 # This enables the strimzi entity operator to create the secrets as necessary
 # Once the secrets are created, it should be copied to the SMO namespace
-while IFS= read -r secret; do
-    echo "Copying $secret from onap namespace..."
-    check_for_secrets $secret
-    kubectl get secret $secret -n onap -o json | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid","ownerReferences"])' | kubectl apply -n smo -f -
-done < <(yq '.smo.secrets[]' $OVERRIDEYAML)
+SECRETS_SIZE=$(yq '.smo.secrets | length' $OVERRIDEYAML)
+if [ "$SECRETS_SIZE" -eq 0 ]; then
+    echo "No secrets to copy from onap namespace"
+    exit 0
+else
+    for i in $(seq 0 $((SECRETS_SIZE - 1))); do
+        secret=$(yq ".smo.secrets[$i].name" $OVERRIDEYAML)
+        dependsOn=$(yq ".smo.secrets[$i].dependsOn" $OVERRIDEYAML)
+        if [ $(yq ".$dependsOn" $OVERRIDEYAML) != "true" ]; then
+            echo "$dependsOn is not set to true. Skipping $secret copy..."
+            continue
+        fi
+        echo "Copying $secret from onap namespace..."
+        check_for_secrets $secret
+        kubectl get secret $secret -n onap -o json | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid","ownerReferences"])' | kubectl apply -n smo -f -
+    done
+fi