[source language=”bash”]
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "Please input pod_id"
exit 1
fi
pod_name=$1
num=10
if [[ $# -eq 2 ]]; then
num=$2
fi
node_name=`po_all|grep $1|awk {‘print $7’}` # 获取k8s中pod所在nodename,service images将日志重定向到特定目录,pod_name.log
ssh -p 16688 -o StrictHostKeyChecking=no -t david@${node_name} "tail -n ${num} -f /var/log/yinnut-services/${pod_name}.log"
[/source]