From 85f9fb4a4053f7d96c409285acc105e41ec05d46 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Wed, 29 Sep 2021 14:11:59 +0800 Subject: [PATCH] Update export k8s log script (#8832) Signed-off-by: zhuwenxing --- tests/scripts/export_log_k8s.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/scripts/export_log_k8s.sh b/tests/scripts/export_log_k8s.sh index f2d9181a5b..ca83c89f3c 100644 --- a/tests/scripts/export_log_k8s.sh +++ b/tests/scripts/export_log_k8s.sh @@ -1,11 +1,19 @@ -array=($(kubectl get pod|grep chaos-milvus|awk '{print $1}')) # change chaos-milvus to your own pod name prefix +#!/bin/bash +set -e + +ns_name=$1 +prefix_name=$2 +array=($(kubectl get pod -n ${ns_name}|grep ${prefix_name}|awk '{print $1}')) echo ${array[@]} log_dir="k8s_logs" -mkdir $log_dir +if [ ! -d $log_dir ]; +then + mkdir $log_dir +fi echo "export logs start" for pod in ${array[*]} do echo "export logs for pod $pod " -kubectl logs $pod > ./$log_dir/$pod.log +kubectl logs $pod -n ${ns_name} > ./$log_dir/$pod.log done echo "export logs done"