Add tool to patch an OSM module using locally built docker image 22/14522/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 20 Aug 2024 14:28:12 +0000 (16:28 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 20 Aug 2024 16:10:26 +0000 (18:10 +0200)
Change-Id: I9b5cdf55d0d68396745c5fc7c25422bf2d72864d
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
tools/patch_module.sh [new file with mode: 0755]

diff --git a/tools/patch_module.sh b/tools/patch_module.sh
new file mode 100755 (executable)
index 0000000..4f89936
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+
+if [ $# -ne 3 ]; then
+    echo "Usage $0 <module> <tag_number>"
+    echo "Example: $0 ro 2"
+    echo "Example: $0 lcm 5"
+    exit 1
+fi
+
+MODULE_NAME="$1"
+TAG_NUMBER="$2"
+
+set -x
+IMAGE_NAME="opensourcemano/${MODULE_NAME}:devel-${TAG_NUMBER}"
+docker tag opensourcemano/${MODULE_NAME}:devel ${IMAGE_NAME}
+IMAGE_FILE="${MODULE_NAME}-devel-${TAG_NUMBER}.tar.gz"
+docker save -o ${IMAGE_FILE} ${IMAGE_NAME}
+sudo ctr -n=k8s.io images import ${IMAGE_FILE}
+rm ${IMAGE_FILE}
+sudo ctr -n=k8s.io images list |grep ${IMAGE_NAME}
+echo $IMAGE_NAME
+kubectl -n osm patch deployment ${MODULE_NAME} --patch '{"spec": {"template": {"spec": {"containers": [{"name": "'${MODULE_NAME}'", "image": "'${IMAGE_NAME}'"}]}}}}'
+kubectl -n osm rollout restart deployment ${MODULE_NAME}
+