copy windows pod 文件到宿主机
把 kube-proxy-windows-cmd4p pod 中 c:/utils/wins.exe copy到宿主机
kubectl cp kube-system/kube-proxy-windows-cmd4p:utils/wins.exe /home/hnidc/tmp/wins.exe
强制清理 namespace
如果删除资源,长时间等待,无法清理。可强制清理 namespace。以清理 kubevirt为例。
参考:https://zhuanlan.zhihu.com/p/128599556
1
kubectl get ns kubevirt -o json > kubevirt.json
2
编辑 kubevirt.json,去掉 spec里面的 finalizers
3
执行命令
kubectl proxy
4
curl 调用接口删除,注意替换 namespace。
curl -k -H "Content-Type: application/json" -X PUT --data-binary @kubevirt.json http://127.0.0.1:8001/api/v1/namespaces/kubevirt/finalize
5
如果有crd未删除,还应把crd删除
kubectl patch crd/virtualmachineinstances.kubevirt.io -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch crd/kubevirts.kubevirt.io -p '{"metadata":{"finalizers":[]}}' --type=merge
统计pod磁盘使用
kubectl exec -it 1804138136479531008-master -- du -h --max-depth=1 /
也可使用 docker system df -v
查找pod eth0 对端
在pod中执行命令
#显示对端index
cat /sys/class/net/eth0/iflink
在宿主机上使用 index 搜索设备
# 116851 是index编号
ip addr |grep 116851 -A 4
查看网络
host 上执行
ip neigh show dev flannel.4096
bridge fdb
arp -a
查询 iptables规则
iptables -t nat -S
iptables -nvL PREROUTING -t nat
iptables -nvL KUBE-SERVICES -t nat
iptables -nvL KUBE-SVC-IJL4IIOSWOTW2SYX -t nat
iptables -nvL KUBE-SEP-USEBOZELZZA6EBQ4 -t nat
iptables -nvL INPUT -t filter