Rancher 各组件开启 debug 级别日志

包括 Rancher、Rancher System Agent、Cattle Cluster Agent 等组件开启 debug 级别日志方法。

Rancher

开启 debug:

1
kubectl -n cattle-system get pod -l app=rancher --no-headers | awk '{ print "kubectl -n cattle-system exec "$1" -c rancher -- loglevel --set debug" }' | sh

关闭 debug:

1
kubectl -n cattle-system get pod -l app=rancher --no-headers | awk '{ print "kubectl -n cattle-system exec "$1" -c rancher -- loglevel --set info" }' | sh

Rancher System Agent

Rancher System Agent 是通过 systemd 方式运行在节点上的组件,需要通过传入环境变量的方式开启 debug。

开启 debug:

1
2
3
4
5
6
7
cat > /etc/systemd/system/rancher-system-agent.env <<EOF
RANCHER_DEBUG=true
CATTLE_DEBUG=true
CATTLE_LOGLEVEL=debug
EOF

systemctl restart rancher-system-agent.service

关闭 debug:

1
2
3
cat /dev/null > /etc/systemd/system/rancher-system-agent.env

systemctl restart rancher-system-agent.service

Cattle Cluster Agent

开启 debug:

1
kubectl -n cattle-system get pod -l app=cattle-cluster-agent --no-headers | awk '{ print "kubectl -n cattle-system exec "$1" -- loglevel --set debug"  }' | sh

关闭 debug:

1
kubectl -n cattle-system get pod -l app=cattle-cluster-agent --no-headers | awk '{ print "kubectl -n cattle-system exec "$1" -- loglevel --set info"  }' | sh
Author

Warner Chen

Posted on

2025-11-04

Updated on

2025-11-04

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.