定时拉取k8s服务中日志
k8s日志在内网无法拉取,通过脚本方式,输出日志
后50000条日志
#!/bin/bash
log_dir=/export/icity/see_log/
deploy_1=lunling-linkage-core
deploy_2=hola-app-orchestrator-server
#log_date=`date +%F_%H`
. /etc/init.d/functions
function log_export() {
mkdir -p ${log_dir}/$1
for i in `kubectl get pod -n lunling | grep $1 | awk '{print $1}'`;
do
kubectl logs $i -n lunling --tail=50000 > ${log_dir}/$1/${i}_tail_50000.log
done
}
log_export ${deploy_1}
log_export ${deploy_2}
find /export/icity/see_log -name "*.log" -mtime +3|xargs -i rm -f {} \;
一小时内日志
#!/bin/bash
log_dir=/export/icity/see_log/
log_date=`date +%F_%H`
deploy_1=lunling-linkage-core
deploy_2=hola-app-orchestrator-server
. /etc/init.d/functions
function log_export() {
mkdir -p ${log_dir}/$1
for i in `kubectl get pod -n lunling | grep $1 | awk '{print $1}'`;
do
kubectl logs $i -n lunling --since=1h > ${log_dir}/$1/${i}_${log_date}.log
done
}
log_export ${deploy_1}
log_export ${deploy_2}
find /export/icity/see_log -name "*.log" -mtime +3|xargs -i rm -f {} \;
更多推荐
所有评论(0)