通常由于iptables問題和selinux問題
解決方式
setenforce 0
iptables --flush
iptables -tnat --flush
service docker restart
iptables -P FORWARD ACCEPT
官方原文:
Disabling SELinux by running setenforce 0 is required to allow containers to access the host filesystem, which is required by pod networks for example. You have to do this until SELinux support is improved in the kubelet.
翻譯就是
通過setenforce 0
關閉SELinux是必須的,這樣容器才可以訪問主機的文件系統(tǒng),例如pod的網絡操作就需要訪問主機文件系統(tǒng)。直到kubelet支持SELinux之前你都需要關閉SELinux。
iptables --flush
和iptables -tnat --flush
是清空iptables的規(guī)則,然后重啟docker后會重新加入kubernetes的iptables規(guī)則,iptables -P FORWARD ACCEPT
則允許轉發(fā)