Skip to content

Commit 92bd370

Browse files
authored
Merge pull request #1676 from todor-ivanov/fixDBSDeploymentScript
Read the tag from cmd for deploy-srv-dbs.sh && Add scaledown-srv-dbs.sh
2 parents d32e8f7 + 00f3ed0 commit 92bd370

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

kubernetes/cmsweb/scripts/deploy-srv-dbs.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
# Define the target namespace in the new cluster
44
target_namespace="dbs"
55

6+
# Fetch the tag from command prompt
7+
tag=$1
8+
69
# Mapping of service names to their full image tags
710
declare -A service_image_tags=(
811
["check-metric"]="registry.cern.ch/cmsweb/check-metric:20220404-stable"
9-
["dbs2go-global-m"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
10-
["dbs2go-global-migration"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
11-
["dbs2go-global-r"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
12-
["dbs2go-global-w"]="registry.cern.ch/cmsweb/dbs2go:v00.06.43-stable"
13-
["dbs2go-phys03-m"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
14-
["dbs2go-phys03-migration"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
15-
["dbs2go-phys03-r"]="registry.cern.ch/cmsweb/dbs2go:v00.06.42-stable"
16-
["dbs2go-phys03-w"]="registry.cern.ch/cmsweb/dbs2go:v00.06.43-stable"
12+
["dbs2go-global-m"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
13+
["dbs2go-global-migration"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
14+
["dbs2go-global-r"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
15+
["dbs2go-global-w"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
16+
["dbs2go-phys03-m"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
17+
["dbs2go-phys03-migration"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
18+
["dbs2go-phys03-r"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
19+
["dbs2go-phys03-w"]="registry.cern.ch/cmsweb/dbs2go:${tag:-v00.06.44-stable}"
1720
)
1821

1922
# Loop through the service names and their full image tags
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Scales down all DBS deployments in the current K8 cluster for a given interval of time in sec.
4+
# If no interval has been provided, scales down all of them and exits
5+
6+
interval=$1
7+
8+
# Build a list of all current replicas in each deployment:
9+
deployList=`kubectl -n dbs get deploy |grep dbs2go |awk '{print $1":"$3}'`
10+
echo $deployList
11+
12+
# Scale down all deployments:
13+
for depl in $deployList
14+
do
15+
repl=${depl#*:}; depl=${depl%:*};
16+
echo Scaling down: ${depl}:0
17+
kubectl -n dbs scale deploy $depl --replicas=0
18+
done
19+
20+
# Exit here if no interval has been provided
21+
[[ -z $interval ]] && exit 0
22+
23+
# Wait before scaling up again:
24+
while [[ $interval -ne 0 ]]; do echo $interval; sleep 1; let "interval--"; done
25+
26+
# Scale up again to the original number of replicas
27+
for depl in $deployList
28+
do
29+
repl=${depl#*:}; depl=${depl%:*};
30+
echo Scaling up: ${depl}:$repl
31+
kubectl -n dbs scale deploy $depl --replicas=$repl
32+
done

0 commit comments

Comments
 (0)