Skip to content

Commit 094d136

Browse files
committed
kubectl-ko: get ovn db leaders only on necessary (#3158)
* kubectl-ko: get ovn db leaders only on necessary * kubectl-ko: apply yaml from stdin --------- Signed-off-by: 张祖建 <zhangzujian.7@gmail.com>
1 parent 1dad23d commit 094d136

File tree

1 file changed

+16
-45
lines changed

1 file changed

+16
-45
lines changed

dist/images/kubectl-ko

+16-45
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ OVN_NB_POD=
77
OVN_SB_POD=
88
OVN_NORTHD_POD=
99
KUBE_OVN_VERSION=
10-
REGISTRY="kubeovn"
10+
REGISTRY="docker.io/kubeovn"
1111
PERF_TIMES=5
1212
PERF_LABEL="PerfTest"
1313
CONN_CHECK_LABEL="conn-check"
@@ -36,7 +36,7 @@ showHelp(){
3636
echo " tuning {install-fastpath|local-install-fastpath|remove-fastpath|install-stt|local-install-stt|remove-stt} {centos7|centos8}} [kernel-devel-version] deploy kernel optimisation components to the system"
3737
echo " reload restart all kube-ovn components"
3838
echo " log {kube-ovn|ovn|ovs|linux|all} save log to ./kubectl-ko-log/"
39-
echo " perf [image] performance test default image is kubeovn/test:v1.12.0"
39+
echo " perf [image] performance test default image is docker.io/kubeovn/test:v1.13.0"
4040
}
4141

4242
# usage: ipv4_to_hex 192.168.0.1
@@ -509,8 +509,7 @@ applyConnServerDaemonset(){
509509
fi
510510

511511
imageID=$(kubectl get ds -n $KUBE_OVN_NS kube-ovn-pinger -o jsonpath={.spec.template.spec.containers[0].image})
512-
tmpFileName="conn-server.yaml"
513-
cat <<EOF > $tmpFileName
512+
cat <<EOF | kubectl apply -f -
514513
kind: DaemonSet
515514
apiVersion: apps/v1
516515
metadata:
@@ -544,8 +543,6 @@ spec:
544543
fieldRef:
545544
fieldPath: metadata.name
546545
EOF
547-
kubectl apply -f $tmpFileName
548-
rm $tmpFileName
549546

550547
isfailed=true
551548
for i in {0..59}
@@ -565,9 +562,7 @@ EOF
565562

566563
applyTestNodePortService() {
567564
local svcName="test-node-port"
568-
tmpFileName="$svcName.yaml"
569-
570-
cat <<EOF > $tmpFileName
565+
cat <<EOF | kubectl apply -f -
571566
apiVersion: v1
572567
kind: Service
573568
metadata:
@@ -585,12 +580,9 @@ spec:
585580
selector:
586581
app: kube-ovn-pinger
587582
EOF
588-
kubectl apply -f $tmpFileName
589-
rm $tmpFileName
590583
}
591584

592585
getTestNodePortServiceIPPorts() {
593-
594586
targetIPPorts=""
595587
nodeIPs=($(kubectl get node -o wide | grep -v "INTERNAL-IP" | awk '{print $6}'))
596588
nodePort=$(kubectl get svc test-node-port -n $KUBE_OVN_NS -o 'jsonpath={.spec.ports[0].nodePort}')
@@ -1253,9 +1245,7 @@ applyTestServer() {
12531245
podName="test-server"
12541246
nodeID=$1
12551247
imageID=$2
1256-
tmpFileName="$podName.yaml"
1257-
1258-
cat <<EOF > $tmpFileName
1248+
cat <<EOF | kubectl apply -f -
12591249
apiVersion: v1
12601250
kind: Pod
12611251
metadata:
@@ -1277,18 +1267,13 @@ spec:
12771267
nodeSelector:
12781268
kubernetes.io/hostname: $nodeID
12791269
EOF
1280-
1281-
kubectl apply -f $tmpFileName
1282-
rm $tmpFileName
12831270
}
12841271

12851272
applyTestHostServer() {
12861273
podName="test-host-server"
12871274
nodeID=$1
12881275
imageID=$2
1289-
tmpFileName="$podName.yaml"
1290-
1291-
cat <<EOF > $tmpFileName
1276+
cat <<EOF | kubectl apply -f -
12921277
apiVersion: v1
12931278
kind: Pod
12941279
metadata:
@@ -1310,19 +1295,13 @@ spec:
13101295
nodeSelector:
13111296
kubernetes.io/hostname: $nodeID
13121297
EOF
1313-
1314-
kubectl apply -f $tmpFileName
1315-
rm $tmpFileName
13161298
}
13171299

1318-
13191300
applyTestClient() {
13201301
local podName="test-client"
13211302
local nodeID=$1
13221303
local imageID=$2
1323-
tmpFileName="$podName.yaml"
1324-
1325-
cat <<EOF > $tmpFileName
1304+
cat <<EOF | kubectl apply -f -
13261305
apiVersion: v1
13271306
kind: Pod
13281307
metadata:
@@ -1339,17 +1318,13 @@ spec:
13391318
nodeSelector:
13401319
kubernetes.io/hostname: $nodeID
13411320
EOF
1342-
kubectl apply -f $tmpFileName
1343-
rm $tmpFileName
13441321
}
13451322

13461323
applyTestHostClient() {
13471324
local podName="test-host-client"
13481325
local nodeID=$1
13491326
local imageID=$2
1350-
tmpFileName="$podName.yaml"
1351-
1352-
cat <<EOF > $tmpFileName
1327+
cat <<EOF | kubectl apply -f -
13531328
apiVersion: v1
13541329
kind: Pod
13551330
metadata:
@@ -1367,15 +1342,11 @@ spec:
13671342
nodeSelector:
13681343
kubernetes.io/hostname: $nodeID
13691344
EOF
1370-
kubectl apply -f $tmpFileName
1371-
rm $tmpFileName
13721345
}
13731346

13741347
applyTestServerService() {
13751348
local svcName="test-server"
1376-
tmpFileName="$svcName.yaml"
1377-
1378-
cat <<EOF > $tmpFileName
1349+
cat <<EOF | kubectl apply -f -
13791350
apiVersion: v1
13801351
kind: Service
13811352
metadata:
@@ -1404,8 +1375,6 @@ spec:
14041375
selector:
14051376
env: server
14061377
EOF
1407-
kubectl apply -f $tmpFileName
1408-
rm $tmpFileName
14091378
}
14101379

14111380
addHeaderDecoration() {
@@ -1456,7 +1425,7 @@ quitPerfTest() {
14561425

14571426
perf(){
14581427
addHeaderDecoration "Prepareing Performance Test Resources"
1459-
imageID=${1:-"kubeovn/test:v1.12.0"}
1428+
imageID=${1:-"docker.io/kubeovn/test:v1.13.0"}
14601429

14611430
nodes=($(kubectl get node --no-headers -o custom-columns=NAME:.metadata.name))
14621431
if [[ ${#nodes} -eq 1 ]]; then
@@ -1601,7 +1570,7 @@ genMulticastPerfResult() {
16011570
tmpFileName="multicast-$serverName.log"
16021571
PERF_GC_COMMAND+=("rm -f $tmpFileName")
16031572
LAST_PERF_FAILED_LOG=$tmpFileName
1604-
1573+
16051574
start_server_cmd="iperf -s -B 224.0.0.100 -i 1 -u"
16061575
kubectl exec $serverName -n $KUBE_OVN_NS -- $start_server_cmd > $tmpFileName &
16071576
sleep 1
@@ -1627,7 +1596,6 @@ checkLeaderRecover() {
16271596
sleep 5
16281597
getOvnCentralPod
16291598
getPodRecoverTime "northd"
1630-
16311599
}
16321600

16331601
getPodRecoverTime(){
@@ -1663,25 +1631,27 @@ fi
16631631

16641632
subcommand="$1"; shift
16651633

1666-
getOvnCentralPod
1667-
16681634
case $subcommand in
16691635
nbctl)
1636+
getOvnCentralPod
16701637
kubectl exec "$OVN_NB_POD" -n $KUBE_OVN_NS -c ovn-central -- ovn-nbctl "$@"
16711638
;;
16721639
sbctl)
1640+
getOvnCentralPod
16731641
kubectl exec "$OVN_SB_POD" -n $KUBE_OVN_NS -c ovn-central -- ovn-sbctl "$@"
16741642
;;
16751643
vsctl|ofctl|dpctl|appctl)
16761644
xxctl "$subcommand" "$@"
16771645
;;
16781646
nb|sb)
1647+
getOvnCentralPod
16791648
dbtool "$subcommand" "$@"
16801649
;;
16811650
tcpdump)
16821651
tcpdump "$@"
16831652
;;
16841653
trace)
1654+
getOvnCentralPod
16851655
trace "$@"
16861656
;;
16871657
diagnose)
@@ -1700,6 +1670,7 @@ case $subcommand in
17001670
log "$@"
17011671
;;
17021672
perf)
1673+
getOvnCentralPod
17031674
perf "$@"
17041675
;;
17051676
*)

0 commit comments

Comments
 (0)