blob: aa118197841ad5f08eec1b435ea39a8e8c9a8936 [file] [log] [blame]
garciadeblas90344b62024-08-20 16:28:12 +02001#!/bin/bash
2#######################################################################################
3# Copyright ETSI Contributors and Others.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#######################################################################################
18
garciadeblasd2272722024-09-11 14:35:35 +020019if [ $# -ne 2 ]; then
garciadeblas90344b62024-08-20 16:28:12 +020020 echo "Usage $0 <module> <tag_number>"
garciadeblas09b4b242024-09-25 16:36:24 +020021 echo " Example: $0 ro 2"
22 echo " Will import image in containerd local registry as opensourcemano/ro:devel-2"
23 echo " Example: $0 lcm 5"
24 echo " Will import image in containerd local registry as opensourcemano/lcm:devel-5"
25 echo " Example: $0 osm-krm-functions 24h"
26 echo " (when tag_number is '[0-9]+h') Will push the image to ttl.sh/osm-krm-functions-devel:24h"
garciadeblas90344b62024-08-20 16:28:12 +020027 exit 1
28fi
29
30MODULE_NAME="$1"
31TAG_NUMBER="$2"
32
33set -x
garciadeblas09b4b242024-09-25 16:36:24 +020034
35if [[ "${TAG_NUMBER}" =~ ^[0-9]+h$ ]]; then
36 IMAGE_NAME="ttl.sh/${MODULE_NAME}-devel:${TAG_NUMBER}"
37 docker tag opensourcemano/${MODULE_NAME}:devel ${IMAGE_NAME}
38 docker push ${IMAGE_NAME}
39 exit 0
40else
41 echo "Image will be imported locally"
42fi
43
garciadeblas90344b62024-08-20 16:28:12 +020044IMAGE_NAME="opensourcemano/${MODULE_NAME}:devel-${TAG_NUMBER}"
45docker tag opensourcemano/${MODULE_NAME}:devel ${IMAGE_NAME}
46IMAGE_FILE="${MODULE_NAME}-devel-${TAG_NUMBER}.tar.gz"
47docker save -o ${IMAGE_FILE} ${IMAGE_NAME}
48sudo ctr -n=k8s.io images import ${IMAGE_FILE}
49rm ${IMAGE_FILE}
50sudo ctr -n=k8s.io images list |grep ${IMAGE_NAME}
51echo $IMAGE_NAME
garciadeblasa2cd7242024-12-13 12:23:55 +010052MODULE_NAME_CLEAN=${MODULE_NAME//-/}
53kubectl -n osm patch deployment ${MODULE_NAME_CLEAN} --patch '{"spec": {"template": {"spec": {"containers": [{"name": "'${MODULE_NAME_CLEAN}'", "image": "'${IMAGE_NAME}'"}]}}}}'
54kubectl -n osm rollout restart deployment ${MODULE_NAME_CLEAN}
garciadeblas90344b62024-08-20 16:28:12 +020055