我正在按照 Kelseys 实验室设置 Kubernetes 集群:https://github.com/kelseyhightower/kubernetes-the-hard-way
到目前为止我只设置了一个节点。尝试部署 Pod 时,以下错误会阻止它启动:
警告 FailedSync Error syncing pod, skipping: failed to "SetupNetwork"for "nginx-3137573019-pjbie_default"with SetupNetworkError: "Failed to setup network for pod\"nginx-3137573019-pjbie_default(b4128fc1-6707-11e6 -a8b3-005056a2068d)\"使用网络插件\"kubenet\": 无法执行 iptables-restore: 退出状态 1 (无法打开/tmp/kube-temp-iptables-restore-214792160: 权限被拒绝\n);跳绳”
kubelet 以 root 身份运行。日志中提到的文件也属于root。
系统为 Linux OEL 7(内核:UEK 4.1.12)
有没有人知道原因可能是什么或如何进一步调查?
最佳答案
听起来 SELinux 正在阻止 kubelet
对 IPtables 执行更改。在 /var/log/audit/audit.log
中搜索包含字符串“AVC”的消息以确认该理论。
最简单的解决方法是使用 shell 命令 setenforce 0
完全禁用 SELinux。这不会在重启后继续存在,因此请确保您还在 /etc/selinux/config
中禁用了 SELinux。
如果您不想完全禁用 SELinux(我建议这样做),您将不得不使用像 audit2allow
和 semodule
这样的工具来构建您自己的kubelet
和 kube-proxy
的 SELinux 模块。
查看这些引用资料以获得进一步的指导:
关于linux - Iptables 错误阻止 Pod 在 Kubernetes 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39059149/